Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compiler PBWin 10
#Compile Exe
#Dim All
%Unicode = 1
#Include "Win32API.inc"
Enum Equates Singular
IDC_ChromeA = 500
IDC_ChromeB
IDC_FireFox
IDC_IE
End Enum
Global hDlg, hWnd, hWndTop, dwThread As Dword
Function PBMain() As Long
Dialog Default Font "Tahoma", 12, 1
Dialog New Pixels, 0, "PowerBASIC",1600,300,400,200, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_IE,"IE (Jose)", 50,10,150,25
Control Add Button, hDlg, %IDC_ChromeA,"ChromeA (Jose)", 50,50,150,25
Control Add Button, hDlg, %IDC_ChromeB,"ChromeB (Dominic)", 50,90,150,25
Control Add Button, hDlg, %IDC_FireFox,"FireFox (Dominic)", 50,130,150,25
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_IE 'Jose
hWnd = FindWindow("IEFrame", ByVal %Null)
Dialog Set Text hDlg, Hex$(hWnd)
SetWindowPos hWnd, %HWnd_NoTopMost, 0,0,500,500,%SWP_ShowWindow
Case %IDC_ChromeA 'Jose
hwnd = FindWindow("Chrome_WidgetWin_1", ByVal %NULL)
hwnd = GetAncestor(hwnd, %GA_ROOTOWNER)
Dialog Set Text hDlg, Hex$(hWnd)
SetWindowPos hwnd, %HWnd_NoTopMost, 0,0,500,500,%SWP_ShowWindow
Case %IDC_ChromeB 'Dominic
hWnd = FindWindow("Chrome_WidgetWin_1", ByVal %NULL)
hWnd = GetWindow(hWnd, %GW_HWNDNEXT)
Dialog Set Text hDlg, Hex$(hWnd)
SetWindowPos hwnd, %HWnd_NoTopMost, 0,0,500,500,%SWP_ShowWindow
Case %IDC_FireFox 'Dominic
hWnd = FindWindow("MozillaWindowClass", ByVal %NULL)
dwThread = GetWindowThreadProcessId(hWnd, ByVal %NULL)
EnumThreadWindows dwThread, CodePtr(EnumThreadWndProc), VarPtr(hWndTop)
Dialog Set Text hDlg, Hex$(hWndTop)
SetWindowPos hwndTop, %HWnd_NoTopMost, 0,0,500,500,%SWP_ShowWindow
End Select
End Select
End Function
Function EnumThreadWndProc( ByVal hWnd As Dword, ByVal lParam As Long) As Long
Local phWndTop As Dword Ptr, dwStyle As Dword
dwStyle = GetWindowLong(hWnd, %GWL_STYLE)
If ((dwStyle And (%WS_Popup Or %WS_Child)) = 0) And ((dwStyle And %WS_Visible) <> 0) Then
phWndTop = lParam
@phWndTop = hWnd
Function = %FALSE
Else
Function = %TRUE
End If
End Function
http://www.garybeene.com/sw/gbsnippets.htm