Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Subclassing a header control to CListCtrl

Posted on 2002-06-13
4
Medium Priority
?
497 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 200 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

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

916 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