Solved

CHeaderCtrl

Posted on 1998-03-11
2
887 Views
Last Modified: 2013-11-20
I would like to use a header in my CScrollView.  First, I derived a class from CHeaderCtrl, and
overrided the CHeaderCtrl::DrawItem.  Then I in my view class, I declared an object of
that derived class called "header:"  In my view's OnInitialUpdate, I make the following
calls:

int status = header.Create(HDS_HORZ | CCS_TOP | WS_VISIBLE, rect, CWnd::GetParent(), 1);
HD_ITEM hd;
hd.pszText = "Item #";
hd.cchTextMax = 7;
hd.mask = HDI_TEXT;
HD_ITEM *hd_ptr = &hd;
header.InsertItem(0, hd_ptr);
DRAWITEMSTRUCT ds;
ds.itemAction = ODA_DRAWENTIRE;
DRAWITEMSTRUCT *d_ptr = &ds;
header.DrawItem(d_ptr);

Yet, all I get in the view is a grey rectangle.  What do I need to put in my override of the
DrawItem function to make this work? If this is not the problem, then what is?

Thanks in Advance!!
0
Comment
Question by:mulshine
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 60 total points
ID: 1316918
CWnd::GetParent() returns the parent window of the view. You should use this. You also need to apply WS_CHILD style.

int status = header.Create(HDS_HORZ | CCS_TOP | WS_VISIBLE | WS_CHILD, rect, this, 1);

You should have the fmt member set to the HDF_OWNERDRAW value.
hd.fmt = HDF_OWNERDRAW;

And DrawItem() will be called by the framework. You should not call it. You just override it and do what you want to do.
0
 
LVL 23

Expert Comment

by:chensu
ID: 1316919
hd.mask = HDI_TEXT | HDI_FORMAT;
hd.fmt = HDF_OWNERDRAW | HDF_STRING;
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
In this post we will learn different types of Android Layout and some basics of an Android App.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question