steveb
Если у вас есть приложение MFC этот фрагмент сохраняет положение окна:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
//.....
LoadPlacement();
return 0;
}
void CMainFrame::OnClose()
{
SavePlacement();
CMDIFrameWnd::OnClose();
}
void CMainFrame::LoadPlacement()
{
LPBYTE pbtData = 0;
UINT nSize = 0;
WINDOWPLACEMENT wp;
if(!AfxGetApp()->GetProfileBinary(_T("MainWindow"), _T("Position"), &pbtData, &nSize))
return;
memcpy(&wp, pbtData, sizeof(WINDOWPLACEMENT));
if(wp.flags & WPF_RESTORETOMAXIMIZED)
wp.showCmd = SW_SHOWMAXIMIZED;
else
wp.showCmd = AfxGetApp ()->m_nCmdShow;
SetWindowPlacement(&wp);
delete [] pbtData;
}
void CMainFrame::SavePlacement()
{
WINDOWPLACEMENT wp;
if(!GetWindowPlacement(&wp))
return;
AfxGetApp()->WriteProfileBinary(_T("MainWindow"), _T("Position"),
reinterpret_cast<LPBYTE>((LPWINDOWPLACEMENT)&wp),
sizeof(WINDOWPLACEMENT));
}