BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

detect adding column and repaint header

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
--== Alain ==--
Guest





PostPosted: Tue Sep 26, 2006 12:38 am    Post subject: detect adding column and repaint header Reply with quote



Hi,

i'm still working on my component and i would like to repaint the header.

i was thinking to trap a message for that purpose. However, i do not
know this message. Could you tell me which message is sent when a new
column is added ?

thanks a lot,

Alain
Back to top
JD
Guest





PostPosted: Tue Sep 26, 2006 4:10 am    Post subject: Re: detect adding column and repaint header Reply with quote



--== Alain ==-- <nospam (AT) noemail (DOT) com> wrote:
Quote:

i'm still working on my component and i would like to
repaint the header.

I presume that you're talking about a TListView descendent.
If that's that case, then you need to understand that a
TListView is just a wrapper arounf MicroSoft's ListView
control which actually consist of 2 controls. The Header
is a seperate window and while some messages (WM_NOTIFY)
can be intercepted in the ListViews WndProc, you'll need to
subclass the Header's WndProc to catch the others.

//-------------------------------------------------------------
#ifdef STRICT
#define HEADERWNDPROC WNDPROC
#else
#define HEADERWNDPROC FARPROC
#endif
//-------------------------------------------------------------
class TGradientListView : public TListView
{
typedef TListView inherited;
protected:
private:
HWND hHeader;
LONG HeaderWndProcPtr;
HEADERWNDPROC OldHeaderWndProc;
void __fastcall SubclassHeaderWndProc();
void __fastcall HeaderWndProc( TMessage &Message );
MESSAGE void __fastcall CMRecreateWnd( TMessage &Message );
public:
BEGIN_MESSAGE_MAP
VCL_MESSAGE_HANDLER( CM_RECREATEWND, TMessage, CMRecreateWnd )
END_MESSAGE_MAP( inherited )
__fastcall TGradientListView( TComponent* Owner );
__fastcall ~TGradientListView();
__published:
};
//-------------------------------------------------------------


//-------------------------------------------------------------
__fastcall TGradientListView::TGradientListView(TComponent* Owner) : TListView( Owner )
{
HeaderWndProcPtr = reinterpret_cast<LONG>( MakeObjectInstance(HeaderWndProc) );
SubclassHeaderWndProc();
}
//-------------------------------------------------------------
__fastcall TGradientListView::~TGradientListView()
{
if( hHeader ) ::SetWindowLong( hHeader, GWL_WNDPROC, reinterpret_cast<LONG>(OldHeaderWndProc) );
FreeObjectInstance( reinterpret_cast<void*>(HeaderWndProcPtr) );
}
//-------------------------------------------------------------
MESSAGE void __fastcall TGradientListView::CMRecreateWnd( TMessage &Message )
{
inherited::Dispatch( &Message );
SubclassHeaderWndProc();
}
//-------------------------------------------------------------
void __fastcall TGradientListView::SubclassHeaderWndProc()
{
hHeader = ListView_GetHeader( Handle );
if( hHeader ) OldHeaderWndProc = reinterpret_cast<HEADERWNDPROC>( ::SetWindowLong(hHeader, GWL_WNDPROC, HeaderWndProcPtr) );
}
//-------------------------------------------------------------
void __fastcall TGradientListView::HeaderWndProc( TMessage &Message )
{
switch( Message.Msg )
{
case WM_DESTROY: Message.Result = ::CallWindowProc(OldHeaderWndProc, hHeader, Message.Msg, Message.WParam, Message.LParam );
::SetWindowLong( hHeader, GWL_WNDPROC, reinterpret_cast<LONG>(OldHeaderWndProc) );
hHeader = NULL;
return;
}
Message.Result = ::CallWindowProc( OldHeaderWndProc, hHeader, Message.Msg, Message.WParam, Message.LParam );
}
//-------------------------------------------------------------


Quote:
Could you tell me which message is sent when a new
column is added ?

You need to search MSN to see if there is a specific message
for that:

http://windowssdk.msdn.microsoft.com/en-us/library/ms670560.aspx

However, adding a column is only done programatically so you
should know when that's happening anyway.

~ JD
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.