• Advertisement

Archived

This topic is now archived and is closed to further replies.

Extracting window size from HDC

This topic is 5358 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I wrote a function that takes an HDC, creates a Render Context for OpenGL, handles all the perspective stuff, and then returns the render context. I had originally hard coded the height and width into the function, but now I''d like to have it work for any size, so I changed the function to look like this:
HGLRC getRC(HDC dcIn, const int width, const in height);
 
but it would be much nicer if I could extract the size of the client area from the DC... so I try this:
HBITMAP hbmIn;
BITMAP bmIn;
hbmIn = (HBITMAP)GetCurrentObject(dcIn, OBJ_BITMAP);
GetObject(hbmIn, sizeof(BITMAP), &bmIn);
 
no dice, the height and width in bmIn are zero so I try this:
SIZE area;
GetWindowExtEx(dcIn, &area);
 
again height and width are zero Is there something that I''m doing wrong? Is there a smart way to extract the height and width of a client area DC?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/GetClientRect.asp


The GetClientRect function retrieves the coordinates of a window''s client area. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window''s client area, the coordinates of the upper-left corner are (0,0).

Syntax

BOOL GetClientRect( HWND hWnd,
LPRECT lpRect
);

Share this post


Link to post
Share on other sites

  • Advertisement