See this article first open the "Programming Windows programs to develop design guidelines" book ~, ISBN: 957-8239-73-4, author: Charles
The first section of Petzold Chapter 9 "Sub Window Control Item". A total of 10 kinds of button categories, namely: BS_PUSHBUTTON BS_DEFPUSHBUTTON BS_CHECKBOX BS_AUTOCHECKBOX BS_RADIOBUTTON BS_3STATE BS_AUTO3STATE BS_GROUPBOX BS_AUTORADIOBUTTON BS_OWNERDRAW I have seen in this study at the chapter button to create BS_OWNERDRAW style, the book has a program code, which has a has a structure,
LPDrawItemStruct, there is no clear given, I don't know if there is any giving me, I haven't seen MSDN as followstruct {; // dispert; ctltype; // control type uint; ctlid;; // control ID uint; itemid; // // inside the ID number UINT; itemAction; // Draw control uint; itemState; // Current mode hwnd; hwndItem; // Control mart HDC; HDC; // device Handle Rect; rcitem; // control range dword itemdata; // data} DrawItemstruct; see MSDN, check DrawItemstruct ~
The key code of this program is the WM_DRAWITEM message, when pressed the button, they generate WM_COMMAND messages, then
When will the WM_DRAWITEM message happen? As long as the system needs to redraw this control, you will send this message, such as switching windows, vegetables
Single pull, etc. There is also a position of coordinates ~
"LPARAM message parameters are indicators for the type DrawItemstruct structure during processing WM_DRAWITEM message processing."
"FillRect erases the inside of the button with a white painting brush, calling FrameRect to draw a black box around the button, so that OWNDRAW started
The WM_DRAWITEM processing process. "FillRect and Framerect are two APIs, respectively,
If is the focus on the button, "Call DrawFocusRect, draw a dashed rectangle in the boundary of the button."
I feel that when using the OwnerDraw style button, DrawItemStruct this structure must be deeply understood ~