Recent

Author Topic: TPageControl tabs visible at design time, vanish at runtime  (Read 734 times)

NightSky

  • New Member
  • *
  • Posts: 15
TPageControl tabs visible at design time, vanish at runtime
« on: August 14, 2022, 05:40:58 am »
Version 2.2.2, May, 32 bit version.  64 bit windows 10, latest.

64 bit version did not install FPC properly, so went to 32 bit version.

Standard form with a PageControl.  Create tabs and place items on them at design time.  No graphics items created during runtime.  Run program.  Only one tab visble.  (is the one that was selected at design time). 

Tried setting the following:
Code: Pascal  [Select][+][-]
  1.    form1.TabSheet3.TabVisible:= true;
  2.    form1.TabSheet4.TabVisible:= true;
  3.    form1.TabSheet5.TabVisible:= true;
  4.    form1.TabSheet3.Visible:= true;
  5.    form1.TabSheet4.Visible:= true;
  6.    form1.TabSheet5.Visible:= true;
  7.    form1.TabSheet3.Enabled:= true;
  8.    form1.TabSheet4.Enabled:= true;
  9.    form1.TabSheet5.Enabled:= true;
  10.  

Doesn't work.  This was working, then stopped working.  Put in new page control, transferred things over, this worked.  Then after a few days, the new page control (hence names) stopped working.

Looking through the posts doesn't seem to give any help.

Any ideas?


jamie

  • Hero Member
  • *****
  • Posts: 4750
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #1 on: August 14, 2022, 03:35:21 pm »
Did you use the Editor for the page control to insert the new tabsheets or did you just add them via code?

 You will only see one page at a time anyways if they are connected to the same Page control, but you need to set the page index of the page control to the one you want to see.
The only true wisdom is knowing you know nothing

wp

  • Hero Member
  • *****
  • Posts: 10031
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #2 on: August 14, 2022, 03:52:04 pm »
Any ideas?
Post a small project in which we can see this issue. In all my own projects, the pagecontrol behaves correctly.

NightSky

  • New Member
  • *
  • Posts: 15
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #3 on: August 14, 2022, 05:03:35 pm »
Thanks for replying:

1) used the editor both times.
2) I may have been unclear.  The tabs for the other pages themselves vanish at runtime, but are present and can be selected at design time.  Content for the pages (all different, of course) is still present in the system.
3) Since this had worked properly, then stopped, I suspect something has mutated.
4) selecting a page in code does not work.

5) For an example, I would cheerfully give you the entire project, but the zip file is almost 700K bytes discarding the EXE file.  I'll have to copy the project and trim down things to see if I can both reproduce the problem (remember it fails after a bit), and reduce the size.


NightSky

  • New Member
  • *
  • Posts: 15
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #4 on: August 14, 2022, 05:50:47 pm »
In creating an example project:

Three tabs:  Tab 1 has a shelltreeview and a shelllistview (in panels)
Tab 2 has a string grid
Tab 3 has a string grid and an image.

Deleting the content (but not the pages) on tabs 2 and 3 has no effect.
Deleting the shelllistview  on tab 1 brings the tabs back to visible
Restoring the shelllistview brings it back, and the tabs are still there.
It hasn't broken yet.

This may be meaningful.

I can zip the project with the content on tab 1 (and broken), but I suspect it will still be too large.
 

wp

  • Hero Member
  • *****
  • Posts: 10031
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #5 on: August 14, 2022, 08:05:44 pm »
Do I understand correctly that these are steps to reproduce?
- Add a pagecontrol with 3 tabs
- Add a TShellTreeView and a TShellListview to the first tab
- Add a TStringGrid to the second tab
- Add a TStringGrid and a TImage to the third tab.

You don't write what happens after this...

When I do these steps (see attached demo) everything is fine (Laz 2.2.2/32bit on Win 11/64bit). So, there more to trigger the issue...

Are there any event handlers attached to the controls on the tabs? What happens if you remove them? It could be that they trigger a silent exception which prevents the other tabs to complete painting.

NightSky

  • New Member
  • *
  • Posts: 15
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #6 on: August 14, 2022, 11:08:32 pm »
It's a trifle more complicated, but....

Quote
Do I understand correctly that these are steps to reproduce?
- Add a pagecontrol with 3 tabs
- Add a TShellTreeView and a TShellListview to the first tab
- Add a TStringGrid to the second tab
- Add a TStringGrid and a TImage to the third tab.


You don't write what happens after this...

Sorry, thought it was implied.  The project compiles properly, and the page control displays all tabs at both runtime and design time.  After using the program (and making minor changes, none of which *ought* to mess things up, mostly changes to a drawn graphic; the tabs vanish at runtime, and still appear at design time.

Quote

When I do these steps (see attached demo) everything is fine (Laz 2.2.2/32bit on Win 11/64bit). So, there more to trigger the issue...


Oh yes, absolutely.  No idea what, but I have suspicions.

Quote
Are there any event handlers attached to the controls on the tabs? What happens if you remove them? It could be that they trigger a silent exception which prevents the other tabs to complete painting.
*

This is possible.  However, I just removed all events from Tshelltreeview and TshellListview without changing the behavior.  I think I've removed all possible event handlers (the code is there, but not linked, the controls onXXXXX is now blank.  This ought to rule that possibility out.  There are no event handlers linked to the page control itself.

If you do decide to run the example (which *is* broken), you will need to point the tshell tree view at another location, mine is hardcoded to the files on my disk.  I found (on a previous test), that deleting the tshelllistview made the tabs come back. 

Still puzzled.  Thanks for the help so far.

wp

  • Hero Member
  • *****
  • Posts: 10031
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #7 on: August 15, 2022, 12:21:23 am »
Thanks for this sample code. Now I can reproduce the issue with the following simplest project: a form with a pagecontrol having three tabs, a shelllistview on one page (a shelltreeview is not required), and the Root property of the shelllistview must not be empty (in the attached project it points to c:\windows). When this project runs only the tab with the shelllistview is displayed.

The issue came in with Laz 2.2, v2.0.x were behaving correctly.

A workaround is to set the Root property at runtime rather than in the object inspector at designtime.
« Last Edit: August 15, 2022, 12:24:47 am by wp »

wp

  • Hero Member
  • *****
  • Posts: 10031
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #8 on: August 15, 2022, 12:53:36 am »
OK, here is a fix; the problem is accessing a non-allocated handle of the TShellListView in the new ShellIcons procedure of v2.2+. Please test, and I'll commit it to Laz/main
  • Open file shellctrls.pas; it is in folder "lcl" of your Lazarus installation.
  • In the declaration of TCustomShellListView add the line "FPendingRoot: String" immediately after "FRoot: String"
  • In the "protected" section add a method "procedure CreateHandle; override" (don't forget the "override"!)
  • In the implementation section add this method:
Code: Pascal  [Select][+][-]
  1. procedure TCustomShellListView.CreateHandle;
  2. begin
  3.   inherited;
  4.   if FPendingRoot <> '' then
  5.   begin
  6.     Root := FPendingRoot;
  7.     FPendingRoot := '';
  8.   end;
  9. end;
  • In the implementation of "TCustomShellListView.SetRoot" add this code immediately after the "begin":
Code: Pascal  [Select][+][-]
  1. procedure TCustomShellListView.SetRoot(const Value: string);
  2. begin
  3.   if not HandleAllocated then    // <--- begin addition
  4.   begin
  5.     FPendingRoot := Value;
  6.     exit;
  7.   end;                            // ---> end addition
  8.  
  9.   if FRoot <> Value then
  10.   begin
  11.     ...
« Last Edit: August 15, 2022, 12:56:10 am by wp »

HeavyUser

  • Sr. Member
  • ****
  • Posts: 397
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #9 on: August 15, 2022, 02:15:56 am »
OK, here is a fix;
A quick test shows that the problem is patched.

wp

  • Hero Member
  • *****
  • Posts: 10031
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #10 on: August 15, 2022, 01:55:08 pm »
Submitted a bug report for documentation (https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39860), committed a slightly different patch to Laz-main and requested back-porting to Laz-fixes/Laz 2.2.4.

NightSky

  • New Member
  • *
  • Posts: 15
Re: TPageControl tabs visible at design time, vanish at runtime
« Reply #11 on: August 15, 2022, 06:14:41 pm »
Solution implemented.  Problem solved.

Thank you.

 

TinyPortal © 2005-2018