Board index » cppbuilder » TPageControl & OnChange problems

TPageControl & OnChange problems


2005-06-27 05:56:36 AM
cppbuilder67
Hi all, having a bit of a problem with a TPageControl. Basically I have a
PageControl with 8 tabsheets on it and an OnChange event coded, for the
PageControl, that make some display alterations depending on which tab is
active. When the form is first created I set the ActivePage to the first
tabsheet (which it isn't at design time) using the code
pgcWizard->ActivePage = tbsIntro; where tbsIntro is the first tabsheet.
However the OnChange event doesn't seem to fire, the first page is displayed
but the OnChange code isn't executed. I've tried placing the code in the
FormShow but still no joy. Once displayed, if I click on the various tabs
the code gets executed but not is I set the ActivePage myself
Any ideas?
 
 

Re:TPageControl & OnChange problems

Mike Collins wrote:
Quote
When the form is first created I set the ActivePage to the first
tabsheet (which it isn't at design time) using the code
pgcWizard->ActivePage = tbsIntro; where tbsIntro is the first tabsheet.
Any reason you can't make tbsIntro the active page at design time?
Quote
However the OnChange event doesn't seem to fire, the first page is displayed
but the OnChange code isn't executed.
I think that some events aren't necessarily triggered when you might
expect them to be -- eg, programmatic vs. user actions don't always
result in the same events being triggered.
Quote
Once displayed, if I click on the various tabs
the code gets executed but not is I set the ActivePage myself

If you can set tbsIntro at design time, you should be OK. I'm assuming
that if you switch to another tab (triggering OnChange) and then switch
back to tbsIntro, you get the OnChange as you should.
-- S.
 

Re:TPageControl & OnChange problems

Mike,
Try forcing the OnChange event with a direct call in
FormShow or another more suitable location like so:
PageControl1Change(NULL);
Kent
 

{smallsort}

Re:TPageControl & OnChange problems

Yeh, thats how I'm doing it at present, but it seems like a bit of a hack.
Obviously I could set the tabsheet at design time, but it doesn't follow
with my design (I'm basically creating a wizard so you never see the tabs
anyway). Would be helpful if the help files provided a bit more
information, like this event is only fired in responce to a user clicking on
a tab, and will not be fired if the tabsheet is activated programmablly :-)
"Kent" < XXXX@XXXXX.COM >wrote in message
Quote
Mike,

Try forcing the OnChange event with a direct call in
FormShow or another more suitable location like so:

PageControl1Change(NULL);

Kent