In the recent project, you need to implement a similar QQ game Hall navigation tree control. Referring to some of the information on the network, the do-it-yourself produced a class CTREECTRLBT. The interface is as follows:
Implementation steps
Step one: Create a new MFC project based on the dialog box, and drag a standard tree control over the interface. Add a new class CTREECTRLBT derived from CTreeCtrl.
Step Two: Add some message responses and virtual functions to the class. Its detailed role is as follows:
void Presubclasswindow (); To add information about the initialization control
Processing of wm_size//control areas when changes occur
WM_PAINT//Drawing controls
Wm_mousemove//main Gets the cell item where the mouse is located
Step three: TreeCtrlBT.h first declares a structure to hold information about the cell items and puts the information of all items into a map. The implementation code is as follows:typedef struct tagItemMsg
{
HTREEITEM hItem; //项的句柄
CBitmap ItemBitmap; //项的位图
COLORREF crTransparent; //透明颜色
tagItemMsg()
{
hItem = NULL;
crTransparent = RGB(255,255,255);
}
~tagItemMsg()
{
if ( ItemBitmap.GetSafeHandle() )
{
ItemBitmap.DeleteObject();
}
}
}ITEM_MSG;
typedef map<HTREEITEM,ITEM_MSG*> ITEMMSG_MAP;