Windows game programming master reading notes

1. Automatically display the identifier of the window: WS_VISIBLE. Without this identifier, the created window needs to be displayed manually with ShowWindow().

2. UpdateWindow() generates a WM_PAINT message.

3. The parameter hwnd in the message processing function WinProc() only works when multiple windows are created with the same window class. At this time, it indicates which window the message comes from.

4. WM_DESTROY is generated when the window is closed. This message does not terminate the application, but only closes the window. A WM_CLOSE message is generated before this.

5. After each message is processed, use return (0); to exit WinProc(), and notify the system that the message has been processed.

6. All parameters passed to WinProc() are contained in the MSG structure, which can be captured by GetMessage() or PeekMessage() in the message loop.

7. <windowsx.h> contains some useful macros and constants. The WIN32_LEAN_AND_MEAN macro prompts the system not to include MFC-related things.

8. When loading a string as a resource, the length of each line cannot exceed 255 characters (including the constant itself).

9. Except for the escape sequence "\n", which cannot be placed in the string form, other characters can be used, such as: %d, octal code sequence "\015", etc.

10. int LoadString() loads a string resource and returns the length of the loaded string.

11. The mouse position is relative to the client area, excluding borders and controls. The mouse passes the coordinates relative to the upper left corner (0,0); the mouse button code (starting with MK_) is processed in WM_MOUSEMOVE.

12. Functions that send messages by themselves:

LRESULT SendMessage(): Pass a message that requires immediate processing to the window, and the WinProc() function of the receiving window returns immediately after the receiving window processes the message, and the return value is the return value of WinProc();

BOOL PostMessage(): Insert a message into the message queue sequentially, and execute it when it is the turn of the message, that is to say, there is a delay in the processing of the message passed by the function. If you don’t care about this short delay, you can use this function The message is delivered, and at the same time, the function is not prone to message out-of-order.

 

......Continually updated......

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325043822&siteId=291194637