handle

Hi

If we have a few internet explorers open how do we obtain a reference to each internet explorer running in vb6 to handle each window separately

thanks
RichardsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
RichardsAuthor Commented:
Thanks ! Can you help me make it more specific to mine . I need to print each memo and handle value of all the IE's opened
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
What do you mean by "memo"?
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

RichardsAuthor Commented:
Thanks  ! the name on each explore for this link on IE it is showing Visual Basic: handle.Question 21810969 - ....

RichardsAuthor Commented:
I mean the name for each IE link
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
' ------------------------------
'  Form1
' ------------------------------

' Project --> References --> Check "Microsoft Scripting Runtime"

Option Explicit

Private Sub Command1_Click()
    Set IE = New Dictionary
    EnumWindows AddressOf EnumWindowsProc, ByVal 0&
   
    Dim key As Variant
    For Each key In IE.Keys
        Debug.Print key, IE.Item(key)
    Next
End Sub


' ------------------------------
'  Module1
' ------------------------------
Option Explicit

Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
Public Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpclassname As String, ByVal nMaxCount As Long) As Long
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Public IE As Dictionary

Public Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Boolean
    Dim sName As String
    Dim lRet As Long

    If IE Is Nothing Then
        Set IE = New Dictionary
    End If
   
    sName = Space(256)
    lRet = GetClassName(hWnd, sName, Len(sName))
    sName = UCase(Left(sName, lRet))
    If sName = "IEFRAME" Then
        IE.Add CStr(hWnd), GetWindowCaption(hWnd)
    End If
   
    EnumWindowsProc = True
End Function

Public Function GetWindowCaption(ByVal windowHandle As Long) As String
    GetWindowCaption = String(GetWindowTextLength(windowHandle) + 1, Chr$(0))
    GetWindowText windowHandle, GetWindowCaption, Len(GetWindowCaption)
End Function

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EDDYKTCommented:
may be this?

Option Explicit
Private Declare Function GetWindow Lib "USER32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetParent Lib "USER32" (ByVal hWnd As Long) As Long
Private Declare Function GetWindowText Lib "USER32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function FindWindow Lib "USER32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowPos Lib "USER32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Private Declare Function ShowWindow Lib "USER32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long


Private Sub Command1_Click()
findWindowRunning "MICROSOFT INTERNET EXPLORER"

End Sub
Public Sub findWindowRunning(taskName As String)
    Dim titleTmp As String
    Dim nRet As Long, hWndTmp As Long
   
    On Error Resume Next

    ' Find First window and loop throug master window list
    hWndTmp = FindWindow(vbNullString, vbNullString)

    Do Until hWndTmp = 0
        ' make sure this window has no parent
        Err.Clear
        If GetParent(hWndTmp) = 0& Then

            ' Retrieve caption text from current window
            titleTmp = Space(256)
            nRet = GetWindowText(hWndTmp, titleTmp, Len(titleTmp))

            If nRet Then
                'Clean up return string preparing for case-insensitive comparision
                titleTmp = UCase(Left(titleTmp, nRet))
                If (InStr(titleTmp, taskName) <> 0) Then  ' Partial
                    Dim title As String
               
                    title = Right(titleTmp, nRet - Len(taskName))
                    title = LTrim(title)
                    title = RTrim(title)
                    Debug.Print title
                End If
            End If
        End If
       
        ' Get next window in master list and continue
        hWndTmp = GetWindow(hWndTmp, 2)
    Loop
End Sub
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.