Initialization of the screen rect for bitblt
This is the following code from the Microsoft IM 7.0 demos. I''m just wondering why they only converted the client to screen coordinates for the left and right points that come from the ClientRect() during initialization, and not the top or bottom points. Any reason why?
// Set the dimensions of the back buffer. Note that if our window changes
// size, we need to destroy this surface and create a new one.
GetClientRect( hWnd, &screen_rect );
GetClientRect( hWnd, &viewport_rect );
ClientToScreen( hWnd, (POINT*)&screen_rect.left );
ClientToScreen( hWnd, (POINT*)&screen_rect.right );
ddsd.dwWidth = screen_rect.right - screen_rect.left;
ddsd.dwHeight = screen_rect.bottom - screen_rect.top;
This would be an example of abusing knowledge of the internals of a data structure.
To initialize the rectangle, you only need two points... Well, the two points start at the left and right coordinates. So if you cast the address of the left value to the address of a POINT structure, you get the both the x and y values of that corner. Same for casting the address of the right value. So you really are passing the top and bottom of the rectangle. It''s just hidden in a tricky way.
To initialize the rectangle, you only need two points... Well, the two points start at the left and right coordinates. So if you cast the address of the left value to the address of a POINT structure, you get the both the x and y values of that corner. Same for casting the address of the right value. So you really are passing the top and bottom of the rectangle. It''s just hidden in a tricky way.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement