Recent

Author Topic: Sudden errors  (Read 458 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1819
Sudden errors
« on: June 18, 2026, 06:01:30 am »
I used to use my program without any problems, but suddenly following exceptions occur --- possibly after upgrading to v4.6.
What does the error means?

Problem happens in the grid on the right panel, which is a TTIPropertyGrid.
When I select one item in the TValueListEditor in the middle part, the TTIPropertyGrid shows the properties of an object connected to the selected item. Displaying them causes no problem. As I change the selection in the TValueListEditor, the properties are displayed accordingly.
However, I cannot edit the content of TTIPropertyEditor. When I try to edit, the attached error message is displayed.

egsuh

  • Hero Member
  • *****
  • Posts: 1819
Re: Sudden errors
« Reply #1 on: June 18, 2026, 06:16:42 am »
Among the TTIPropertyEditor's properties,

Align = alClient;
and none of the anchors are set (this doesn't matter, as I tried setting alLeft and alTop, but the same result).

I upgraded to version 4.8, but still the same problem.
« Last Edit: June 18, 2026, 06:19:08 am by egsuh »

jamie

  • Hero Member
  • *****
  • Posts: 7852
Re: Sudden errors
« Reply #2 on: June 18, 2026, 11:13:13 am »
If you are using the OnResize event of a wincontrol you should not make changes to the size of the contril, only use that event for logging or maybe update child controls, otherwise you will get an error like that.

 Using INVALIDATE may delay the update after the change,
The only true wisdom is knowing you know nothing

Xenno

  • Full Member
  • ***
  • Posts: 132
    • BS Programs
Re: Sudden errors
« Reply #3 on: June 18, 2026, 11:35:08 am »
Agree, ELayoutException is frustating. Usually it involves intrussion processes by timer, thread, or other events.
 
After you checked for any intrussion processes, you can check layout and aim for simple one as complex layout often contributes such problem.

For example the right side, it seems like:

TPanel (alRight)
  - TPanel (alTop)
    - TRadioGroup "Question type"
  - TGroupBox "Codeframe Options" (alTop)
    - TPanel (pnlSync) (alClient)
      - Sync Q
      - Unsync
  - TTIPropertyGrid (alClient)


It could be simplified:

TPanel (alRight)
  - TPanel (alTop)
    - TRadioGroup "Question type" (alClient)
    - TGroupBox "Codeframe Options" (alBottom)
      - Sync Q
      - Unsync
  - TTIPropertyGrid (alClient)


Use Align and BorderSpacing properties wisely.

Anyway, why alClient with no anchors? Doesn't Align set Anchors accordingly and need that?
Lazarus 4.6, Windows 10, https://www.youtube.com/@bsprograms
If I want to share, I give. If I want money, I sell. I don't set traps.

egsuh

  • Hero Member
  • *****
  • Posts: 1819
Re: Sudden errors
« Reply #4 on: June 18, 2026, 11:49:24 am »
Quote
If you are using the OnResize event of a wincontrol

No.. there are no OnResize events.


Quote
Anyway, why alClient with no anchors? Doesn't Align set Anchors accordingly and need that?

Yes, they are automatically checked for all sides, but there are no siblings. I removed them myself.

egsuh

  • Hero Member
  • *****
  • Posts: 1819
Re: Sudden errors
« Reply #5 on: June 18, 2026, 12:21:32 pm »
This seems to happen when the align is set to alTop or alClient. Wiht alNone, it's fine.

There are many TPanels or TGroupBoxes in the panel. I have been asking this since quite a while ago, but do not have answers yet.

Can I fix the order of the controls appear, if all of them are set to alTop, and I hide some of them by setting their visible properties. I hope they appear in the order that I designed them. But they are not guaranteed.

Or would TFloatPanel help instead of TPanel?

Xenno

  • Full Member
  • ***
  • Posts: 132
    • BS Programs
Re: Sudden errors
« Reply #6 on: June 18, 2026, 12:25:35 pm »
Glad to see a light.

My experience, I need to check whenever needed and fix the order by code.

Code: Pascal  [Select][+][-]
  1. if (B.Top > A.Top) then
  2.   B.Top := A.Top + A.Height;

It's one reason to encourage simple layouts.
Lazarus 4.6, Windows 10, https://www.youtube.com/@bsprograms
If I want to share, I give. If I want money, I sell. I don't set traps.

egsuh

  • Hero Member
  • *****
  • Posts: 1819
Re: Sudden errors
« Reply #7 on: June 18, 2026, 12:39:14 pm »
Quote
My experience, I need to check whenever needed and fix the order by code.

Code: Pascal  [Select][+][-]
  1.     if (B.Top > A.Top) then
  2.       B.Top := A.Top + A.Height;

Does this automatically keep the order of all controls whenever I set visibility on/off?

Quote
It's one reason to encourage simple layouts.

The reason I'm using multi-layered layout is to keep orders.


BTW, the problem does not happen by setting Constraints.MaxWidth to any value, not 0.

Xenno

  • Full Member
  • ***
  • Posts: 132
    • BS Programs
Re: Sudden errors
« Reply #8 on: June 18, 2026, 01:15:27 pm »
Does this automatically keep the order of all controls whenever I set visibility on/off?

Placement order? Yes, sure. Of course, need to modify for your layout and not automatically.
Tab order? We need to use BringToFront and SendToBack properly.

Quote
BTW, the problem does not happen by setting Constraints.MaxWidth to any value, not 0.

Rather risky. What would happend when alClient and/or Constraints.MaxWidth = 1?
But, if it solves the problem and you're happy, it solves.
Lazarus 4.6, Windows 10, https://www.youtube.com/@bsprograms
If I want to share, I give. If I want money, I sell. I don't set traps.

egsuh

  • Hero Member
  • *****
  • Posts: 1819
Re: Sudden errors
« Reply #9 on: June 19, 2026, 05:25:55 am »
Quote
Placement order? Yes, sure. Of course, need to modify for your layout and not automatically.
Tab order? We need to use BringToFront and SendToBack properly.

I do not mean TabOrder. Let's assume that I have 5 TPanels, panel1, panel2, panel3, panel4 and panel5. All panels' alignments are alTop. During the design time, they are displayed in the order from top to bottom.
But when I set

panel1.visible := false;
panel3.visible := false;


and then later I set

panel3.visible := true;

then sometimes they are displayed in the order of :

         panel2, panel4, panel3, and panel5. (this is not consistent. But anyway the orders are not kept as I designed).

Quote
Rather risky. What would happend when alClient and/or Constraints.MaxWidth = 1?

I can fix Constraints.MaxWidth at property editor. Of course this is a temporary solution until ultimate solution is found.

Xenno

  • Full Member
  • ***
  • Posts: 132
    • BS Programs
Re: Sudden errors
« Reply #10 on: June 19, 2026, 06:18:25 am »
Prepare a procedure.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.PrcFixPlacementOrders;
  2. begin
  3.   if (panel2.Visible) and (panel2.Top < panel1.Top) then
  4.     panel2.Top := panel1.Top + panel1.Height;
  5.   if (panel3.Visible) and (panel3.Top < panel2.Top) then
  6.     panel3.Top := panel2.Top + panel2.Height;
  7.   // so on...
  8. end;

Added visibility check to avoid uneeded arrangement.

Code: Pascal  [Select][+][-]
  1. panel3.Visible := True;
  2. PrcFixPlacementOrders;

No need to call it when setting a panel to be not visible.

Back to this thread's subject, is it solved by Constraints.MaxWidth trick? I can't say this will always work. I hope you'll find better solution.
Lazarus 4.6, Windows 10, https://www.youtube.com/@bsprograms
If I want to share, I give. If I want money, I sell. I don't set traps.

jamie

  • Hero Member
  • *****
  • Posts: 7852
Re: Sudden errors
« Reply #11 on: June 19, 2026, 12:14:29 pm »
Change the Z order of the controls? Place the control to be first to show at the top and so on.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018