Solved

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

Posted on 2008-10-09
1
591 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

17 Experts available now in Live!

Get 1:1 Help Now