Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bring to Front and Send to Back problem
#1
Hi All,
 
I have a region which covers the same screen area as another (larger) region.
 
At design I use the EDIT menu points Bring to front and Send to back, to be able to see and change the contents of the covered areas.
At runtime I expected to be able to execute the region methods BringToFront and SendToBack, to decide which to be on top.
 
But the commands IWRegion1.BringToFront and IWRegion1.SendToBack do not change anything. They seem not to work.
 
Only by toggling the covered region's Visible property, can I make it appear. And then of course only when I have left the region on the front, when I compiled the program. If I left it on the back, it does not show.
 
I've made a small test program with 2 regions and 4 buttons to show the problem, and I've included the source code as attachment. No exe-file included though. You have to compile it yourself. The buttons events are the OnClick but it makes no difference if it is the OnAsyncClick events.
 
I use Delphi 10.3.2 Rio and IW 15.1.5.
 
Can I do anything to make it work ?
 
Regards
Soren
 


Attached Files
.zip   Project1.zip (Size: 53.46 KB / Downloads: 0)
Reply
#2
I only did a quick check to confirm my memory, but BringToFront and SendToBack are inherited vestigal methods of TControl and don't function in IW.

Instead, use the .ZIndex property which is on IW controls. IW maps it to this in the output:

https://www.w3schools.com/jsref/prop_style_zindex.asp
Reply
#3
Hi Kudzu,

Thanks for your reply. I'll check out the Zindex possibility.

I went through all the examples from IW XIV, and the closest to this is the Tabbed Notebook example, where indeed the visible property is the one making it work.

As it is only a part of one of the regions in my program which is covered by another region, I cannot set visibility false for that, but if I understand the Zindex property (from your link) correctly, I should be able to make it work if I change the ZIndex on both regions. I'll try it out,

Thanks,

Regards
Soren
Reply
#4
Hi all,

Just to follow up on this issue.Kudzu was (of course) right and Zindex do the trick.

I changed the buttons events to the following and made IWButton1 and -4 point to IWButton1OnClick, and IWButton2 and -3 point to the IWButton2OnClick event like this:

procedure TIWForm1.IWButton1Click(Sender: TObject);
begin
  IWRegion1.ZIndex := 1000;
  IWRegion2.ZIndex := 2000;
end;

procedure TIWForm1.IWButton2Click(Sender: TObject);
begin
  IWRegion1.ZIndex := 2000;
  IWRegion2.ZIndex := 1000;
end;

And I did set the property zindex to 1000 on the IWRegion1, as I want it be on top when the program starts, and set the IWRegion2 zindex property to 2000.

NOTE THOUGH: It does not function with the ASyncOnClick event. Only the OnClick event !!

Regards
Soren
Reply
#5
You can force it to invalidate if you call:

IWRegion.Invalidate;

after setting the zindex value of the region.

It will work.

It's already fixed in our code base and it will be available in the next release.
Reply
#6
Hi Alexandre,

Thanks. I'll try it out. Saving a roundtrip to the server just for changing which is on top, will be nice.

Regards
Soren
Reply
#7
Hi Alexandre,

Yes, IWRegion.Invalidate makes AsyncClick work:

procedure TIWForm1.IWButton1AsyncClick(Sender: TObject);
begin
  IWRegion1.ZIndex := 1000;
  IWRegion1.Invalidate;
  IWRegion2.ZIndex := 2000;
  IWRegion2.Invalidate;
end;

procedure TIWForm1.IWButton2AsyncClick(Sender: TObject);
begin
  IWRegion1.ZIndex := 2000;
  IWRegion1.Invalidate;
  IWRegion2.ZIndex := 1000;
  IWRegion2.Invalidate;

end;

Works better than with onclick. It's a lot faster.

NB! You say: It's already fixed in our code base and it will be available in the next release.
Does it mean the OnAsyncClick will work without the Invalidate method from the next release ?

Regards
Soren
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)