posts - 311, comments - 0, trackbacks - 0, articles - 0
  C++博客 :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

(地基工)窗口按比例变化

Posted on 2011-09-27 15:14 点点滴滴 阅读(108) 评论(0)  编辑 收藏 引用 所属分类: 02 编程语言
取得最大最小宽度高度
    void InteralMFCWnd::OnGetMinMaxInfo(MINMAXINFO* lpMMI)
    {
        
// TODO: 在此添加消息处理程序代码和/或调用默认值
        if(lpMMI->ptMinTrackSize.x < (LONG)(mMinHeight * m_RectRate) || lpMMI->ptMinTrackSize.y < mMinHeight )
        {
            lpMMI
->ptMinTrackSize.x  = (LONG)(mMinHeight * m_RectRate);
            lpMMI
->ptMinTrackSize.y  = mMinHeight;
        }        
    }
窗口大小调整

    
void InteralMFCWnd::OnSizing(UINT fwSide, LPRECT pRect)
    {
        CWnd::OnSizing(fwSide, pRect);
        
if(pRect)
        {
            
int nWidth  = pRect->right - pRect->left;
            
int nHeight = pRect->bottom - pRect->top;
        
            
if(m_RectWidnow.width() != nWidth) // 宽度改变
            {
                pRect
->bottom = (LONG)(pRect->top + nWidth / m_RectRate);
            }
            
else if(m_RectWidnow.height() != nHeight) // 高度改变
            { 
                pRect
->right = (LONG)(pRect->left + nHeight * m_RectRate);
            }

            m_RectWidnow.left 
= pRect->left;
            m_RectWidnow.right 
= pRect->right;
            m_RectWidnow.top  
= pRect->top;
            m_RectWidnow.bottom 
= pRect->bottom;            
        }
    }