Article ID: 133256
Article Last Modified on 11/21/2006
void CMainFrame::OnFreeze()
{
char* lpszFreeze = "F&reeze!";
char* lpszUnFreeze = "&UnFreeze!";
CMenu* pmenu = GetMenu();
if (!freezeState)
{
freezeState = TRUE;
pmenu->ModifyMenu(ID_FREEZE, MF_STRING, ID_FREEZE,
lpszUnFreeze);
DWORD style = ::GetWindowLong(this->m_hWnd, GWL_STYLE);
// Remove the thick frame style and the Minimize, Maximize buttons
style &= ~(WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_THICKFRAME);
::SetWindowLong(this->m_hWnd, GWL_STYLE, style);
}
else
{
freezeState = FALSE;
pmenu->ModifyMenu(ID_FREEZE, MF_STRING, ID_FREEZE,
lpszFreeze);
DWORD style = ::GetWindowLong(this->m_hWnd, GWL_STYLE);
// Add the thick frame style and the Minimize, Maximize buttons
style |= (WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_THICKFRAME);
::SetWindowLong(this->m_hWnd, GWL_STYLE, style);
}
DrawMenuBar();
}
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
if (freezeState)
{
RECT rc;
GetWindowRect(&rc);
lpMMI->ptMaxSize.x = rc.right - rc.left;
lpMMI->ptMaxSize.y = rc.bottom - rc.top;
lpMMI->ptMaxPosition.x = rc.left;
lpMMI->ptMaxPosition.y = rc.top;
lpMMI->ptMinTrackSize.x = rc.right - rc.left;
lpMMI->ptMinTrackSize.y = rc.bottom - rc.top;
lpMMI->ptMaxTrackSize.x = rc.right - rc.left;
lpMMI->ptMaxTrackSize.y = rc.bottom - rc.top;
}
CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);
CMenu* pmenu = GetMenu();
if (nType == SIZE_MAXIMIZED)
pmenu->EnableMenuItem(ID_FREEZE, MF_DISABLED|MF_GRAYED);
else
pmenu->EnableMenuItem(ID_FREEZE, MF_ENABLED);
DrawMenuBar();
}
Additional query words: kbinf 1.50 2.00 2.10 2.20 2.50 2.51 2.52 3.00 3.0 3.10 3.1 3.20 3.2 4.00 4.10 4.20
Keywords: kbhowto kbuidesign kbwndw KB133256