Solved

CHeaderCtrl

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

705 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