Solved

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

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

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

Suggested Solutions

Title # Comments Views Activity
MYSQL responding very slow 3 50
VB.NET - Refactor Class per SOLID principles 2 33
ModalPopup  question 22 39
Telerik RadEditor Control Save 8 15
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

726 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