This article is going to introduce two things: one is a very useful cdialogresize template class in WTL, allowing you to drag the dialog box to resize (including the control automatically adapts to the dialog box), and the other is a subclass of button buttons that produce a three-dimensional font ( An example of this site is to use MFC to do the Cmytextbutton class, I transplanted it into the WTL, encapsulated into the Cfontbutton class, here first thanks to the author of this code, but can only display English fonts. With these examples, you can see that there is nothing mystical about WTL.
A Use of the Cdialogresize class
1. Add public cdialogresize<cderive> to the base class column inherited by the dialog box
In this case, add
public CDialogResize<CMainDlg>
2. Add macros
BEGIN_DLGRESIZE_MAP(CDialogResize<>)
DLGRESIZE_CONTROL(id, flags)
END_DLGRESIZE_MAP()
Specifies that the control needs this support, where the ID is the value of the control Id,flags as follows:
dlsz_size_x = 0x00000001,
Dlsz_size_y = 0x00000002,
dlsz_move_x = 0x00000004,
Dlsz_move_y = 0x00000008,
Dlsz_repaint = 0x00000010.
3. Add Dlgresize_init () in OnInitDialog (), OK
In the atlframe.h you can find the definition of dlgresize_init (), and some people used MFC to write similar code, if you are interested to compare.
Finally, do not forget to add the corresponding header file in the stdafx.h, see the source file specifically.
Two Implementation of Cfontbutton Class
1. Cownerdraw and Ccustomdraw
Both template classes support the custom drawing feature, and the difference between them is Ccustomdraw processing nm_customdraw, which generally supports header,
List view, rebar, toolbar, ToolTip, TrackBar, and tree view control redraw; Cownerdraw processing Wm_drawitem, Wm_measureitem, Wm_compareitem and WM _deleteitem these four messages, usually support button, combo box, list box, List View control, and menu items
's self painting.