Custom message

xiaoxiao2021-03-06  23

Still look at the code directly! !

I saw a definition message a few days ago, watching the words on the book, I still don't understand for a long time!

Still grateful to netizens "Go back to the world" to help! I have solved my problem last time. !

Still look at how to define custom messages on the MSDN.

THE WM_USER Constant Is Used by Applications To Help Define Private Messages for Use by Private WINDOW CLASSES, U SUALLY OF THE FORM WM_USER X, WHERE X IS ANTEGER VALUE.

It is roughly that constant WM_USER is defined by the application from defined messages, usually defined with WM_USER X.

grammar

#define wm_user 0x0400

/

WM_USER THROUGH 0x7FFF //

Integer Messages for Use by private window classes. //

/

Then look at the specific description of MSDN:

Message numbers in the second range (WM_USER through 0x7FFF) can be defined and used by an application to send messages within a private window class. These values ​​can not be used to define messages that are meaningful throughout an application, because some predefined window classes already define values ​​in this range. For example, predefined control classes such as BUTTON, EDIT, LISTBOX, and COMBOBOX may use these values. messages in this range should not be sent to other applications unless the applications have been designed to exchange messages and to attach the Same meaning to the message Numbers. You can define custom messages between WM_USER to 0x7FFF, but cannot be used to define Meaningful (here the meaningful should be button, control, edit a number of messages The message, as well as messages within this range cannot be sent to other applications that do not define the message. Or watch the netizen "back to the world" to help me change the program! Some implementation details I ignored, there is a specific code in the article written in the last time! #include #include "resource.h" #define WM_CHANGECOLOR WM_USER 100 // global variable HINSTANCE hinst; COLORREF tmpcolor; BOOL // declare function CALLBACK DialogFun (HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain (HINSTANCE, HINSTANCE, LPSTR, int); InitApplication (HINSTANCE); InitInstance (HINSTANCE, int); LRESULT CALLBACK MainWndProc (HWND, UINT, WPARAM, LPARAM); BOOL PaintWindows (HWND, int); // paint defined window function // Application entry point function int WinApi WinMain (Hinstance Hinstance, Hinstance Hinstance, LPSTR LPCMDLINE, INT NCMDSHOW) {........................ .....} // Application Initialization Bool InitApplication (Hinstance Hinstance) {..............................} // Create and display window Bool InitInstance (Hinstance Hinstance, Int ncmdshow) {................................. Lresult Callback MainwndProc (HWND HWND, UINT UMSG, WPARAM WPARAM, LPARAM LPARAM) {PAINTSTRUCT PS; HDC HDC; RECT

转载请注明原文地址:https://www.9cbs.com/read-40077.html

New Post(0)