Solved

CHeaderCtrl

Posted on 1998-03-11
2
862 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
Comment Utility
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
Comment Utility
hd.mask = HDI_TEXT | HDI_FORMAT;
hd.fmt = HDF_OWNERDRAW | HDF_STRING;
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now