Solved

!lose internet-connection when netscape closed!

Posted on 1999-01-23
1
142 Views
Last Modified: 2010-05-03
How can I check & activcate a netscape window with
the title (where xxx is not known):
xxx - netscape

I wan´t to check if an netscape window  (or several netscape windows) is opened and as soon as they are all
closed the Internet connection should close, too.
PLEASE give an working example!
0
Comment
Question by:qwertzu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
covington earned 200 total points
ID: 1470270
Here's how you can check. You can't check by Window Class because Netscape starts up with a different window class each time. Because of this, you have to check by title.

Usage:

If NetscapeIsRunning Then
    'something
Else
    'close internet connection
End If

Make sure none of your apps have the phrase "Netscape" in the title bar.



Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal aint As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long

Const GW_HWNDNEXT = 2
Const GW_CHILD = 5


Public Function NetscapeIsRunning() As Boolean

    Dim hWndTmp As Long
   
    'get the first child window
    hWndTmp = GetWindow(GetDesktopWindow, GW_CHILD)
   
    'look for netscape in the children
    Do While hWndTmp <> 0
   
        If InStr(WindowTitle(hWndTmp), "Netscape") <> 0 Then
            NetscapeIsRunning = True
            Exit Function
        End If
        'look for a sibling
        hWndTmp = GetWindow(hWndTmp, GW_HWNDNEXT)
               
    Loop
   
End Function

Private Function WindowTitle(hwnd As Long) As String

    Dim lResult As Long
    Dim sTemp As String * 256
   
    lResult = GetWindowText(hwnd, sTemp, 256)
    WindowTitle = Left(sTemp, lResult)
   
End Function
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

734 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