当前位置:网站首页>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
边栏推荐
- Leetcode the smallest number of the rotation array of the offer of the sword (11)
- 【Transform】【NLP】首次提出Transformer,Google Brain团队2017年论文《Attention is all you need》
- 函数栈帧的创建和销毁
- Chapter 04_ Logical architecture
- Jvm-02-class loading subsystem
- Visual upper system design and development (Halcon WinForm) -5 camera
- redis单线程问题强制梳理门外汉扫盲
- App global exception capture
- Neon global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
- 视觉上位系统设计开发(halcon-winform)-1.流程节点设计
猜你喜欢
[transform] [NLP] first proposed transformer. The 2017 paper "attention is all you need" by Google brain team
Visual upper system design and development (Halcon WinForm) -5 camera
什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe
mysql innodb 存储引擎的特性—行锁剖析
Jvm-08-garbage collector
The markdown file obtains the pictures of the network and stores them locally and modifies the URL
百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式
Finally, someone explained the financial risk management clearly
【云原生训练营】模块七 Kubernetes 控制平面组件:调度器与控制器
随机推荐
什么是embedding(把物体编码为一个低维稠密向量),pytorch中nn.Embedding原理及使用
Jvm-05-object, direct memory, string constant pool
Visual upper system design and development (Halcon WinForm) -1 Process node design
Global and Chinese markets for ionization equipment 2022-2028: Research Report on technology, participants, trends, market size and share
求字符串函数和长度不受限制的字符串函数的详解
[pytorch learning notes] transforms
Enable multi-threaded download of chrome and edge browsers
Using multipleoutputs to output multiple files in MapReduce
Global and Chinese market of Bus HVAC systems 2022-2028: Research Report on technology, participants, trends, market size and share
Relationship between truncated random distribution and original distribution
el-switch 赋值后状态不变化
Use of Tex editor
Atlas atlas torque gun USB communication tutorial based on mtcom
Concurrency-02-visibility, atomicity, orderliness, volatile, CAS, atomic class, unsafe
What is label encoding? How to distinguish and use one hot encoding and label encoding?
Center and drag linked global and Chinese markets 2022-2028: Research Report on technology, participants, trends, market size and share
Visual upper system design and development (Halcon WinForm) -2 Global variable design
Leasing cases of the implementation of the new regulations on the rental of jointly owned houses in Beijing
XWiki Installation Tips
Apache ant extension tutorial