SDI的MainFrame,如何在窗口最大化时禁止拖动窗口边框来改变窗口大小

解决方案 »

  1.   

    LONG style = ::GetWindowLong(this->m_hWnd,GWL_STYLE); style &= ~(WS_DLGFRAME | WS_THICKFRAME);
      SetWindowLong(this->m_hWnd,GWL_STYLE, style);
      this->ShowWindow(SW_SHOWMAXIMIZED);
      CRect rect;
      this->GetWindowRect(&rect);
      ::SetWindowPos(this->m_hWnd,HWND_NOTOPMOST,rect.left-1, rect.top-1, rect.right-rect.left + 3, rect.bottom-rect.top + 3, SWP_FRAMECHANGED);
      

  2.   

    多谢楼上
    style &= ~(WS_DLGFRAME | WS_THICKFRAME);
    是可以达到要求。但用了后就出现了新问题
    我是想最大化时无法拖动边框,但还原后可以拖动,
    我在还原响应里用了
    GetWindowLong(..style);
    style |= WS_DLGFRAME | WS_THICKFRAM;
    SetWindowLong(..style);
    发现style无法改回来,边框还是跟最大化一样没了
      

  3.   

    style |= WS_DLGFRAME | WS_THICKFRAME;
      SetWindowLong(this->m_hWnd, GWL_STYLE, style);
      this->ShowWindow(SW_NORMAL);
      

  4.   

    试过了,重设的Style没起作用,晕了
    这消息响应是放在CMainFrame下的一个dialogBar里,难道跟这个有关吗?
    可是为什么
    style &= ~(WS_DLGFRAME | WS_THICKFRAME);起作用了
    而 style |= WS_DLGFRAME | WS_THICKFRAME;不起作用呢?代码贴出来给看看:
    void CShapeDialogBar::OnShapeButtonCommand(CString sShapeName)
    {
             if(sShapeName==_T("MAXMIZE"))
    {
    CWnd* pParent=GetParent();//取得CMainFrame指针

    LONG nStyle=GetWindowLong(pParent->GetSafeHwnd(),GWL_STYLE);
    if(!m_bMWndMaxed) //BOOL m_bWndMaxed,指示窗口状态
    {
    pParent->GetWindowRect(&m_rcOriMainWnd);
    CRect rcWorkArea;
    SystemParametersInfo(SPI_GETWORKAREA,0,&rcWorkArea,0);
    pParent->MoveWindow(&rcWorkArea); nStyle &= ~( WS_DLGFRAME | WS_THICKFRAME );
    }
    else
    {
    pParent->MoveWindow(&m_rcOriMainWnd);
    pParent->CenterWindow(); nStyle |= WS_DLGFRAME | WS_THICKFRAME ;
    }
    SetWindowLong(pParent->GetSafeHwnd(),GWL_STYLE,nStyle); pParent->ShowWindow(SW_NORMAL); m_bMWndMaxed=!m_bMWndMaxed; }
    }