Date: 02-16-2022
Return to Index
created by gbSnippets
'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: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#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
Local Flags As Long
Flags = %SWP_NOMOVE Or %SWP_NOSIZE
Select Case CB.Msg
Case %WM_Command
Select Case CB.Ctl
Case 100: SetWindowPos(hDlg, %HWND_TOPMOST, 0, 0, 0, 0, Flags) 'on Top
Case 200: SetWindowPos(hDlg, %HWND_NOTOPMOST, 0, 0, 0, 0, Flags) 'not on Top
End Select
End Select
End Function
'gbs_00044
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm