Date: 02-16-2022
Return to Index
created by gbSnippets
'Several API can modify the z-order list:
BringWindowToTop '- put specific window at top of z-order
SetWindowPost '- rearrange z-order of windows
GetTopWindow '- return handle of topmost window
GetNextWindow '- gets handle to next or previous window in the z-order
'Primary Code:
'Example#1 - bring a window to top
Local iReturn As Integer, Flags&
FLAGS = %SWP_NOMOVE Or %SWP_NOSIZE
BringWindowToTop hDlg
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
Global hDlg1 As DWord, hDlg2 As DWord, hDlg3 As DWord
Function PBMain() As Long
Dialog New Pixels, 0, "Dialog1",300,300,200,200, %WS_OverlappedWindow To hDlg1
Dialog New Pixels, 0, "Dialog2",350,350,200,200, %WS_OverlappedWindow To hDlg2
Dialog New Pixels, 0, "Dialog3",400,400,200,200, %WS_OverlappedWindow To hDlg3
Control Add Button, hDlg3, 100,"3-2-1", 50,10,100,20
Control Add Button, hDlg3, 200,"1-2-3", 50,40,100,20
Control Add Button, hDlg1, 300,"3 to top", 50,10,100,20
Dialog Show Modeless hDlg1 Call DlgProc1
Dialog Show Modeless hDlg2
Dialog Show Modal hDlg3 Call DlgProc3
End Function
CallBack Function DlgProc1() As Long
If CB.Msg = %WM_Command AND CB.Ctl = 300 AND CB.Ctlmsg = %BN_Clicked Then
MsgBox "Bringing 3 to top!"
BringWindowToTop hDlg3
End If
End Function
CallBack Function DlgProc3() As Long
Local iReturn As Integer, Flags&
If CB.Msg = %WM_Command AND CB.Ctl = 100 AND CB.Ctlmsg = %BN_Clicked Then
BringWindowToTop hDlg1
BringWindowToTop hDlg2
BringWindowToTop hDlg3
End If
If CB.Msg = %WM_Command AND CB.Ctl = 200 AND CB.Ctlmsg = %BN_Clicked Then
BringWindowToTop hDlg3
BringWindowToTop hDlg2
BringWindowToTop hDlg1
End If
End Function
'gbs_00059
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm