Google 그룹스는 더 이상 새로운 유즈넷 게시물 또는 구독을 지원하지 않습니다. 과거의 콘텐츠는 계속 볼 수 있습니다.

How to get the IE Window Object from handle (IE.HWND)?

조회수 40회
읽지 않은 첫 메시지로 건너뛰기

Chris Young

읽지 않음,
2001. 11. 1. 오후 7:12:1001. 11. 1.
받는사람
Apologies for this rather Newbie question...How can I get the Window *Object*
if I have the Window Handle? I am automating Internet Explorer from Visual
Basic, and I want to know when the user switches IE windows (assuming multiple
IE windows are up, e.g., a pop-up). I need to catch events (esp OnFocus) from
the IE Window.

I was thinking something simple like:
===========================
Dim WithEvents IE As InternetExplorer
Dim WithEvents IEWin As ???????
.
.
.
Set IE = CreateObject("InternetExplorer.Application")
Set IEWin = SomeFuncToGetTheWindowObject(IE.HWND)

And then:

Private Sub IEWin_OnFocus()

<Code to handle focus change here>

============================

Thoughts?

Thanks,
Chris

Garcia Francois

읽지 않음,
2001. 11. 29. 오전 4:46:3101. 11. 29.
받는사람
To get events from InternetExplorer window, subscribe to WebBrowser
events and then to HTMLWindow2 events when you receive a "navigate
complete" notification :

--- Sample begin --------------------------------------

Dim ie As New SHDocVw.InternetExplorer
Dim win As IHTMLWindow2
Dim WithEvents ieEvt As SHDocVw.WebBrowser
Dim WithEvents winEvt As HTMLWindow2

Private Sub Form_Load()
Set ieEvt = ie
ie.Visible = True
ie.Navigate "http://hongkong.scmp.com/index.html"
End Sub

Private Sub ieEvt_NavigateComplete2(ByVal pDisp As Object, URL As
Variant)
' Called when navigation is completed
' Get document window and subscribe on its events
Dim wb As WebBrowser
Set wb = pDisp
Set win = wb.Document.parentWindow
Set winEvt = win
End Sub

Private Sub winEvt_OnFocus()
' Called when window has focus
End Sub

Private Sub winEvt_OnBlur()
' Called when window lost focus
End Sub

--- Sample end --------------------------------------


FG.


cb...@home.com (Chris Young) wrote in message news:<9rsn5q$mg...@kcweb01.netnews.att.com>...

새 메시지 0개