|
-
Feb 11th, 2000, 03:23 PM
#1
Thread Starter
Addicted Member
Any ideas why this brings up a "Compile error- Argument not optional" error?
The Declares are:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long
Private Declare Function BringWindowToTop Lib "user32" (ByVal hWnd As Long) 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_SETTEXT = &HC
Problem code:
Private Sub Command3_Click()
Call PutTextIntoNotepad
End Sub
Private Sub PutTextIntoNotepad(hWnd As Long)
'This adds text to notepad, by locating its
''Edit' class window. This is similar to the
'method used to locate the hwnd itself, but
'here we know the parent (hWnd) so only
'have to search its child windows.
Dim hWndChild As Long
Dim sMsg As String
Dim sBuffer As String * 32
Dim nSize As Long
'this string is split only to fit the browser window
sMsg = "This method demonstrates using SendMessage()"
'get the first child window in Notepad
hWndChild = GetWindow(hWnd, GW_CHILD)
'hwndchild will = 0 when no more child windows are found
Do While hWndChild <> 0
'get the Class Name of the window
nSize = GetClassName(hWndChild, sBuffer, 32)
'if nSize > 0, it contains the length
'of the class name retrieved
If nSize Then
'if the class name is "Edit",
'set some text and exit
If Left$(sBuffer, nSize) = "Edit" Then
Call SendMessage(hWndChild, WM_SETTEXT, 0&, ByVal sMsg)
Exit Sub
End If
End If
'not found, so get the next hwnd
hWndChild = GetWindow(hWndChild, GW_HWNDNEXT)
Loop
End Sub
Thanks for the help, guys!
Daniel Christie
-
Feb 11th, 2000, 03:29 PM
#2
Because in the Command3_Click Event you are calling the PutTextIntoNotepad Sub, which has a Required Parameter, (hWnd), that you aren't passing.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
-
Feb 11th, 2000, 03:57 PM
#3
Thread Starter
Addicted Member
Doh! thank's got it
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
|