Results 1 to 2 of 2

Thread: Closing outside window with instr stuff

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2002
    Location
    Australia
    Posts
    1

    Closing outside window with instr stuff

    Can someone please tell me how to close a window if it has a certain string in it's title?

    eg. If there is two windows opened called 'Go!Zilla Downloads' and 'My Downloads', theyd both close because they both have the string 'Downloads' in them.

    Thx.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    3.  
    4. Private Const WM_CLOSE = &H10
    5.  
    6. Private Sub cmdCloseApp_Click()
    7. Dim CloseIt As Long
    8. CloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
    9. PostMessage CloseIt, WM_CLOSE, CLng(0), CLng(0)
    10. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width