MrDoomMaster
July 14th, 2005, 06:33 PM
In my level editor, the tiling grid is supposed to be displayed in the CENTER of the client rect. I do this by creating an offset from the top left corner of the client rect. By starting from this offset, I can blitter my grid and it will appear centered both horizontally and vertically. Here is the code to do it:
GridOffset.x = MainCRect.right / 2 - TGRIDSIZEX / 2;
GridOffset.y = MainCRect.bottom / 2 - TGRIDSIZEY / 2;
TGRIDSIZEX and Y are the pixel dimensions of the grid (which is smaller than the client rect). MainCRect is the client rect measurements of the window.
Depending on where I call GetClientRect(), the result of the RECT is always different. For example, right after I create the window, I call GetClientRect() and it returns an invalid size, because my grid is not centered properly.
When I call Get ClientRect() at WM_CREATE, it is even MORE off. The only time GetClientRect() works properly is if I call it in my WM_SIZING handler.
Can someone tell me why it is doing this? Also, how can I get the exact client rect *before* or exactly after the window is created (I want the grid to instantly be centered, so that the user does not see the process of it being centered)?
Thanks!
GridOffset.x = MainCRect.right / 2 - TGRIDSIZEX / 2;
GridOffset.y = MainCRect.bottom / 2 - TGRIDSIZEY / 2;
TGRIDSIZEX and Y are the pixel dimensions of the grid (which is smaller than the client rect). MainCRect is the client rect measurements of the window.
Depending on where I call GetClientRect(), the result of the RECT is always different. For example, right after I create the window, I call GetClientRect() and it returns an invalid size, because my grid is not centered properly.
When I call Get ClientRect() at WM_CREATE, it is even MORE off. The only time GetClientRect() works properly is if I call it in my WM_SIZING handler.
Can someone tell me why it is doing this? Also, how can I get the exact client rect *before* or exactly after the window is created (I want the grid to instantly be centered, so that the user does not see the process of it being centered)?
Thanks!