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 

Re: OnVisibleChange event

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development)
View previous topic :: View next topic  
Author Message
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Aug 30, 2003 11:43 pm    Post subject: Re: OnVisibleChange event Reply with quote



"JD" <nospam (AT) nospam (DOT) com> wrote


Quote:
Can I subclass a TPanel to add an event for when
the Visible property changes? If so, could you also
please provide a sample?

When the Visible property is changed, it sends a CM_VISIBLECHANGED message
back to the component. You can subclass the WindowProc property in order to
intercept that message:

TWndMethod OldWndProc;

__fastcall TForm1::TForm1(TComponent *Owner)
: TForm(Owner)
{
OldWndProc = Panel1->WindowProc;
Panel1->WindowProc = PanelWndProc;
}

void __fastvall TForm1::PanelWndProc(TMessage &Message)
{
if( Message.Msg == CM_VISIBLECHANGED )
// do something
OldWndProc(Message);
}

The alternative is to derive a new component from TPanel and override the
inherited VisibleChanging() method instead:

class TMyPanel : public TPanel
{
protected:
DYNAMIC void __fastcall VisibleChanging();
public:
__fastcall TMyPanel(TComponent *Owner);
};

__fastcall TMyPanel::TMyPanel(TComponent *Owner)
: TPanel(Owner)
{
}

void __fastcall TMyPanel::VisibleChanging()
{
// do something
TPanel::VisibleChanging();
}


Gambit


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ([url]http://www.grisoft.com)[/url].
Version: 6.0.512 / Virus Database: 309 - Release Date: 8/19/03



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Development) 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.