TpageControl Tab and Page display lazarus / 5-Lazarus Extra Components ---------------------------------------------------------------------- ksihota · 2008-06-29 23:11 I am having a problem with the TPageControl component. The proper page does not always display when the tab is selected.  I created a simple test to try and figure out when the problem was occurring. Create two forms. On form 1 create a button the displays form2. On form 2 place a TPageControl   component (I think the same problem exists with the  notebook component as well) Create 3 or 4 new pages. On each page place a label and set the caption to the page number.  You can also add some other components to make it easier to view the page you're on. Place a cancel button on Form 2. on the button click event of Form1 set the activepageindex of the pagecontrol to 0 before calling showmodal. Run the application. When you select each tab everything looks great. now select tab 3 and then select tab 2. Click the cancel button and then select the button to show the 2nd form again.  Select the 2nd tab.  It displays the 3rd tab's info (my label didn't show but other components did) if you select tab 1 and then tab 2 again you still see the 3rd pages info.  To see the 2nd page's info you need to first select the third tab again and then the 2nd tab If you add a 4th page and select it first, then both the 2nd and 3rd pages display page 4 until you select page 4 tab and then the proper pages show when you click on the corresponding tabs. It appears that the highest tab you select becomes the default page when you go back again.  The first page does not appear to be affected but this appears to be because of the setting for the activepageindex.  when this is removed the problem happens to page1 as well. Can someone tell me how to overcome this problem? Thanks for any help. KS Version: 0.9.24 beta date: 18/05/2008 SVN Revision: 12752 i386-win32-win32/win64 WinXP ---------------------------------------------------------------------- gerardus · 2008-07-02 15:08 Hi, There have been quite a few bug reports about TPageControl, and some are solved by now. Can you get the latest SVN and try? Regards, Gerard. ---------------------------------------------------------------------- ksihota · 2008-07-03 04:55 Quote from: "gerardus"Hi, There have been quite a few bug reports about TPageControl, and some are solved by now. Can you get the latest SVN and try? Regards, Gerard. Hi Gerard, thanks for the response. I have updated to: Version: 0.9.25 beta date: 2008/07/02 SVN Revision: 15646 i386-win32-win32/win64 but the problem still exists. Have you tried duplicating the problem?  Maybe it is only happening on my setup.  I haven't found any other posts about it. Kim ---------------------------------------------------------------------- gerardus · 2008-07-03 08:38 Hi Kim. I also get strange results with my setup (similar to yours: FPC 2.2.0, latest SVN under win XP). I tried with 4 tabs, and a label on each 'Tab 1', 'Tab2' and so on... When the form with the pagecontrol is showed again, usually the central tabs don't show the label when first selected. Further selections show all the tabs correctly. Setting the ActivePageIndex doesn't make any difference, the error occurs anyway. I've found two bug reports that may be related http://bugs.freepascal.org/view.php?id=8346 http://bugs.freepascal.org/view.php?id=11334 I've also tried freeing and creating the form that contains the TPageControl every time instead of just showing/hiding it, and it seems to work. This could be a workaround, and it's also a more elegant solution in general IMHO to handle modal forms. In your Form2 declaration add   public     { public declarations }     class procedure Execute; implemented as Code: [Select]class procedure TForm2.Execute; begin    with TForm2.Create(Application) do    begin      ShowModal;      Release;    end; end; and in your first form instead of calling  form2.ShowModal call   TForm2.Execute (or whatever class procedure you decide) HTH, Gerard. ---------------------------------------------------------------------- ksihota · 2008-07-03 17:11 Hi Gerard, Thanks for the help.  your solution appears to work perfectly.  After your change all I needed to do was switch some of my methods for pre- populating the pagecontol pages. It not only solved the wrong page display but it appears to have solved the problem of certain components not displaying. Thanks again for all your help. Kim ---------------------------------------------------------------------- gerardus · 2008-07-03 19:14 I'm glad it worked for you. ---------------------------------------------------------------------- gerardus · 2008-07-04 07:50 I created a bug report: http://bugs.freepascal.org/view.php?id=11605 ---------------------------------------------------------------------- ksihota · 2008-07-05 07:15 Hi Gerard, Thanks for doing that.  Your workaround is great and has allowed me to carry on with my project. However, it would be nice to have the component working as expected.  It is great having people like you around to help out those of us not so experienced in the field. Thanks again for all your help.  It is really appreciated. Kim ---------------------------------------------------------------------- gerardus · 2008-07-05 11:22 Quote from: "ksihota"However, it would be nice to have the component working as expected. Indeed. I had a quick look, but I dind't find any trivial (for me) problem. It could be a Win32 issue, or something common to TPageControl on all platforms. :? I'm not so experienced, and it takes a while to get to know the inners of the  LCL well enough. So a bug report + a test project and instructions to reproduce is probably the best way to help when you can't go any further. Best regards, Gerard.