change the Z Order of a Window - making a window the TOPMOST

#1

Hi

if i have more than 1 window in my app , how can i get the
openframeworks window to be the TOPMOST ???

thanks!!

#2

is this on a mac, pc, linux?

there are system specific ways to do it on each…

take care!
zach

#3

I’m working on a PC.

#4

here is code for making it top most again, but it can change. there is also a way to make it fixed, (like photoshop’s loading panel) but that’s with the window styles, there some code here for that:

http://www.openframeworks.cc/forum/view-…-windowlong

fyi this is the call to make the window topmost again:

  
  
HWND hWnd = WindowFromDC(wglGetCurrentDC());  
::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0 , 0 , 0, SWP_NOMOVE | SWP_NOSIZE);      
  

if you call this code, every so often, the window pops back up to the top (even if it looses focus), ie:

  
  
    if (ofGetFrameNum() % 100 == 0){  
        HWND hWnd = WindowFromDC(wglGetCurrentDC());  
        ::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0 , 0 , 0, SWP_NOMOVE | SWP_NOSIZE);  
    }  
  

it’s slightly annoying :slight_smile: but it could be useful for what you need to do… (either do it through the winow style, or this way, by getting the hwnd and manually making it topmost) I guess there is another windows call to get focus back.

hope that helps!
zach

Is it possible to force OF app window to maintain focus?
Remove screen border
#5

Huh - I didn’t know about that method for getting a window handle.
I think with that approach we could fix the [x] button on windows. The problem with the previous code was in getting the window handle

I’ll give it a shot when I have a chance - here is the link to the rather ridiculous way I was trying to get the window handle.
http://forum.openframeworks.cc/t/stopping-application-on-window-close-with-of-window/22/13

Theo