Galera, terminei um projeto aqui mas quando eu executo uso um timer/button pra executar uma açao da o erro Run-time error '424': Object required
será q alguma coisa deve ta errada no code? vou postar ele pra vocês verem:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As Long) As Long
Declare Function sendmessagebystring Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Declare Function getwindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Const WM_CLOSE = &H10
Public Const GW_CHILD = 5
Public Const GW_HWNDFIRST = 0
Public Const GW_HWNDLAST = 1
Public Const GW_HWNDNEXT = 2
Public Const GW_HWNDPREV = 3
Public Const GW_MAX = 5
Public Const GW_OWNER = 4
Public Sub KillWin(Title As String)
Dim a, hwnd
hwnd = FindWindowByTitle(Title)
a = sendmessagebystring(hwnd, WM_CLOSE, 0, 0)
End Sub
Function FindWindowByTitle(Title As String)
Dim a, b, Caption
a = getwindow(frmMain.hwnd, GW_OWNER)
Caption = GetCaption(a)
If InStr(1, LCase(Caption), LCase(Title)) <> 0 Then
FindWindowByTitle = b
Exit Function
End If
b = a
Do While b <> 0: DoEvents
b = getwindow(b, GW_HWNDNEXT)
Caption = GetCaption(b)
If InStr(1, LCase(Caption), LCase(Title)) <> 0 Then
FindWindowByTitle = b
Exit Do
Exit Function
End If
Loop
End Function
Function GetCaption(hwnd)
Dim hwndLength%, hwndTitle$, a%
hwndLength% = GetWindowTextLength(hwnd)
hwndTitle$ = String$(hwndLength%, 0)
a% = GetWindowText(hwnd, hwndTitle$, (hwndLength% + 1))
GetCaption = hwndTitle$
End Function
Private Sub Command1_Click()
Call KillWin("WPE")
End Sub
Pergunta
platchuk
Galera, terminei um projeto aqui mas quando eu executo uso um timer/button pra executar uma açao da o erro Run-time error '424': Object required
será q alguma coisa deve ta errada no code? vou postar ele pra vocês verem:
Editado por platchukLink para o comentário
Compartilhar em outros sites
3 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.