can I change visual object (rectangle) into foreground programatically?

Is it possible to change the layer of a visual object like a rectangle into foreground (front) after the start of the program?
I do not see any possibility at the moment. Or have I missed something?

Any suggestions are welcomed.
Thank you.
Thomas

There is no built in method.

I know of declares for Windows and there may be for Mac. But since your post is in General, I did not think proper to post any until I know which you are developing for.

A possible way in pure Xojo is to use two identical objects, one bottom and one front, and switch visibility between the two.

Thank you for your reply, Micheal.

First I want to use this for the Windows platform.

At the end it will be a good idea to have a solution for at least two platforms: Windows and Mac (OS X, macOS). Linux is not my first choice at the moment.

Best wishes
Thomas

Additional information:

I select a rectangle (with a sentence inside) and move the rectangle to another place for ranking.
The problem is: I have four rectangles that if want to order vertically. There is always the problem that if a rectangle is already sorted another (to be sorted) rectangle can have a lower layer. If I move the new one over a sorted one the new moved rectangle can be below the other one so that I cannot read the sentence or see the rectangle fully.

Another solution would be to place the rectangle on a ContainerControl. As I understand it, the only thing that changes is the text, right ?

Then you can remove and add rectangles dynamically, the latest coming on top.

See http://documentation.xojo.com/index.php/containerControl, and in particular http://documentation.xojo.com/index.php/ContainerControl.EmbedWithin

In terms of use, if you have never employed them, think of Container controls as sort of windows you stick within other windows.

This could be the solution. I will try this.

Thank you very much.
Thomas

if the items won’t end up being overlapped, why not use the built-in drag and drop capability?

@Michel: I tried the ContainerControl but have a problem with it. Is it possible to use a ContainerControl (e.g. CC1.Close) again if I have closed it before? If I do something like this (and embed it within another ContainerControl AnotherCC) I got errors:

CC1.Close

CC1 = new ContainerControl 
CC1.EmbedWithin(AnotherCC, 0,0,width, height) 

This do not work and the whole Debugger stops so that I do not see any errors…

@Greg: I did not found a example how I can drag and drop a ContainerControl into another location within the same Window. Do I miss someting?

Thank you.
Thomas

It should not be

CC1 = new ContainerControl 

ContainerControl is a reserved name.

Maybe ContainerControl1 instead. That is the name the IDE gives to the first ContainerControl you drag into the project.

This works in a button :

[code] if CC1 <> nil then CC1.Close

CC1 = new ContainerControl1
CC1.EmbedWithin(self, 0,0,width, height) [/code]

CC1 is a property of the window. Note the check for CC1 being nil. Also, you embed in the window, here simply the window onto which the button is, self.

Dear Michel,

yes, this was one of the errors but there were some other problems with the event handler in the containercontrol if I close it. So I have transfer the necessary logic into the main window. Now it works! Thank you very much, the idea of re-embed the containercontrol again was the answer for me!

If I am ready I will send a drop box link for checking if someone want to do. It could be that I have other fiddly programming parts in the code. Since I am not a full time programmer due to my job as scientist it will take some time.

I am not familiar with the drag and drop features in Xojo. It could be that such an solution is possible. At the moment I have my own special “drag and drop” for ranking sentences hirachically and it works.

However, another problem is that under Windows OS the containercontrols are flicker a lot and I have not a good solution since yet. I know that there is a big debate about it. What are the necessary parameter that I should alter?
DoubleBuffering? Background erase?, transparent of the containercontrol?, or shoud I use a solution with declares?

Thank you very much,
Thomas

here is the link for the “drag and drop” project

https://www.dropbox.com/s/lrg6vr51f8jcozl/TestDragAndDropWithContainerControls_V02.xojo_binary_project?dl=0

Windows is prone to flickering any time you move controls. The solution is to make the control invisible, and substitute it a canvas that only shows a rectangle of the same size which will flicker way less when moved. Then when your drag is over, put the canvas off screen or make it invisible, and make the Container Control visible again.

Dear Michel,

thank you very much again, a good solution that I will try.

Thomas