 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
--== Alain ==-- Guest
|
Posted: Tue Sep 26, 2006 12:38 am Post subject: detect adding column and repaint header |
|
|
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
|
Posted: Tue Sep 26, 2006 4:10 am Post subject: Re: detect adding column and repaint header |
|
|
--== 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 |
|
 |
|
|
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
|
|