Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

!lose internet-connection when netscape closed!

Posted on 1999-01-23
1
Medium Priority
?
144 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 400 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 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