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

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

canvas——绘制文本——饼图的修改

The difference between the world wide web, the Internet and the Internet

Managing databases in a hybrid cloud: eight key considerations

STM——EXTI外部中断学习笔记

LoRa和NB-IOT可用用在哪些地方

UE4 how to render statically? 5 steps to generate static rendering

Implement a method to find the sum of the number k and m in the array

Looking at the next step of BAIC bluevale through the 8billion fund-raising, product upgrading and building core capabilities are the key words

URDF 语法详解
随机推荐
LeetCode·每日一题·剑指 Offer || 115.重建序列·拓扑排序
Oxycon 2022 network capture frontier conference is about to open!
Service gateway (zuul)
实现一个方法,找出数组中的第k大和第m大的数字相加之和
[sql] case expression
[untitled]
js中数组排序的方法有哪些
C language layered understanding (C language function)
Unknown-Aware Object Detection:Learning What You Don’t Know from Videos in the Wild(CVPR 2022)
2022-07-21 第四小组 多态
Execution process behind shell commands
Implement a method to find the sum of the number k and m in the array
els 初始化窗口类
Opencv annotates the image (picture frame + writing)
STM——EXTI外部中断学习笔记
LeetCode·83双周赛·6128.最好的扑克手牌·模拟
Small test (I)
STM - exti external interrupt learning notes
QT笔记——Q_Q 和Q_D 学习
Win11更改磁盘驱动器号的方法