如何做一个窗口能够用鼠标拖放其大小,但到达某个大小时就不能用鼠标拖放其大小

解决方案 »

  1.   

    see this,can help you.
    http://www.vckbase.com/bbs/prime/viewprime.asp?id=289
    http://www.vckbase.com/bbs/prime/viewprime.asp?id=376
    http://www.codeproject.com/dialog/easysize.asp
      

  2.   

    以下代码使得窗口不小于300*250
    void CxxxWnd::OnSizing(UINT fwSide, LPRECT pRect) 
    {
    int minWidth = 300;
    int minHeight = 250;
    switch(fwSide)
    {
    case WMSZ_BOTTOM:
    {
    if(pRect->bottom - pRect->top < minHeight)
    {
    pRect->bottom = pRect->top + minHeight;
    }
    }
    break;
    case WMSZ_BOTTOMLEFT:
    {
    if(pRect->bottom - pRect->top < minHeight)
    {
    pRect->bottom = pRect->top + minHeight;
    } if(pRect->right - pRect->left < minWidth)
    {
    pRect->left = pRect->right - minWidth;
    }
    }
    break;
    case WMSZ_BOTTOMRIGHT:
    {
    if(pRect->bottom - pRect->top < minHeight)
    {
    pRect->bottom = pRect->top + minHeight;
    } if(pRect->right - pRect->left < minWidth)
    {
    pRect->right = pRect->left + minWidth;
    }
    }
    break; case WMSZ_TOP:
    {
    if(pRect->bottom - pRect->top < minHeight)
    {
    pRect->top = pRect->bottom - minHeight;
    }
    }
    break;
    case WMSZ_TOPLEFT:
    {
    if(pRect->bottom - pRect->top < minHeight)
    {
    pRect->top = pRect->bottom - minHeight;
    } if(pRect->right - pRect->left < minWidth)
    {
    pRect->left = pRect->right - minWidth;
    }
    }
    break;
    case WMSZ_TOPRIGHT:
    {
    if(pRect->bottom - pRect->top < minHeight)
    {
    pRect->top = pRect->bottom - minHeight;
    } if(pRect->right - pRect->left < minWidth)
    {
    pRect->right = pRect->left + minWidth;
    }
    }
    break; case WMSZ_LEFT:
    {
    if(pRect->right - pRect->left < minWidth)
    {
    pRect->left = pRect->right - minWidth;
    }
    }
    break;
    case WMSZ_RIGHT: 
    {
    if(pRect->right - pRect->left < minWidth)
    {
    pRect->right = pRect->left + minWidth;
    }
    }
    break;
    default:
    break;
    } CxxxParent::OnSizing(fwSide, pRect);

    // TODO: Add your message handler code here
    }
      

  3.   

    CWnd::OnGetMinMaxInfo  WM_GETMINMAXINFO
    The framework calls this member function whenever Windows needs to know the maximized position or dimensions, or the minimum or maximum tracking size.afx_msg void OnGetMinMaxInfo(
       MINMAXINFO* lpMMI 
    );
    Parameters
    lpMMI 
    Points to a MINMAXINFO structure that contains information about a window's maximized size and position and its minimum and maximum tracking size. For more about this structure, see the MINMAXINFO structure. 
    Res
    The maximized size is the size of the window when its borders are fully extended. The maximum tracking size of the window is the largest window size that can be achieved by using the borders to size the window. The minimum tracking size of the window is the smallest window size that can be achieved by using the borders to size the window. Windows fills in an array of points specifying default values for the various positions and dimensions. The application may change these values in OnGetMinMaxInfo.Note   This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.