Solved

How do I only kill/close a child window without killing the Parent all in VB.NET

Posted on 2008-10-09
1
594 Views
Last Modified: 2012-05-05
How do I only kill/close a child window without killing the Parent all in VB.NET

I'm trying it with:
                    'tempProc.Kill() 'Kills all Iexplorer open
                    'tempProc.CloseMainWindow() 'Prompts to closes
But maybe I need to be working with that specific handle?


  Public Function EnumWindowsCallBack(ByVal hwnd As IntPtr, ByVal lParam As Int32) As Int32
        Dim sSave As String
        Dim ProcessID As Long

        GetWindowThreadProcessId(hwnd, ProcessID)


        Dim tempProc As Process = Process.GetProcessById(ProcessID)

        Dim processName As String = tempProc.ProcessName
       
        If (processName = "iexplore") Then


            'Get the windowtext length
            sSave = Space(GetWindowTextLength(hwnd) + 1)

            'get the window text
            GetWindowText(hwnd, sSave, Len(sSave))

            'remove the last Chr(0)
            sSave = Microsoft.VisualBasic.Left(sSave, Len(sSave) - 1)

            If (sSave.Length <> 0) Then

                If sSave.ToString.IndexOf("Google") >= 0 Then
                    sSave = "Found Google Search"

                    'tempProc.Kill() 'Kills all Iexplorer open
                    'tempProc.CloseMainWindow() 'Prompts to closes

                End If

                'Error below: Reference to a non-shared member requires an Object Reference
                Lst.Items.Add(sSave)
                'Lst.Items.Add(processName)


                If sSave.Trim <> "" Then
                    Debug.WriteLine(sSave)
                End If
            End If
        End If
        Return 1 'continue enumeration        
    End Function

0
Comment
Question by:vaultworld
1 Comment
 
LVL 15

Accepted Solution

by:
angus_young_acdc earned 500 total points
ID: 22685005
Have you tried just Me.Close() when closing the child form?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now