Keep on Top

Category: Apps/Dialogs

Date: 07-23-2010

Return to Index


 
'Primary Code:
Local iReturn As Integer, Flags&
FLAGS = %SWP_NOMOVE Or %SWP_NOSIZE
iReturn = SetWindowPos(hDlg, %HWND_TOPMOST, 0, 0, 0, 0, Flags)  'on Top
iReturn = SetWindowPos(hDlg, %HWND_NOTOPMOST, 0, 0, 0, 0, Flags) 'not on Top
 
'The SetWindowPos can be used to set size/location or z-order of
'a window. The Flags settings used above keep the window stationary.
 
'Compilable Example:
#Compile Exe
#Dim All
#Include "Win32API.inc"
Global hDlg As DWord
Function PBMain() As Long
   Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
   Control Add Button, hDlg, 100,"OnTop", 50,10,100,20
   Control Add Button, hDlg, 200,"NotOnTop", 50,40,100,20
   Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
   BringWindowToTop GetDlgItem(hDlg,100)
 
'gbs_00044


created by gbSnippets: http://www.garybeene.com