|
-
September 13th, 2001, 10:56 PM
#1
dll error
code :
Private Sub f_findwindow()
Dim hwnd1
hwnd1 = findwindow("windowname", "")
w_setfocus
End Sub
Private Sub w_setfocus()
Dim rtn As Long
Dim hwnd1
rtn = setfocus(hwnd1.hwnd)
End Sub
module :
Public Declare Function findwindow Lib "user32" Alias "findwindowa" _
(ByVal lpclassname As String, ByVal lpwindowname As String) As Long
Public Declare Function setfocus Lib "user32" (ByVal hwnd As Long) As Long
occur '453' runtime error
help me
-
September 14th, 2001, 01:47 AM
#2
Re: dll error
The setfocus function cannot be called from within a form, because it will call the setfocus method of the form. What you can do is change the declaration of the API into
public Declare Function SF Alias "SetFocus" Lib "user32" (byval hwnd as Long) as Long
and call SF instead of SetFocus
Another mistake is that you declare the hwnd1 twice. This will result in hwnd1 always having the value 0 when you come in the other procedure. Place the declaration in the general declaration section of the form.
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|