Hi all!,
i've generated a standard MFC application using the Wizzard under VC++6.0.
I want to save the WINDOWPLACEMENT when the window closes and load the data when it opens.
Code:
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::OnShowWindow(BOOL bShow, UINT nStatus)
{
CFrameWnd::OnShowWindow(bShow, nStatus);
if (bShow && !IsWindowVisible())
{
WINDOWPLACEMENT *wp;
UINT nByte;
if (AfxGetApp()->GetProfileBinary ("Window", "WP", (LPBYTE*)&wp, &nByte))
{
wp->length = sizeof(WINDOWPLACEMENT);
SetWindowPlacement(wp);
delete [] wp;
}
}
// TODO: Add your message handler code here
}
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
WINDOWPLACEMENT wp;
wp.length = sizeof(WINDOWPLACEMENT);
GetWindowPlacement(&wp);
AfxGetApp()->WriteProfileBinary ("Window", "WP", (BYTE *)&wp, sizeof(WINDOWPLACEMENT));
CFrameWnd::OnClose();
}
A Stack Overflow within the OnShowWindow appears when it gots started.
Please Help!
Regards,
Robert