当前位置:网站首页>win32创建窗口及按钮(轻量级)
win32创建窗口及按钮(轻量级)
2022-07-03 15:20:00 【宇龍_】
话不多说,都在注释里,上代码:
#include <Windows.h>
#include <stdio.h>
//按钮ID
#define IDC_BUTTON_CLICK 150
//按钮点击事件
void OnButtonClick()
{
::MessageBox(NULL, L"你好", L"呵呵呵", MB_OK);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT msgID, WPARAM wParam, LPARAM lParam)
{
switch (msgID)
{
case WM_CLOSE:
DestroyWindow(hWnd);
break;
case WM_CREATE:
//界面上创建一个按钮
CreateWindow(L"button",//必须为:button,这是一个按钮类名
L"点我",//按钮上显示的字符
WS_CHILD | WS_VISIBLE,
200, 200, 50, 30, //按钮在界面上出现的位置
hWnd, (HMENU)IDC_BUTTON_CLICK, //设置按钮的ID,随便设置一个数即可
((LPCREATESTRUCT)lParam)->hInstance, NULL);
break;
//销毁窗口
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_COMMAND:
if (wParam == IDC_BUTTON_CLICK)
{
//进入按钮点击事件
OnButtonClick();
}
break;
default:
DefWindowProc(hWnd, msgID, wParam, lParam);
}
return 1;
}
int __stdcall WinMain(HINSTANCE hIns
边栏推荐
- XWiki Installation Tips
- Global and Chinese market of trimethylamine 2022-2028: Research Report on technology, participants, trends, market size and share
- el-switch 赋值后状态不变化
- What is machine reading comprehension? What are the applications? Finally someone made it clear
- [probably the most complete in Chinese] pushgateway entry notes
- Characteristics of MySQL InnoDB storage engine -- Analysis of row lock
- Global and Chinese markets for sterile packaging 2022-2028: Research Report on technology, participants, trends, market size and share
- Enable multi-threaded download of chrome and edge browsers
- 基础SQL教程
- Finally, someone explained the financial risk management clearly
猜你喜欢
运维体系的构建
Basic SQL tutorial
Baidu AI Cloud helps Shizuishan upgrade the smart health care model of "Internet + elderly care services"
Visual upper system design and development (Halcon WinForm) -4 Communication management
Visual upper system design and development (Halcon WinForm) -3 Image control
Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing
Summary of JVM knowledge points
Kubernetes帶你從頭到尾捋一遍
Dataframe returns the whole row according to the value
The markdown file obtains the pictures of the network and stores them locally and modifies the URL
随机推荐
GCC cannot find the library file after specifying the link library path
The state does not change after the assignment of El switch
SQL server安装位置改不了
qt使用QZxing生成二维码
Halcon与Winform学习第二节
Search in the two-dimensional array of leetcode sword offer (10)
详解指针进阶1
High quality workplace human beings must use software to recommend, and you certainly don't know the last one
Puppet automatic operation and maintenance troubleshooting cases
Halcon and WinForm study section 1
Kubernetes帶你從頭到尾捋一遍
Tensorflow realizes verification code recognition (I)
【云原生训练营】模块八 Kubernetes 生命周期管理和服务发现
Introduction, use and principle of synchronized
Global and Chinese markets for flexible chips 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese market of trimethylamine 2022-2028: Research Report on technology, participants, trends, market size and share
什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team
MySQL reports an error: [error] mysqld: file '/ mysql-bin. 010228‘ not found (Errcode: 2 “No such file or directory“)
Popular understanding of gradient descent