[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

handle

Posted on 2006-04-12
7
Medium Priority
?
259 Views
Last Modified: 2010-04-07
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
0
Comment
Question by:Richards
  • 3
  • 3
7 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16435973
0
 

Author Comment

by:Richards
ID: 16436229
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
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 16436338
What do you mean by "memo"?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Richards
ID: 16436609
Thanks  ! the name on each explore for this link on IE it is showing Visual Basic: handle.Question 21810969 - ....

0
 

Author Comment

by:Richards
ID: 16436621
I mean the name for each IE link
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 400 total points
ID: 16436769
' ------------------------------
'  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
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 16436774
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
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question