Results 1 to 2 of 2

Thread: vb controling the topmost instance of IE

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2006
    Posts
    34

    vb controling the topmost instance of IE

    if anyone here has had the same headache I have had I am posting this for you. I have a program that controls IE with events the only problem with this you cannot have an array with events so my users were limited to using only the single instance of IE. If they opened a new window it was no use so here is my code to control the instance of IE with focus...


    VB Code:
    1. Private Declare Function GetForegroundWindow Lib "user32" () As Long
    2. Public WithEvents IE As SHDocVw.InternetExplorer
    3.  
    4. Private Sub Timer1_Timer()
    5. Dim strTitle As String
    6. Dim lngRet As Long
    7.  
    8. lngRet = GetForegroundWindow() ' Get the handle of the foreground window.
    9. On Error Resume Next
    10. If (lngRet <> IE.hwnd) Then
    11.     Set objShell = New Shell
    12.     For Each obj In objShell.Windows
    13.         If TypeName(obj.Document) = "HTMLDocument" Then
    14.             If obj.hwnd = lngRet Then
    15.                 Set IE = obj
    16.             End If
    17.         End If
    18.     Next obj
    19. End If
    20. End Sub
    Last edited by Hack; Jun 15th, 2006 at 01:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width