LEADERSOFT.ru Разработка на заказ программ и сайтов
Форумы по информационным технологиям
 
Регистрация  |  Вход
left
Форумы Минимизировать
ПоискСписок форумов
  Программирование  Microsoft Access. Файлы mdb и accdb  Тема: Как закры...
 Тема: Как закрыть другое приложение?
 
 15.06.2007 21:03:57
Benko
8 сообщения


Тема: Как закрыть другое приложение?
Открыть понятно как: shell.
А какой код нужно поместить в процедуру обработки закрытия формы, чтобы вместе с формой закрывалось другое windows-приложение?


P.S. Общие вопросы по модулям
Автор: Константин от 17.04.2003 16:40:48 Источник ...
 15.06.2007 21:03:57
All
4316 сообщения
1-ый


RE: Как закрыть другое приложение?
' 1 вариант
DoCmd.Quit
appExcel.Quit

' 2 вариант От:Steven M. Ginter (sginter@ix.netcom.com)

Declare Function GetDesktopWindow& Lib "user32" ()
Declare Function GetWindowText& Lib "user32" Alias _
"GetWindowTextA" (ByVal hwnd As Long, ByVal lpstring As String, _
ByVal cch As Long)
Declare Function GetWindow& Lib "user32" (ByVal hwnd As Long, _
ByVal wcmd As Long)
Declare Function PostMessage& Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wmsg As Long, ByVal wparam As Long, _
lparam As Any)

Public Const GW_CHILD = 5
Public Const GW_HWNDNEXT = 2
Public Const WM_CLOSE = &H10

Public Function IsRunning(TheText As String) As Long
'cycles through all top level windows, searching for _
window with title matching leftmost TexLen _
characters of TheText. Returns handle of window if _
match found, 0 otherwise
Dim WinHand As Long
Dim TextBuff As Long
Dim TexLen As Single
Dim WinText As String
TexLen = Len(TheText)

IsRunning = 0
WinHand = GetDesktopWindow()
WinText = Space$(254)
TextBuff = 255
GetWindowText WinHand, WinText, TextBuff
If Left(TrimNull(WinText), TexLen) = TheText Then
IsRunning = WinHand
Exit Function
End If

WinHand = GetWindow(WinHand, GW_CHILD)
WinText = Space$(254)
TextBuff = 255
GetWindowText WinHand, WinText, TextBuff
If Left(TrimNull(WinText), TexLen) = TheText Then
IsRunning = WinHand
Exit Function
End If
Do
WinHand = GetWindow(WinHand, GW_HWNDNEXT)
WinText = Space$(254)
TextBuff = 255
GetWindowText WinHand, WinText, TextBuff
If Left(TrimNull(WinText), TexLen) = TheText Then
IsRunning = WinHand
Exit Function
End If
Loop While WinHand <> 0
End Function

Public Function TrimNull(BegStr As String) As String
Dim NullPos As Integer
NullPos = InStr(BegStr, vbNullChar)
If NullPos > 0 Then
TrimNull = Left(BegStr, NullPos - 1)
Else
TrimNull = BegStr
End If
End Function

Public function CloseProgram()
dim hWnd as long
hWnd = IsRunning("WINDOW TITLE")
if hwnd<>0 Then
PostMessage hwnd, WM_CLOSE, &O0, &O0
end if
end function



P.S. Общие вопросы по модулям
Автор: Антон от 0:00:00 Источник ...
  Программирование  Microsoft Access. Файлы mdb и accdb  Тема: Как закры...
ПоискПоиск  Список форумовСписок форумов  
right