Like the QQ Game Hall navigation tree control

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.