Click here to Skip to main content
15,913,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralNeed help with key logger (?) Pin
Snyp3-Jan-04 9:00
Snyp3-Jan-04 9:00 
GeneralRe: Need help with key logger (?) Pin
abc8763-Jan-04 9:20
abc8763-Jan-04 9:20 
GeneralRe: Need help with key logger (?) Pin
Jörgen Sigvardsson4-Jan-04 4:21
Jörgen Sigvardsson4-Jan-04 4:21 
GeneralDialog based SDI Pin
TolTol3-Jan-04 7:22
TolTol3-Jan-04 7:22 
GeneralRe: Dialog based SDI Pin
abc8763-Jan-04 8:56
abc8763-Jan-04 8:56 
GeneralRe: Dialog based SDI Pin
TolTol3-Jan-04 9:41
TolTol3-Jan-04 9:41 
GeneralWindows system font size Pin
zwergerl3-Jan-04 6:18
zwergerl3-Jan-04 6:18 
GeneralProblems getting client area screen coordinates Pin
doomgaze3-Jan-04 6:08
doomgaze3-Jan-04 6:08 
Heya,
This problem's been dogging me for a couple days already, so I'm asking you guys.

As you can see from the code below, I'm trying to implement a DirectDraw wrapper. One of my design goals is that the wrapper should automatically handle window size and resizing without relying on adding function calls and so on to track it in WinMain or in my WindProc.

I decided to solve this problem by simply comparing the client rect this frame to the client rect as it existed last frame. I even overloaded the != operator just so I could do it.

In theory, by simply calling GetClientScreenRect() I can get the screen coordinates of the client rect so that it can directly be used for blitting from a 'fake' DirectDraw backbuffer. Also, in theory, I could compare it to the client/screen rect from last frame to check to see if it's been resized. I could then set the window back to it's proper size using the SetWindowSize() function.

Each function appears to work fine independent of each other, but when I call SetWindowSize() before I call GetClientScreenRect(), ClientToScreen() returns some values that can only be described as "wonky".

In the example, below, I want 640x480 as the client area (m_iScreenX and Y). SetWindowSize() appears to work fine and the next time I call GetClientRect() in GetClientScreenRect(), it returns the values I'd expect (left and top == 0, right == 640, bottom == 480). But when I pass those coordinates in to ClientToScreen(), it returns the following rect: left == -32764, top == -32718, right == -32124, bottom == -32238. Even more curiously, if I subtract right - left and bottom - top, my requested client area pops out: 640x480.

Can anyone tell me why this is happening?

<br />
void CDirectDrawWrapper::SetWindowSize()<br />
{<br />
	// Get the style info out of windows<br />
	WINDOWINFO winfo;<br />
	winfo.cbSize = sizeof(WINDOWINFO);<br />
	if (GetWindowInfo(m_hWnd, &winfo))<br />
	{<br />
		// We want our client area like so.<br />
		RECT rectWindow;<br />
		rectWindow.top = rectWindow.left = 0;<br />
		rectWindow.right = m_iScreenX;<br />
		rectWindow.bottom = m_iScreenY;<br />
<br />
		// Adjust our rect so that it matches the client area<br />
		AdjustWindowRectEx(&rectWindow, winfo.dwStyle, GetMenu(m_hWnd) != NULL,<br />
			winfo.dwExStyle);<br />
	<br />
		// Adjust the window.<br />
		MoveWindow(m_hWnd, CW_USEDEFAULT, CW_USEDEFAULT, <br />
			rectWindow.right - rectWindow.left,<br />
			rectWindow.bottom - rectWindow.top, FALSE);<br />
	}<br />
}<br />
<br />
// This function is a hack right now.  Can't figure out why ClientToScreen<br />
// doesn't work, but it has something to do with the way I'm setting the size.<br />
bool CDirectDrawWrapper::GetClientScreenRect(LPRECT pRect)<br />
{<br />
	if (pRect)<br />
	{<br />
		// Store the client rect to the pointer<br />
		GetClientRect(m_hWnd, pRect);<br />
<br />
		// Get the screen coordinates of our rect<br />
		if (ClientToScreen(m_hWnd, (POINT*)&pRect->left) && <br />
			ClientToScreen(m_hWnd, (POINT*)&pRect->right))<br />
		{<br />
			return true;<br />
		}<br />
	}<br />
<br />
	return false;<br />
}<br />


Thanks in advance,

DoomGaze
GeneralVisual Studio 2003 - C++ Pin
Runka3-Jan-04 5:44
sussRunka3-Jan-04 5:44 
GeneralRe: Visual Studio 2003 - C++ Pin
valikac3-Jan-04 5:48
valikac3-Jan-04 5:48 
GeneralRe: Visual Studio 2003 - C++ Pin
runka5-Jan-04 2:05
sussrunka5-Jan-04 2:05 
Questionhow to start an application and wait for its end Pin
gaxxx3-Jan-04 4:26
gaxxx3-Jan-04 4:26 
AnswerRe: how to start an application and wait for its end Pin
John R. Shaw3-Jan-04 4:40
John R. Shaw3-Jan-04 4:40 
AnswerRe: how to start an application and wait for its end Pin
John R. Shaw3-Jan-04 4:50
John R. Shaw3-Jan-04 4:50 
GeneralRe: how to start an application and wait for its end Pin
gaxxx3-Jan-04 5:12
gaxxx3-Jan-04 5:12 
GeneralWebbrowser control unexpected behaviour Pin
blindcop3-Jan-04 1:59
blindcop3-Jan-04 1:59 
GeneralRe: Webbrowser control unexpected behaviour Pin
John R. Shaw3-Jan-04 2:36
John R. Shaw3-Jan-04 2:36 
GeneralRe: Webbrowser control unexpected behaviour Pin
blindcop3-Jan-04 2:52
blindcop3-Jan-04 2:52 
GeneralRe: Webbrowser control unexpected behaviour Pin
John R. Shaw3-Jan-04 3:20
John R. Shaw3-Jan-04 3:20 
QuestionHow to make apply different form designs to a dialog Pin
blindcop3-Jan-04 1:56
blindcop3-Jan-04 1:56 
AnswerRe: How to make apply different form designs to a dialog Pin
John R. Shaw3-Jan-04 2:27
John R. Shaw3-Jan-04 2:27 
GeneralRe: How to make apply different form designs to a dialog Pin
blindcop3-Jan-04 2:54
blindcop3-Jan-04 2:54 
GeneralRe: How to make apply different form designs to a dialog Pin
John R. Shaw3-Jan-04 3:33
John R. Shaw3-Jan-04 3:33 
GeneralAddress Bar Pin
Prakash Nadar3-Jan-04 0:57
Prakash Nadar3-Jan-04 0:57 
GeneralI need EasyCalulator code! Pin
shenziyang2-Jan-04 20:17
shenziyang2-Jan-04 20:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.