已阅读5页,还剩21页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
2020 3 6 1 案例2 可扩展的对话框 2020 3 6 2 需求与目标 这个功能类似QQ的显示聊天记录当用户要显示一些过多的选择时 对话框自动扩展其大小 将隐藏的部分显示出来 2020 3 6 3 效果 2020 3 6 4 效果 2020 3 6 5 手段 利用CDialog类的SetRect函数来设定对话框的大小 2020 3 6 6 手段 利用CDialog类的SetRect函数来设定对话框的大小调用MoveWindow函数来实现改变对话框的大小 2020 3 6 7 编程步骤 1 使用AppWizard创建一个基于对话框的应用程序 2020 3 6 8 编程步骤 2 为对话框添加一些控件 2020 3 6 9 编程步骤 2 2020 3 6 10 编程步骤 2 2020 3 6 11 编程步骤 3 为对话框添加3个成员变量 BOOLm bExpand 记录是否已经扩展对话框UINTm nExpandedHeight 扩展后对话框的高度UINTm nNormalHeight 扩展前对话框的高度 2020 3 6 12 BOOL typedefintBOOL typedeflongBOOL ABooleanvalue 2020 3 6 13 UINT typedefunsignedintUINT A16 bitunsignedintegeronWindowsversions3 0and3 1 a32 bitunsignedintegeronWin32 2020 3 6 14 编程步骤 4 在对话框的OnInitDialog函数中加入以下代码 m bExpand FALSE CRectrcDlg 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 nNormalHeight MoveWindow rcDlg TRUE 2020 3 6 15 CWnd GetWindowRect voidGetWindowRect LPRECTlpRect const lpRectPointstoaCRectobjectoraRECTstructurethatwillreceivethescreencoordinatesoftheupper leftandlower rightcorners RemarksCopiesthedimensionsoftheboundingrectangleoftheCWndobjecttothestructurepointedtobylpRect Thedimensionsaregiveninscreencoordinatesrelativetotheupper leftcornerofthedisplayscreen Thedimensionsofthecaption border andscrollbars ifpresent areincluded 2020 3 6 16 RECT LPRECT typedefstructtagRECT LONGleft LONGtop LONGright LONGbottom RECT PRECT NEAR NPRECT FAR LPRECT 2020 3 6 17 CRect classCRect publictagRECT public retrievesthewidthintWidth const returnstheheightintHeight const 2020 3 6 18 CWnd GetDlgItem CWnd GetDlgItem intnID const nIDSpecifiestheidentifierofthecontrolorchildwindowtoberetrieved ReturnValueApointertothegivencontrolorchildwindow IfnocontrolwiththeintegerIDgivenbythenIDparameterexists thevalueisNULL Thereturnedpointermaybetemporaryandshouldnotbestoredforlateruse RemarksRetrievesapointertothespecifiedcontrolorchildwindowinadialogboxorotherwindow ThepointerreturnedisusuallycasttothetypeofcontrolidentifiedbynID 2020 3 6 19 控件ID resource h defineIDC BORDER1000 defineIDC EXPAND1001 2020 3 6 20 CRect SetRect voidSetRect intx1 inty1 intx2 inty2 x1Specifiesthex coordinateoftheupper leftcorner y1Specifiesthey coordinateoftheupper leftcorner x2Specifiesthex coordinateofthelower rightcorner y2Specifiesthey coordinateofthelower rightcorner RemarksSetsthedimensionsofCRecttothespecifiedcoordinates 2020 3 6 21 CWnd MoveWindow voidMoveWindow LPCRECTlpRect BOOLbRepaint TRUE lpRectTheCRectobjectorRECTstructurethatspecifiesthenewsizeandposition bRepaintSpecifieswhetherCWndistoberepainted RemarksChangesthepositionanddimensions Foratop levelCWndobject thexandyparametersarerelativetotheupper leftcornerofthescreen ForachildCWndobject theyarerelativetotheupper leftcorneroftheparentwindow sclientarea 2020 3 6 22 编程步骤 5 为 隐藏 按钮添加单击响应函数OnExpand 2020 3 6 23 编程步骤 5 为 隐藏 按钮添加单击响应函数OnExpand voidCExpandDlgDlg OnExpand m bExpand m bExpand CRectrcDlg GetWindowRect rcDlg 2020 3 6 24 编程步骤 5 if m bExpand rcDlg SetRect rcDlg left rcDlg top rcDlg left rcDlg Width rcDlg top m nExpandedHeight m expand SetWindowText 隐藏 else rcDlg SetRect rcDlg left rcDlg top rcDlg left rcDlg Width rcDlg top m nNormalHeight m expand SetWindowText 显示 MoveWindow rcDlg TRUE 2020 3 6 25 CWnd SetWindowText voidSetWindowText LPCTSTRlpszString lpszStringPointstoaCStringobjectornull terminatedstringtobeusedasthenewtitleorcontroltext Remarks
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 四川省宜宾市兴文县香山中学八年级信息技术下学期 第九课电子商务与网上购物 教案
- 一年级道德与法治下册 14 今天我值日教案 鄂教版
- 河南省濮阳市范县白衣阁第二中学九年级信息技术 5.5.1《计算机网络》教学设计
- vbnet模拟试题7及答案
- 八年级语文浙教版衔接阶段第三单元同步测试卷基础版A卷
- 银行的述职报告个格式(4篇)
- 普通员工述职报告2025年(30篇)
- 高压电容器交接试验方案
- 美丽幸福河湖评价标准
- 政务数字化服务平台建设方案
- 2026-2027学年江苏省常州市度七年级数学上学期期中考试试题(含答案)
- 2026年中小学班主任班级管理培训课件
- 2026贵州省农业发展集团有限责任公司管培生招录91人考试备考试题及答案详解
- 2026年烟花爆竹生产单位主要负责人考试练习题
- 安全教育-2026年秋季学期1530安全教育记录表
- 苏州工业园区唯亭街道2026年社工招聘考试【结构化面试题库+高分答题模板】(含考官评分要点)
- 工程施工过程管理方案
- 2026年驾照补考科目一考试题库及答案
- 2026-2030中国他汀类行业市场发展趋势与前景展望战略研究报告
- 2026新教材人教PEP版五年级上册英语Unit 1 Different friends 教案
- 英语老师:最常用2000个英语单词附音标
评论
0/150
提交评论