Xojo framework z-order backwards?

I’ve just finished playing around with the Z-Order of controls and I’ve come to a strange discovery, it would seem the Xojo framework renders controls backwards compared to Windows.

In my testing tonight I have been wondering why things have been happening strangely until I realised that I had to use the following to send a control to the “bottom” of the stack.

SetWindowPos(ctrl.Handle, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)

I’ll show you a simple example.

In the Xojo designer, I placed Button1, Button2, then Rectangle1 so Button1 is at the back, Button2 is in the middle and Rectangle1 is at the front.

Now if we look at the Inspect of that when the program is running, you can see the order of the items.

Button1 is at the top of the list, the list is ordered front to back, top to bottom, so Button1 is at the top of the Z-Order.

This is evident by moving the cursor over the intersection of Button2 and Rectangle1, windows registers it as a rollover of Button2 as that is higher up the Z-Order than Rectangle1

If you look at the same form designed in Visual Studio C#, the controls were placed in the same order:

And if we look at the Inspect of that, you can see the order of the control is correct, i.e. reversed compared with Xojo

And obviously, the Visual Studio C# version doesnt suffer from Z-Order fighting when the mouse is placed over the intersection of controls

I’ve tried a few other languages and it would seem that Xojo is the only one that is rendering controls backwards in this manor.

Would someone from Xojo be able to answer if this is this a conscious design decision or has it been overlooked and implemented in this fashion by accident?

If its a conscious design decision what does it enable over doing things in the correct order?

The reason I bring this up is that is causes issues with Z-Order fighting when controls are placed other each other which are sometimes needed if certain functionality is required. I see this in the Xojo IDE as well my own apps.

Thanks in advance.

in the ide as you select items they will appear to “pop forward”

In the IDE use the move forward / move backward buttons in the upper toolbar to change their relative z-order otherwise z-order is, I believe, creation order - which is what you’re seeing

I’ve tried that Norman.

If I click on Rectangle1 I am unable to “Order Front” because it is at the front (as it was added to the Window last and is at the “top” of the pile) and that option is grayed out, however it isnt front when the program is running because this can happen:

Here’s a link to the project:

https://www.dropbox.com/s/i0xp0v5ktg17kwv/TestZOrderExample.xojo_binary_project?dl=1

Here’s a video of the problem. The yellow boxes are drawn by Inspect.exe an MS tool for inspecting Windows and their controls. I’m not clicking the mouse here, I just pause over the control and it will highlight it in yellow and find it in the tree view to the right.

https://www.dropbox.com/s/38llc0c7md5h0tk/ZOrderProblem.mp4?dl=0

Well my bug report is in, time for a break I think, that took way too long.

<https://xojo.com/issue/47001>

If you find yourself here, this thread has been superseded here:

https://forum.xojo.com/41627-how-to-fix-canvas-flicker-in-windows-7-8-10/p6#p344497