views:

86

answers:

3

I'd like to implement "Always on top" configuration option in my application that takes effect immediately.

I know that I can call Shell constructor with ON_TOP style. Is there a way to do that at runtime, that is after Shell instance has already been created?

+1  A: 

One time I had similar problem and I had found such thread:

http://dev.eclipse.org/newslists/news.eclipse.platform.swt/msg11143.html

Unfortunately I don't remember if it works...

Lukasz Stelmach
Thanks, Lukasz. I'll try that and see if it works. I'll still need a solution for Mac though. I'll see if I can find anything from SWT source code as Aaron suggested.
parxier
+1  A: 

There is no standard way to change the styles of widgets after they have been created.

You must check which code gets executed during creation time and then call the specific native method (in the class OS).

Download the source for SWT for your platform to see how it works. It's not magic, just a bit of manual debugging.

Aaron Digulla
+1  A: 

In Cocoa you need to use reflection to get at the Shell instance variable window and then call window.setLevel(OS.NSStatusWindowLevel).

In Carbon you need to get at the shellHandle instance variable and then call OS.SetWindowGroup(shellHandle, OS.kFloatingWindowClass). You might be able to get away with doing just that much, depending on your needs.

In either case, you should also forcibly add the SWT.ON_TOP bit to the style field. Particularly in Carbon, lots of things rely on that bit being set.

Scott K.
this sounds very promising, I'll give it a go
parxier