Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2006, 04:03 AM
Authorized User
 
Join Date: Feb 2004
Posts: 44
Thanks: 0
Thanked 0 Times in 0 Posts
Default Troubles with detecting the 'right' window

In my case there will normally be many open IE windows, but I want to extract some info. from one of these.In this ex. GOOGLE.
Then line: InStr("GOOGLE", IECaption) > 0 always return 1 no matter what IE instance I am looking at and the IECaption is always empty.
Code:
' Reference to
' Microsoft internet control
' microsoft html object lib.
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
 
Sub Test()
 Dim sText As String * 255
 Dim IECaption As String
 Dim SW As SHDocVw.ShellWindows
 Dim IE As SHDocVw.InternetExplorer
 
 Set SW = New ShellWindows

 Static lHwnd As Long
 'Loop through all the shell windows on the desktop
 For Each IE In SW
     If TypeOf IE.Document Is HTMLDocument Then
    IECaption = UCase(Left$(sText, GetWindowText(lHwnd, ByVal sText, 255)))
    If InStr("GOOGLE", IECaption) > 0 Then
     ' Code for fetching info goes here
           MsgBox IE.LocationName
    End If
     End If
 Next IE
 Set SW = Nothing
End Sub
What am I doing wrong ?
Cheers Karsten






Similar Threads
Thread Thread Starter Forum Replies Last Post
Shader troubles Largo39 BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 0 August 9th, 2007 03:01 PM
Troubles with Programm AlisaSmi Excel VBA 0 March 7th, 2007 07:50 AM
PHP Troubles[:D] peter_budo BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 September 3rd, 2004 04:42 PM
DataGrid Troubles mrideout BOOK: Beginning ASP.NET 1.0 1 August 17th, 2004 11:32 AM
Interop Troubles Yehuda Pro VB.NET 2002/2003 0 June 29th, 2004 01:26 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.