MFC扩展对话框(即收缩对话框)
效果图如下,扩展前(上)、扩展后(下)、上下扩展:
MFC收缩对话框
MFC收缩对话框
具体步骤如下:
1.在.h文件中添加如下代码:
2.在.cpp中添加如下代码:
10 | GetWindowRect(winRect); |
11 | m_winHeight = winRect.Height(); |
13 | GetDlgItem(IDC_BUTTON1)->GetWindowRect(btRect); |
14 | m_shrinkHeight = btRect.bottom+20; |
15 | winRect.SetRect(winRect.left,winRect.top,winRect.right,m_shrinkHeight); |
16 | MoveWindow(winRect,TRUE); |
21 | GetDlgItem(IDC_BUTTON1)->GetWindowRect(btRect); |
23 | GetWindowRect(&winRect); |
26 | winRect.SetRect(winRect.left,winRect.top,winRect.right,winRect.top + m_winHeight); |
27 | GetDlgItem(IDC_BUTTON1)->SetWindowText(_T( "关闭" )); |
31 | winRect.SetRect(winRect.left,winRect.top,winRect.right,winRect.top + m_shrinkHeight); |
32 | GetDlgItem(IDC_BUTTON1)->SetWindowText(_T( "设置" )); |
34 | MoveWindow(winRect,TRUE); |