Solved

Subclassing a header control to CListCtrl

Posted on 2002-06-13
4
470 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
[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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

719 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