 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Aug 30, 2003 11:43 pm Post subject: Re: OnVisibleChange event |
|
|
"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 |
|
 |
|
|
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
|
|