欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > PPT文档下载  

    案例2:可扩展的对话框.ppt

    • 资源ID:5991109       资源大小:172.54KB        全文页数:26页
    • 资源格式: PPT        下载积分:10金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要10金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    案例2:可扩展的对话框.ppt

    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函数来设定对话框的大小调用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_nExpandedHeight;/扩展后对话框的高度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,成都信息工程学院 计算机学院,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_nNormalHeight);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 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 struct 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)const;nIDSpecifies the identifier of the control or child window to be retrieved.Return ValueA pointer to the given control or child window.If no control with the integer ID given by the nID parameter exists,the value is NULL.The returned pointer may be temporary and should not be stored for later use.RemarksRetrieves a pointer to the specified control or child window in a dialog box or other window.The pointer returned is usually cast to the type of control identified by nID.,2023/9/11,成都信息工程学院 计算机学院,19,控件ID,resource.h#define IDC_BORDER 1000#define IDC_EXPAND 1001,2023/9/11,成都信息工程学院 计算机学院,20,CRect:SetRect,void SetRect(int x1,int y1,int x2,int y2);x1Specifies the x-coordinate of the upper-left corner.y1Specifies the y-coordinate of the upper-left corner.x2Specifies the x-coordinate of the lower-right corner.y2Specifies the y-coordinate of the lower-right corner.RemarksSets the dimensions of CRect to the specified coordinates.,2023/9/11,成都信息工程学院 计算机学院,21,CWnd:MoveWindow,void MoveWindow(LPCRECT lpRect,BOOL bRepaint=TRUE);lpRectThe CRect object or RECT structure that specifies the new size and position.bRepaintSpecifies whether CWnd is to be repainted.RemarksChanges the position and dimensions.For a top-level CWnd object,the x and y parameters are relative to the upper-left corner of the screen.For a child CWnd object,they are relative to the upper-left corner of the parent windows client area.,2023/9/11,成都信息工程学院 计算机学院,22,编程步骤(5),为“隐藏”按钮添加单击响应函数OnExpand:,2023/9/11,成都信息工程学院 计算机学院,23,编程步骤(5),为“隐藏”按钮添加单击响应函数OnExpand:void CExpandDlgDlg:OnExpand()m_bExpand=!m_bExpand;CRect rcDlg;GetWindowRect(rcDlg);,2023/9/11,成都信息工程学院 计算机学院,24,编程步骤(5),if(m_bExpand)rcDlg.SetRect(rcDlg.left,rcDlg.top,rcDlg.left+rcDlg.Width(),rcDlg.top+m_nExpandedHeight);m_expand.SetWindowText(隐藏);elsercDlg.SetRect(rcDlg.left,rcDlg.top,rcDlg.left+rcDlg.Width(),rcDlg.top+m_nNormalHeight);m_expand.SetWindowText(显示);MoveWindow(rcDlg,TRUE);,2023/9/11,成都信息工程学院 计算机学院,25,CWnd:SetWindowText,void SetWindowText(LPCTSTR lpszString);lpszStringPoints to a CString object or null-terminated string to be used as the new title or control text.RemarksSets the windows title to the specified text.If the window is a control,the text within the control is set.,2023/9/11,成都信息工程学院 计算机学院,26,LPCTSTR,A 32-bit pointer to a constant character string that is portable for Unicode and DBCS.,

    注意事项

    本文(案例2:可扩展的对话框.ppt)为本站会员(sccc)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开