Solved

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

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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
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 …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

705 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