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.