案例2:可扩展的对话框.ppt
《案例2:可扩展的对话框.ppt》由会员分享,可在线阅读,更多相关《案例2:可扩展的对话框.ppt(26页珍藏版)》请在三一办公上搜索。
1、2023/9/11,成都信息工程学院 计算机学院,1,案例2:可扩展的对话框,2023/9/11,成都信息工程学院 计算机学院,2,需求与目标,这个功能类似QQ的显示聊天记录当用户要显示一些过多的选择时,对话框自动扩展其大小,将隐藏的部分显示出来,2023/9/11,成都信息工程学院 计算机学院,3,效果,2023/9/11,成都信息工程学院 计算机学院,4,效果,2023/9/11,成都信息工程学院 计算机学院,5,手段,利用CRect类的SetRect函数来设定对话框的大小,2023/9/11,成都信息工程学院 计算机学院,6,手段,利用CRect类的SetRect函数来设定对话框的大小调
2、用MoveWindow函数来实现改变对话框的大小,2023/9/11,成都信息工程学院 计算机学院,7,编程步骤(1),使用AppWizard创建一个基于对话框的应用程序,2023/9/11,成都信息工程学院 计算机学院,8,编程步骤(2),为对话框添加一些控件,2023/9/11,成都信息工程学院 计算机学院,9,编程步骤(2),2023/9/11,成都信息工程学院 计算机学院,10,编程步骤(2),2023/9/11,成都信息工程学院 计算机学院,11,编程步骤(3),为对话框添加3个成员变量:BOOL m_bExpand;/记录是否已经扩展对话框UINT m_nExpandedHeigh
3、t;/扩展后对话框的高度UINT m_nNormalHeight;/扩展前对话框的高度,2023/9/11,成都信息工程学院 计算机学院,12,BOOL,typedef int BOOL;typedef long BOOL;A Boolean value.,2023/9/11,成都信息工程学院 计算机学院,13,UINT,typedef unsigned int UINT;A 16-bit unsigned integer on Windows versions 3.0 and 3.1;a 32-bit unsigned integer on Win32.,2023/9/11,成都信息工程学院
4、 计算机学院,14,编程步骤(4),在对话框的OnInitDialog函数中加入以下代码:m_bExpand=FALSE;CRect rcDlg,rcMarker;GetWindowRect(rcDlg);m_nExpandedHeight=rcDlg.Height();GetDlgItem(IDC_BORDER)-GetWindowRect(rcMarker);m_nNormalHeight=(rcMarker.top-rcDlg.top);rcDlg.SetRect(rcDlg.left,rcDlg.top,rcDlg.left+rcDlg.Width(),rcDlg.top+m_nNor
5、malHeight);MoveWindow(rcDlg,TRUE);,2023/9/11,成都信息工程学院 计算机学院,15,CWnd:GetWindowRect,void GetWindowRect(LPRECT lpRect)const;lpRectPoints to a CRect object or a RECT structure that will receive the screen coordinates of the upper-left and lower-right corners.RemarksCopies the dimensions of the bounding
6、rectangle of the CWnd object to the structure pointed to by lpRect.The dimensions are given in screen coordinates relative to the upper-left corner of the display screen.The dimensions of the caption,border,and scroll bars,if present,are included.,2023/9/11,成都信息工程学院 计算机学院,16,RECT、LPRECT,typedef stru
7、ct tagRECT LONG left;LONG top;LONG right;LONG bottom;RECT,*PRECT,NEAR*NPRECT,FAR*LPRECT;,2023/9/11,成都信息工程学院 计算机学院,17,CRect,class CRect:public tagRECTpublic:/retrieves the widthint Width()const;/returns the heightint Height()const;,2023/9/11,成都信息工程学院 计算机学院,18,CWnd:GetDlgItem,CWnd*GetDlgItem(int nID)c
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 案例 扩展 对话框
![提示](https://www.31ppt.com/images/bang_tan.gif)
链接地址:https://www.31ppt.com/p-5991109.html