当前位置:网站首页>ELS window settings, WM_ CREATE、WM_ PAINT
ELS window settings, WM_ CREATE、WM_ PAINT
2022-07-26 03:15:00 【joker_ 0030】
#include<Windows.h>
#include"resource.h"
LRESULT CALLBACK PELouSi(HWND hWnd, UINT oMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR ipCmdLine,int nCmdShow)
{
// Initialize window class .
WNDCLASSEX db;
HWND hWnd;
MSG msg;// Structural variable .
db.cbClsExtra = 0;
db.cbSize = sizeof(WNDCLASSEX);
db.cbWndExtra = 0;
db.hbrBackground = (HBRUSH)COLOR_BACKGROUND;// The background color .
// Return value : Handle of mouse .
// Parameters 1: If the system cursor is loaded ,NULL、 If you load a custom cursor , Fill in the real column handle ,hInstance; Parameters 2: System cursor , Fill in the defined macro directly 、 If you load a custom cursor , Just use MAKEINTRESOURCE(240) Load the corresponding resources ID.
//db.hCursor = LoadCursor(NULL,IDC_HAND);// Load the system defined cursor .
db.hCursor = LoadCursor(hInstance,MAKEINTRESOURCE (IDC_NODROP));// Customized cursor . Resource file -> add to -> resources ->Cursor->IDC_NODROP-> newly build .
// Return value : Handle to icon .
// Parameters 1: If the system cursor is loaded ,NULL、 If you load a custom cursor , Fill in the real column handle ,hInstance; Parameters 2: System cursor , Fill in the defined macro directly 、 If you load a custom cursor , Just use MAKEINTRESOURCE(240) Load the corresponding resources ID.
//db.hIcon = LoadIcon(NULL,IDI_ASTERISK);// Load the system defined cursor .
db.hIcon = LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));// Status bar icons .
//db.hIconSm = NULL;// The icon in the upper left corner is defined for this . If it is blank, it defaults to the status bar icon .
db.hIconSm = LoadIcon(NULL,IDI_HAND);
db.hInstance = hInstance;
db.lpfnWndProc = PELouSi;// Callback function name .
db.lpszClassName = "els";
db.lpszMenuName = NULL;
db.style = CS_HREDRAW | CS_VREDRAW;
if(0==RegisterClassEx(&db))
{
int a = GetLastError();
return 0;
}
// create a window .hWnd Window handle Failure to return NULL.
// Window style : Parameters 4; Window name : Parameters 3.
hWnd=CreateWindowEx(WS_EX_TOPMOST,"els","els square ",WS_OVERLAPPEDWINDOW,100,100,500,500,NULL,NULL,hInstance,NULL);
if (NULL == hWnd)// Window handle . Unique identification of the window .
{
return 0;
}
// Display window
ShowWindow(hWnd, nCmdShow);
// Message loop . queue .
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
// Callback function
// Return value :LRESULT,CALLBACK Calling convention .
// Parameters 1: Window handle ; Parameters 2: news ID.
LRESULT CALLBACK PELouSi(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)// LRESULT:long type ;UINT: Unsigned integer , News ID.
{
PAINTSTRUCT pt;// Defining structure .
HDC hDc;
// Close window message
switch (nMsg)
{
case WM_CREATE:// The first message received by the window information handler , It is also the first message processed by the callback function ( by WM_CREATE). This message is generated only once , It is generally used to initialize some data .
//GetLastError();// Optimize .
break;
// Is the second message processed by the callback function ( by WM_PAINT).
// When a part of the display area of the window changes to ( Invalid ), So much so that ( Update the screen ) when , The program will be notified by this message .
// The last member of the window structure CS_HREDRAW|CS_VREDRAW, The purpose is when the window size changes , produce WM_PAINT news .
// When windows overlap , When the overlap gradually appears .
case WM_PAINT:
//GetLastError();// Optimize .
hDc=BeginPaint(hWnd,&pt);//getDC, Identification of window operable area .
// Draw the contents of the window in between .
EndPaint();// end .
break;
case WM_DESTROY:
PostQuitMessage(0);// call PostQuitMessage(0) This function emits WM_QUIT news .// The point and fork system generates WM_CLOSE,WM_DESTROY,WM_QUIT.
break;
}// Manually handle the cross off message .
return DefWindowProc(hWnd, nMsg, wParam, lParam);
//LRESULT a=DefWindowProc(hWnd, oMsg, wParam, lParam);// function
//return a;
}
边栏推荐
- URDF 语法详解
- tf.truncated_normal()用法
- Summary of Huawei virtualization fusioncompute knowledge points
- How to reinstall win7 system?
- STM32——DMA笔记
- Swin Transformer【Backbone】
- Course notes of single chip microcomputer principle and interface technology for migrant workers majoring in electronic information engineering
- Is the galaxy VIP account opened by qiniu safe?
- Jsd-2204-cool shark Mall (Management Commodity module) -day02
- JVM memory model parsing
猜你喜欢

Win11麦克风权限的开启方法

STM32——PWM学习笔记

LeetCode·每日一题·剑指 Offer || 115.重建序列·拓扑排序

"Xiao Deng's view" the value brought by Siem to enterprises (II)

Managing databases in a hybrid cloud: eight key considerations

Course notes of single chip microcomputer principle and interface technology for migrant workers majoring in electronic information engineering

离线数据仓库从0到1-阶段一资源购买配置

Win11隐藏输入法状态栏方法

Chen Yili, China Academy of communications technology: cost reduction and efficiency increase are the greatest value of Enterprise Cloud native applications

Multithreaded programming
随机推荐
LeetCode·每日一题·剑指 Offer || 115.重建序列·拓扑排序
Matlab simulation of vertical handover between MTD SCDMA and TD LTE dual networks
LeetCode·
Remember SQL optimization once
Implement a method to find the sum of the number k and m in the array
Jsd-2204-cool shark Mall (Management Commodity module) -day02
使用anaconda配置gpu版本的tensorflow(30系列以下显卡)
LeetCode·83双周赛·6128.最好的扑克手牌·模拟
STM——EXTI外部中断学习笔记
堆内存与栈内存的区别?
复制列表时踩过的坑:浅拷贝与深拷贝
[Yuri crack man] brings you easy understanding - deep copy and shallow copy
称霸薪酬榜!什么行业大有“钱”途?
The difference between the world wide web, the Internet and the Internet
Managing databases in a hybrid cloud: eight key considerations
tf.truncated_normal()用法
What are the methods of array sorting in JS
78. 子集
Continuous delivery and Devops are good friends
Service gateway (zuul)