i am useing VB.NET, and am working in a windows form.
i am trying to close a child window within a web browser. this is the code i'm useing:
Code:
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
'this is in a button
Dim hWndTmp As Long
Dim hWndOver As Long
'Get the mozilla window handle
hWndTmp = FindWindow("MozillaWindowClass", vbNullString)
'Get the child window handle
hWndOver = FindWindowEx(tWnd, 0, "#32770", "Alert")
SendMessage(hWndOver, WM_CLOSE, 0, 0)
the class name of the mozilla browser is "MozillaWindowClass", and the class name of the "alert" child window is "#32770".
could someone tell me what i'm doing wrong?
thanks.
i am trying to close a child window within a web browser. this is the code i'm useing:
Code:
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
'this is in a button
Dim hWndTmp As Long
Dim hWndOver As Long
'Get the mozilla window handle
hWndTmp = FindWindow("MozillaWindowClass", vbNullString)
'Get the child window handle
hWndOver = FindWindowEx(tWnd, 0, "#32770", "Alert")
SendMessage(hWndOver, WM_CLOSE, 0, 0)
the class name of the mozilla browser is "MozillaWindowClass", and the class name of the "alert" child window is "#32770".
could someone tell me what i'm doing wrong?
thanks.