hwndForegroundWindow = GetForegroundWindow(); hwndTopWindow        = GetTopWindow(NULL); hwndWindow           = NULL; hwndParent           = GetParent(aDlg); while(hwndParent != NULL) { hwndWindow = hwndParent; hwndParent = GetParent(hwndWindow); }  if(hwndParent == aDlg) gSystemInfo.lastWindowIsTopWindow = TRUE; else if((hwndParent == NULL) && (hwndWindow == aDlg)) gSystemInfo.lastWindowIsTopWindow = TRUE; else if(hwndForegroundWindow == aDlg) gSystemInfo.lastWindowIsTopWindow = TRUE; else gSystemInfo.lastWindowIsTopWindow = FALSE;
void SaveWindowPosition(HWND aDlg){  RECT rectDlg;  if(GetWindowRect(aDlg, &rectDlg))  {    gSystemInfo.lastWindowPosCenterX = ((rectDlg.right - rectDlg.left) / 2) + rectDlg.left;    gSystemInfo.lastWindowPosCenterY = ((rectDlg.bottom - rectDlg.top) / 2) + rectDlg.top;  }}