也就是说使对话框窗口可调整大小,但要限制一个最小值,使窗口不能调整为700*500以下的大小。

解决方案 »

  1.   

    响应WM_SIZING   
      void   CMyDlg::OnSizing(UINT   fwSide,   LPRECT   pRect)     
      {   
        
      CDialog::OnSizing(fwSide,   pRect);   
      //   TODO:   Add   your   message   handler   code   here   
      CRect   rect(pRect);   
        
      int   width   =   rect.Width();   
      int   height   =   rect.Height();   
        
      switch(fwSide)   
      {   
      case   WMSZ_BOTTOM:   
      {   
      if   (height   <   MINDLG_HEIGHT)   
      pRect->bottom   =   pRect->top   +   MINDLG_HEIGHT;   
      break;   
      }   
      case   WMSZ_LEFT:   
      {   
      if   (width   <   MINDLG_WIDTH)   
      pRect->left   =   pRect->right   -   MINDLG_WIDTH;   
      break;   
      }   
      case   WMSZ_RIGHT:   
      {   
      if   (width   <   MINDLG_WIDTH)   
      pRect->right   =   pRect->left   +   MINDLG_WIDTH;   
      break;   
      }   
      case   WMSZ_TOP:   
      {   
      if   (height   <   MINDLG_HEIGHT)   
      pRect->top   =   pRect->bottom   -   MINDLG_HEIGHT;   
      break;   
      }   
      case   WMSZ_TOPLEFT:   
      {   
      if   (width   <   MINDLG_WIDTH)   
      pRect->left   =   pRect->right   -   MINDLG_WIDTH;   
      if   (height   <   MINDLG_HEIGHT)   
      pRect->top   =   pRect->bottom   -   MINDLG_HEIGHT;   
      break;   
      }   
      case   WMSZ_TOPRIGHT:   
      {   
      if   (width   <   MINDLG_WIDTH)   
      pRect->right   =   pRect->left   +   MINDLG_WIDTH;   
      if   (height   <   MINDLG_HEIGHT)   
      pRect->top   =   pRect->bottom   -   MINDLG_HEIGHT;   
      break;   
      }   
      case   WMSZ_BOTTOMLEFT:   
      {   
      if   (width   <   MINDLG_WIDTH)   
      pRect->left   =   pRect->right   -   MINDLG_WIDTH;   
      if   (height   <   MINDLG_HEIGHT)   
      pRect->bottom   =   pRect->top   +   MINDLG_HEIGHT;   
      break;   
      }   
      case   WMSZ_BOTTOMRIGHT:   
      {   
      if   (width   <   MINDLG_WIDTH)   
      pRect->right   =   pRect->left   +   MINDLG_WIDTH;   
      if   (height   <   MINDLG_HEIGHT)   
      pRect->bottom   =   pRect->top   +   MINDLG_HEIGHT;   
      break;   
      }   
      }   
        
      }
    classwizard里没有WM_SIZING这个消息啊。
      

  2.   

    终于找到了。
    重载 OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 消息    lpMMI->ptMinTrackSize.x = 400 ;
        lpMMI->ptMinTrackSize.y = 400 ;    lpMMI->ptMaxTrackSize.x = 500 ;
        lpMMI->ptMaxTrackSize.y = 500 ;    CDialog::OnGetMinMaxInfo(lpMMI);这样就可以限制最大和最小的尺寸了
    当然在VC的缺省的ClassWizard里不能处理这个消息,因为VC缺省认为
    Dialog是不改变大小的,你在进入ClassWizard后,先选择Class Info
    把Message Filter里的Dialog先该为Window,然后回到Message Maps里
    添加该消息,添加后,再回到Class Info,改回Dialog
    然后去编写代码了,记住,在资源的对话框的属性里里,
    把对话框设置为可改变大小的
      

  3.   

    void   CDrawTestDlg::OnSize(UINT   nType,   int   cx,   int   cy)     
      {   
      CDialog::OnSize(nType,   cx,   cy);   
        
      CWnd   *   pWnd   =   GetDlgItem(IDC_WORKSPACE);   
      if(   pWnd   )   
      {   
        CRect   rcTmp;   
        GetClientRect(&rcTmp);   
      pWnd->MoveWindow(&rcTmp);   
      }   
      }