Results 1 to 4 of 4

Thread: closing windows

  1. #1

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Question

    how can i close access window?

    If a post has helped you then Please Rate it!

  2. #2
    Addicted Member Babbalouie's Avatar
    Join Date
    Jan 2001
    Location
    On the bright, blue sea...
    Posts
    197
    How did you open it?
    Building A Better Body Albeit Left Out Under Intense Extrapolation

  3. #3
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    VBKNIGHT:
    Here how we close an external application.

    Code:
    Option Explicit
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As String) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    
    Private Const WM_SYSCOMMAND = &H112
    Private Const SC_CLOSE = &HF060&
    Private xhWnd As Long
    
    Private Sub CloseExtApplication()
        xhWnd = FindWindow(0&, "Access Windows name")
        If xhWnd <> 0 Then SendMessage xhWnd, WM_SYSCOMMAND, SC_CLOSE, 0&
    End Sub

  4. #4
    Guest
    You also need to Destroythe window.
    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Const WM_CLOSE = &H10
    
    Private Sub Command1_Click()
        Dim hWnd_App As Long
        
        hWnd_App = FindWindowEx(0, 0, "WindowClass", "WindowName")
        SendMessage hWnd_App, WM_CLOSE, 0, 0
        DestroyWindow hWnd_App
    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