本人看了很多例程,发现CHeaderCrtl类一般在CListCtrl及CListView中使用,但我现在希望能在一个空的对话框上生成一个表头,不知有无办法?

解决方案 »

  1.   

    本人看了很多例程,发现CHeaderCrtl类一般在CListCtrl及CListView中使用,但我现在希望能在一个空的对话框上生成一个表头,不知有无办法?
    说明白些
      

  2.   

    add a member to your dialog class
    CHeaderCtrl m_HeaderCtrl;
    in the OnIntialDiglog() // TODO: Add extra initialization here
    RECT rc;
    rc.left = 10;
    rc.top = 10;
    rc.right = 320;
    rc.bottom = 40;
    m_HeaderCtrl.Create (HDS_BUTTONS, rc, this, 1234);
    HDITEM item;
    char textbuf[]="header in dlg";
    item.mask        = HDI_HEIGHT | HDI_TEXT | HDI_FORMAT;
    item.fmt         = HDF_STRING;
    item.cxy         = 175;
    item.pszText     = textbuf;
    item.cchTextMax  = sizeof(textbuf)+2;
    item.fmt         = HDF_LEFT;
    // LOGFONT lf;
    // ::ZeroMemory (&lf, sizeof (lf));
    // lf.lfHeight = 80;
    // lf.lfWeight = FW_BOLD;
    // lf.lfItalic = FALSE;
    // ::lstrcpy (lf.lfFaceName, _T ("MS Sans Serif"));
    // CFont* m_Font = new CFont();
    // VERIFY (m_Font -> CreatePointFontIndirect (&lf));
    // m_HeaderCtrl.SetFont (m_Font, TRUE);
    // delete m_Font;
    m_HeaderCtrl.InsertItem (0, &item);
    m_HeaderCtrl.ShowWindow (SW_SHOW);