下面是获取窗口的位置:
BOOL CMainFrame:reCreateWindow(CREATESTRUCT& cs)
{
//
// Restore main window position
//
CWinApp* app = AfxGetApp();
int s, t, b, r, l;
// only restore if there is a previously saved position
if ( -1 != (s = app->GetProfileInt("Frame", "Status", -1)) &&
-1 != (t = app->GetProfileInt("Frame", "Top", -1)) &&
-1 != (l = app->GetProfileInt("Frame", "Left", -1)) &&
-1 != (b = app->GetProfileInt("Frame", "Bottom", -1)) &&
-1 != (r = app->GetProfileInt("Frame", "Right", -1))
) {
// restore the window's status
app->m_nCmdShow = s;
// restore the window's width and height
cs.cx = r - l;
cs.cy = b - t;
// the following correction is needed when the taskbar is
// at the left or top and it is not "auto-hidden"
RECT workArea;
SystemParametersInfo(SPI_GETWORKAREA, 0, &workArea, 0);
l += workArea.left;
t += workArea.top;
// make sure the window is not completely out of sight
int max_x = GetSystemMetrics(SM_CXSCREEN) -
GetSystemMetrics(SM_CXICON);
int max_y = GetSystemMetrics(SM_CYSCREEN) -
GetSystemMetrics(SM_CYICON);
cs.x = min(l, max_x);
cs.y = min(t, max_y);
}
return CFrameWnd:reCreateWindow(cs);
}