WTL learning notes (1)

xiaoxiao2021-03-06  76

First, ATL's GUI class

1. The class related to the window and the window

ATL

The CWindow class defines the interface of the window, which packages most

HWND as the API function of the first parameter and will be directly

M_HWND as

Public members are available. In addition, it is overloaded

Operator hwnd, you can

The CWindow object is used directly as a window handle.

The implementation of the window in the ATL is

CWINDOWIMPL is done, including the registration of the window class, subclass of the window, message mapping, and a basic

Windowproc. In addition, the implementation of the dialog is

CDialogIMPL and

CAXDIALOGIMPL is done. The former is a normal dialog that the latter is used to include the ActiveX control dialog.

2. Define the implementation of the window

All non-dialog boxes that need to be created are inherited

CWINDOWIMPL, there is three things to do: 1. Define window classes; second, message mapping; three, the default style used by the window.

The definition of the window class is passed

Declare_wnd_class or

Declare_wnd_class_ex macro implementation, where the former's parameters are the window class name, the latter parameters are the window class name, style and background color. If used

NULL as the window name, the ATL will automatically generate a window class name. E.g:

Class CMYWINDOW: PUBLIC CWINDOWIMPL {public: declare_wnd_class (_t ("my window class")}; message mapping is passed

Begin_MSG_MAP and

End_msg_map macro is completed, as follows:

Class CMYWINDOW: PUBLIC CWINDOWIMPL {public: declare_wnd_class (_T ("My WINDOW CLASS")) Begin_MSG_MAP (CMYWINDOW) / / Complete the map content END_MSG_MAP ()}; window characteristics is not common, it passes

Cwintraits This class template is done.

3. Message mapping table

ATL uses three macro to implement message mapping, which is:

Command_id_handler (command ID, handler) - used to process

WM_COMMAND;

Notify_handler (Control ID, Notification Code, Processing Function) - Used to process

WM_NOTIFY;

Message_Handler (Message Name, Processing Function) - Used to process other messages.

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

New Post(0)