当前位置:网站首页>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边栏推荐
猜你喜欢

Visual upper system design and development (Halcon WinForm) -1 Process node design

Reentrantlock usage and source code analysis

C语言刷题~Leetcode与牛客网简单题

如何使用 @NotNull等注解校验 并全局异常处理

百度智能云助力石嘴山市升级“互联网+养老服务”智慧康养新模式
![[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University](/img/83/922efb4f88843f1b7feaccf2b515b9.jpg)
[Yu Yue education] scientific computing and MATLAB language reference materials of Central South University

Jvm-05-object, direct memory, string constant pool

Redis主从、哨兵、集群模式介绍

Kubernetes advanced training camp pod Foundation

什么是one-hot encoding?Pytorch中,将label变成one hot编码的两种方式
随机推荐
Dataframe returns the whole row according to the value
基础SQL教程
【pytorch学习笔记】Datasets and Dataloaders
The first character of leetcode sword offer that only appears once (12)
视觉上位系统设计开发(halcon-winform)
[cloud native training camp] module 7 kubernetes control plane component: scheduler and controller
Halcon与Winform学习第二节
Visual upper system design and development (Halcon WinForm) -2 Global variable design
Using notepad++ to build an arbitrary language development environment
"Seven weapons" in the "treasure chest" of machine learning: Zhou Zhihua leads the publication of the new book "machine learning theory guide"
Redis lock Optimization Practice issued by gaobingfa
Halcon与Winform学习第一节
Global and Chinese markets for sterile packaging 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets of AC electromechanical relays 2022-2028: Research Report on technology, participants, trends, market size and share
视觉上位系统设计开发(halcon-winform)-5.相机
Summary of JVM knowledge points
Kubernetes 进阶训练营 Pod基础
What is embedding (encoding an object into a low dimensional dense vector), NN in pytorch Principle and application of embedding
Stress test WebService with JMeter
Reentrantlock usage and source code analysis