class CWindowPositionRestoreNSave { public: BOOL RestoreWindowPosition(CWnd * pWnd, const CString & sRegEntry) { CRect pos; pWnd->GetWindowRect(&pos); DutSetRegistryPath(sRegEntry); //Get the dims from the reg, assigning suitable defaults if not present. int iX = DutGetRegistryInt("Window", "X", 0); int iY = DutGetRegistryInt("Window", "Y", 0); int iW = DutGetRegistryInt("Window", "Width", pos.Width()); int iH = DutGetRegistryInt("Window", "Height", pos.Height()); return pWnd->SetWindowPos(&(pWnd->wndNoTopMost), iX, iY, iW, iH, SWP_SHOWWINDOW ); } void SaveWindowPosition(CWnd * pWnd, const CString & sRegEntry) { DutSetRegistryPath(sRegEntry); CRect rect; pWnd->GetWindowRect(&rect); DutWriteRegistryInt("Window","X",rect.left); DutWriteRegistryInt("Window","Y",rect.top); DutWriteRegistryInt("Window","Width",rect.Width()); DutWriteRegistryInt("Window","Height",rect.Height()); } };