본문 바로가기

Windows/MFC

윈도우 위치 고정 (Fix Position)

Window를 non-sizable, non-movable하게 만들려면 아래와 같이 code를 추가한다.
[code]
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
     ......
     //Remove positions of menu
     CMenu* pTopMenu = GetSystemMenu(FALSE);

     pTopMenu -> RemoveMenu(4,MF_BYPOSITION); //Maximize
     pTopMenu -> RemoveMenu(2,MF_BYPOSITION); //Size
     pTopMenu -> RemoveMenu(1,MF_BYPOSITION); //Move

     return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
     if( !CFrameWnd::PreCreateWindow(cs) )
         return FALSE;

     cs.style &= ~WS_THICKFRAME;

     //If you use buttons MAXIMIZE and MINIMIZE in the caption,
     // insert next string!!!!!!
     cs.style &= ~WS_MAXIMIZEBOX;

     return TRUE;
}
[/code]