Forum > Beginners

[Solved!] TPageControl: OnChange event not firing

(1/3) > >>

Hi all,

I have a TPageControl that holds all the different screens of my program.  I need to show a logo when the user is on certain screens only, and hide it on others.  For some bizarre reason, the OnChange event does not fire when the page is changed via code - only when the user changes pages via switching tabs.

I even tried putting code in the MouseUp events for, firstly the PageControl and then the form itself.  The PageControl one worked, but again only if the user clicks on the tabs.  The form event did not seem to work at all.

Surely there must be a way for me to do this without having to add extra code to every button that changes pages?  I have a lot of those...

Btw the logo is not on the PageControl itself, it is in the bottom 20% of the screen where the PageControl does not extend.  This part of the screen contains various controls that only change minimally between pages.


Add nboDoChangeOnSetIndex to the PageControl.Options to fire OnChange when the pageindex is set by code (


I googled the heck out of this before I posted and seemingly no-one but you in the entire universe knows that option exists.  Did not realise it'd be that easy.  THANK YOU!!!!  :D

It's one of those cases where for sake of Delphi compatibility the LCL opts to to set a default which is inconvenient for most of us (and can break early LCL code), and unfortunately the way to change that default behaviour is not intuitive or obvious.

OK so now I've got another weird problem.  Here's the event code:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.MainScreenChange(Sender: TObject);begin  if MainScreen.ActivePage = MainHome then  begin  MainLogo.Visible:=true;  Blurb.Visible := false;  end  else  MainLogo.Visible:=false;  Blurb.Visible:=true;end;
When it shows the logo, it needs to hide a TLabel called 'Blurb' that normally occupies that same spot.  It successfully shows the logo but it doesn't hide the Blurb.  What the ???


[0] Message Index

[#] Next page

Go to full version