I'm using WinAPI and trying to center the new create window position.
CODE
RECT rc;
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
GetWindowRect(hwnd, &rc);
SetWindowPos(hwnd, 0, (screenWidth - rc.right)/2,
(screenHeight - rc.bottom)/2, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
from the code above, it works because it puts the window at the center of the screen, but not until I keep execute my code repeatedly over and over, the window position starts to shift little by little until it reaches the edge of the screen then it comes back to put the window at the center of the screen. If I excute my code again, it will shift again... how can I prevent it from shifting after executing the code for the second, third or fourth time?
This post has been edited by skyHigh: 29 Oct, 2007 - 04:03 PM