• Advertisement

Archived

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

Getting DC height and width

This topic is 5777 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

How do you get the height and width of an arbitrary DC? GetDeviceCaps seemed the way to go, but it only seems to work on the screen.

Share this post


Link to post
Share on other sites
Advertisement
void OglView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
CClientDC dc( this );
CRect rect;
GetClientRect( rect );
CDC dcMem;

dcMem.CreateCompatibleDC( & dc );

// grab anything you like here, now dcMen contains
// a copy of the current device context for the
// view you have called the onsize message

dcMem.DeleteDC( );

Mx = ( float )( rect.right - rect.left ) ;
My = ( float )( rect.bottom - rect.top ) ;



}



Share this post


Link to post
Share on other sites
GetClientRect... cool, looks like that will do the job. I''ll try it after work. Thx.

Share this post


Link to post
Share on other sites

  • Advertisement