Solved

CHeaderCtrl

Posted on 1998-03-11
2
881 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
  • 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

Technology Partners: 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

Title # Comments Views Activity
Doc'in system (example?) BA 7 120
lucky13 challenge 11 158
Dell Alienware Graphics Amplifier Driver for non-Alienware systems 18 465
Work with App store 7 91
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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