WindowsAPI之按钮
来源:互联网 发布:python安卓版 编辑:程序博客网 时间:2024/06/16 12:06
WindowsAPI之按钮
定义一个按钮函数:
HWND CreateButton( const HWND hParent, //父窗口类 const HINSTANCE hInst, //应用程序实例 DWORD dwStyle, //窗口样式 constRECT& rc, //相对于父窗口的位置矩形 const int id, //按钮ID号 const string&caption) //按钮标题{ dwStyle |= WS_CHILD|WS_VISIBLE; return CreateWindowEx( 0, TEXT("BUTTON"), //类型为BUTTON,若是文本框为EDIT caption.c_str(), dwStyle, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, hParent, reinterpret_cast<HMENU>(static_cast<INT_PTR>(id)), hInst, NULL);}
调用按钮函数创建一个按钮,指定位置,ID号等,尤其是ID号比较重要:
#defineIDC_BUTTON_1 101 RECT editrc_1 = {120,30,220,100 };CreateButton(<span style="white-space:pre"></span>hParentWindow,<span style="white-space:pre"></span>(HINSTANCE) GetWindowLong (hParentWindow ,<span style="white-space:pre"></span>GWL_HINSTANCE),<span style="white-space:pre"></span>BS_DEFPUSHBUTTON,<span style="white-space:pre"></span>buttonrc,<span style="white-space:pre"></span>IDC_BUTTON_1, //注意<span style="white-space:pre"></span>string("按钮1"));
case WM_COMMAND: switch(wParam) { case IDC_BUTTON_1: //ID号要于上面创建按钮时保持一致 break; default: break; } break;
- WindowsAPI之按钮
- WindowsAPI自绘按钮
- windowsAPI之键盘输入
- WindowsAPI之SetWindowsHookEx()
- windowsAPI
- 小白学windowsAPI之编程范式
- WindowsAPI之GetFileVersionInfo函数和VerQueryValue函数
- WindowsAPI之RegOpenKey和RegSetValueEx函数
- windowsAPI之OpenProcessToken,AdjustTokenPrivileges 和LookupPrivilegeValue
- 解析SMBIOS信息之WindowsAPI和WMIC
- WindowsAPI WinMain
- WindowsAPI 文本框
- 学习WindowsAPI
- WindowsAPI 窗口
- windowsAPI函数
- C# WindowsAPI
- WindowsAPI 记事本
- windowsAPI断点
- Win32应用程序中创建控制台窗口
- sql2005 provider: SQL 网络接口, error: 26 - 定位指定的服务器/实例时出错
- android hw_get_module分析
- 不同EXE文件的调用
- csc.exe的环境变量设置
- WindowsAPI之按钮
- GetMessage和PeekMessage
- iphone Quickie: URL Encoding
- 简单创建DLL
- 分享一个小技巧
- C#中的Main方法
- Hello World
- png图像有哪几种属性?
- lo4j学习