说是方法,最多算是小技巧
typedef struct tagINITCOMMONCONTROLSEX {
DWORD dwSize; // size of this structure
DWORD dwICC; // flags indicating which classes to be initialized
} INITCOMMONCONTROLSEX, *LPINITCOMMONCONTROLSEX;
#define ICC_LISTVIEW_CLASSES 0x00000001 // listview, header
#define ICC_TREEVIEW_CLASSES 0x00000002 // treeview, tooltips
#define ICC_BAR_CLASSES 0x00000004 // toolbar, statusbar, trackbar, tooltips
#define ICC_TAB_CLASSES 0x00000008 // tab, tooltips
#define ICC_UPDOWN_CLASS 0x00000010 // updown
#define ICC_PROGRESS_CLASS 0x00000020 // progress
#define ICC_HOTKEY_CLASS 0x00000040 // hotkey
#define ICC_ANIMATE_CLASS 0x00000080 // animate
#define ICC_WIN95_CLASSES 0x000000FF
以上是MFC初始化时,获得本工程包含哪些类型控件的数据结构。每1bit代表一个类型,这样有32个类型的时候轻松用个int就管理了。需要知道哪个类型被设置,直接用按位与操作就可以了。算是用空间换时间的方法。这个方法看起来简单,但是运用场景还覆盖了排序,《编程珠玑》第一章就说的是这么个方法。
可见小技巧往往有大运用。要深刻理解技巧的思想。