文档详情

第六章《Windows标准控件》.ppt

发布:2018-05-20约8.71千字共36页下载文档
文本预览下载声明
德州学院 计算机系 德州学院计算机系 Visual C++ 与面向对象程序设计 第6章 Windows标准控件 德州学院 计算机系 主讲教师 韩金姝 本章主要内容 控件概述 按钮控件 滚动条控件 静态控件(自学) 列表框子窗口控件 编辑框控件 控件概述 控件是Windows图形用户界面的主要组成部分之一。属于一般窗口,具有通用的窗口性质,且可使用ShowWindow和MoveWindow等窗口管理函数对其操作 创建控件的两种方式: 在对话框中制定控件。 调用CreateWindow/CreateWindowEx创建窗口类控件,和主窗口类似,填写WNDCLASS结构并注册。或使用Windows系统预定义的窗口类 控件概述 窗口间消息传递 作为子窗口的控件通过向其父窗口发送WM_COMMAN消息进行通信,wParam参数包含了子窗口的标志,低位是子窗口句柄,高位是通知代码(各种类型的操作表6-2) 应用程序调用,向特定子窗口发送消息 LRESULT SendMessage( HWND hWnd,UINT Msg, WPARAM wParam, LPARAM lParam); 对话框控件:SendDlgItemMessage( ) 控件概述 SendMessage An application sends a BM_SETSTYLE message to change the style of a button. lResult?=?SendMessage( ????//?returns?LRESULT?in?lResult ??? (HWND) hWndControl, ????// handle to destination control ???(UINT) BM_SETSTYLE,// message ID (WPARAM)?wParam, ????//?=?(WPARAM)?()?wParam;? ??(LPARAM)?lParam ????//?=?(LPARAM)?()?lParam; ); wParam :Specifies the new button style. This parameter can be a combination of button styles. For a table of button styles, see Button Styles. lParam :The low-order word of lParam specifies whether the button is to be redrawn. A value of TRUE redraws the button; a value of FALSE does not redraw the button. 控件概述 常用子窗口操作函数 应用程序对控件的操作,实质是子窗口操作的一种类型(P113) 获得指定窗口标题或文本:GetWindowText( )/GetDlgItemText( ) 设置窗口标题或文本:SetWindowText( )/SetDlgItemText( ) 激活或禁止窗口:EnableWindow( ) 关闭窗口:DestroyWindow( ) 控件概述 常用子窗口操作函数 5. 移动窗口或改变窗口大小:MoveWindow The MoveWindow function changes the position and dimensions of the specified window. For a top-level window, the position and dimensions are relative to the upper-left corner of the screen. For a child window, they are relative to the upper-left corner of the parent windows client area. bRepaint:[in] Specifies whether the window is to be repainted. If this parameter is TRUE, the window receives a message. If the parameter is FALSE, no repainting of any kind occurs. This applies to the client area, the nonclient area (incl
显示全部
相似文档