Solved

Subclassing a header control to CListCtrl

Posted on 2002-06-13
4
431 Views
Last Modified: 2013-11-20
Hi,
I have a CListCtrl in which I want to replace its CHeaderCtrl to CMyHeaderCtrl. The CListCtrl is created at run-time using create method (not from the resources).
I tried the following code:
int CMyListCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
     if (CListCtrl::OnCreate(lpCreateStruct) == -1)
          return -1;
     
     m_MyHeader.SubclassDlgItem( 0, this);
     
     return 0;
}
This works fine if the CListCtrl is created with WS_VISIBLE style, but unfortunatelly I need it to be created not-visible, and if the WS_VISIBLE style is not set on the creation then the SubclassDlgItem does not succeeded.
I also checked in spy++ that the header-ctrl is not exist after CListCtrl::OnCreate exits.

Can someone please advise ??
thanks,
Yoav.

0
Comment
Question by:yoavo
  • 3
4 Comments
 
LVL 4

Expert Comment

by:mblat
ID: 7076162
Try to do it in PreSubclassWindow() of header control.

Hope it helps...
0
 
LVL 4

Expert Comment

by:mblat
ID: 7076195
Try to do it in PreSubclassWindow() of header control.

Hope it helps...
0
 
LVL 4

Expert Comment

by:mblat
ID: 7076211
Ok, that's not going to work :-(.

What you can do is this:

1. Derive CMyListCtrl from CListCtrl.
2. Derive CMyHeaderCtrl
3. Overwrite WM_PAINT ( or some other message like this)

 in
 CMyListCtrl
  ......
  CMyHEaderCtrl m_hdr;
  .......
 in there

 static bool bFirstTime = true;

  if(bFirstTime)
  {
    bFirstTime = false;
    m_hdr.SublassWindow(GetHeaderCtrl()->m_hWnd);  
   }



  Hope it helps....
 Typos are possible....
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 50 total points
ID: 7077376
Create the List Control with WS_VISBLE style, subclass it , and make it unvisible.

Only first paint comes, the object will draw. So I think , this will not make any difference that creating in invisible style.

GOOD LUCK
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
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.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

813 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

14 Experts available now in Live!

Get 1:1 Help Now