WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Window Manipulation

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How to Keep a Window On Top

Keywords:  stay on top window on top dllhwnd position always on top  

Question:

How do I make a window stay on top?

Answer:

Newer function (First showing up in WB 98A):
IntControl(54, p1, p2, 0, 0)

Keep window on top.

This IntControl tells the specified window to remain on top of all other windows, or to return to a normal (non-topmost) state.
P1 = partial windowname of the window to be affected.

P2	Meaning
--	-------
0	Don't stay on top
1	Stay on top

Returns @TRUE on success, @FALSE on failure.
IntControl 54 wants the "owning parent" title, not the messagebox title, so if you want to keep a Winbatch message box on top, for example, try:
   IntControl(54,"",1,0,0) ;keep the Winbatch window on top
"" is shorthand for the WinBatch window.

Answer (more difficult..old way):

Here's a sample script to keep a window on top.
;Check to see whether a 32 bit version of Windows is running.
If WinMetrics(-4)>=4      ;32-BIT WINDOWS
    ; Set our windows to be on top
      OurWnd=DllhWnd("")
      xx=-1
      DaDll=strcat(DirWindows(1),"USER32.DLL")     
        
      DllCall(DaDll,long:"SetWindowPos",long:OurWnd,long:xx,long:0,long:0, long:0, long:0,long:3)
      Message("This Window","Should stay on top")
      ;
      ;Try it
      
      ;Return to normal mode
      xx= -2
      DllCall(DaDll,long:"SetWindowPos",long:OurWnd,long:xx,long:0,long:0, long:0,long:0,long:3)

      ;Try it
      
      Message("This Window","Should be normal and fall behind")
      exit
else        
      ; Set our windows to be on top (FOR 16-BIT WINDOWS)
      OurWnd=DllhWnd("")
      DllCall("USER.EXE",void:"SetWindowPos",word:OurWnd,word:65535,word:0, word:0,word:0,word:0,word:3)
      Message("This Window","Should stay on top")
      ;
      ;Try it
      
      ;Return to normal mode
      DllCall("USER.EXE",void:"SetWindowPos",word:OurWnd,word:65534,word:0, word:0,word:0,word:0,word:3)
      ;Try it
      
      Message("This Window","Should be normal and fall behind")

      exit
endif           

Article ID:   W13370
Filename:   Keep a Window On Top.txt
File Created: 1999:11:04:10:37:14
Last Updated: 1999:11:04:10:37:14