Page 1 of 1

Toggle a window from always on top to bottom

Posted: Mon Feb 24, 2014 2:09 am
by PB
I've got a window which I've "pinned" to the desktop so it's
always underneath all other windows:

Code: Select all

SetParent_(WindowID(win),FindWindow_(0,"Program Manager"))
And it works totally fine. But now I need to toggle it so that
it's sometimes on top of all other windows for a while. I tried
this, but it doesn't work:

Code: Select all

SetParent_(WindowID(win),0)
SetWindowPos_(WindowID(win),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
Normally the SetWindowPos line does it, but it's failing because
of SetParent. What else can I try? Thanks.

Re: Toggle a window from always on top to bottom

Posted: Mon Feb 24, 2014 2:29 am
by TI-994A
PB wrote:...I need to toggle it so that it's sometimes on top of all other windows for a while.
Hi PB. Try this:

Code: Select all

  SetParent_(WindowID(win), 0)
  StickyWindow(win, 1)

Re: Toggle a window from always on top to bottom

Posted: Mon Feb 24, 2014 5:03 am
by netmaestro
Agree with TI-994A. StickyWindow is what I use and it's worked well for years. I guess the only reason you might look for another option is if the window you're working with is an api window and not a PB window. Dunno if that's a consideration or not, but if it's a native window, StickyWindow should give good results.

Re: Toggle a window from always on top to bottom

Posted: Mon Feb 24, 2014 6:35 am
by PB
Thanks TI-994A, using StickyWindow did it! :D
Don't know why SetWindowPos failed, though.
I shouldn't use so much API code, I guess. :?