|
-
Oct 20th, 2000, 04:17 PM
#1
Thread Starter
Frenzied Member
I am using:
Code:
X = FindWindowEx(hwnd, 0&, "RICHEDIT", vbNullString)
to get the hWnd of one the rich edit boxes on a form of another program so I can send text to. This works fine, the problem I have is there are two rich edit boxes on the form how do I get the other rich edit box hWnd?
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Oct 20th, 2000, 04:41 PM
#2
transcendental analytic
Code:
Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private returnval(), counter%, Parent&
Private Function EnumFunction(ByVal hwnd&, ByVal lParam&) As Long
If GetParent(hwnd) <> Parent Then EnumFunction = True: Exit Function 'Exits if it's a indirect child
counter = counter + 1
ReDim Preserve returnval(counter - 1)
returnval(counter - 1) = hwnd
EnumFunction = True
End Function
Public Function Getchild(Parenthwnd&)
Parent = Parenthwnd
counter = 0
EnumChildWindows Parenthwnd, AddressOf EnumFunction, 0
If counter Then Getchild = returnval
End Function
You could enumerate the child windows of your form and check for their classnames, catch both richtextboxes and check for their specific size or position to determine which one it is
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 20th, 2000, 04:52 PM
#3
Thread Starter
Frenzied Member
Once again Kedaman you rule!!
Thanks
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Oct 20th, 2000, 04:53 PM
#4
Or you can still use FindWindowEx function by looping through all children that's class name is RICHEDIT:
Code:
Dim lngChildHwnd As Long
Dim arrChildren() As Long
Dim i As Integer
lngChildHwnd = 1
Do until lngChildHwnd = 0
lngChildHwnd = FindWindowEx(ParentHwnd, lngChildHwnd, "RICHEDIT", vbNullString)
If lngChildHwnd Then
Redim Preserve arrChildren(i)
arrChildren(i) = lngChildHwnd
i = i + 1
End If
Loop
arrChildren now holds window handles of all RICHEDIT children (assuming that ParentHwnd is a parent window handle).
-
Oct 20th, 2000, 05:11 PM
#5
transcendental analytic
Yep, but Serge seems to have found a better solution!
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 20th, 2000, 05:13 PM
#6
Thread Starter
Frenzied Member
I can't get serge's solution to work though it will only find the first hWnd then it stops.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Oct 20th, 2000, 05:16 PM
#7
Are you sure you pass a parent that has more then 1 RICHEDIT child???
-
Oct 20th, 2000, 05:19 PM
#8
Thread Starter
Frenzied Member
Positive I used spy++ and both are named RICHEDIT and they both have different hWnds
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Oct 20th, 2000, 05:45 PM
#9
transcendental analytic
Hmm I tried the same and didn't get any handles of the Richtextboxes at all, are you sure the arguments are correct?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 20th, 2000, 06:23 PM
#10
It's hard to say if it's working correctly or not, since I don't know what application you're trying to use to send the text to.
This code was tested with the form and 5 RichTextboxes sitting on it. It has created an array with 5 elements. Even though classname of the RichTextBox in VB is different, it shouldn't be any different then to look for RICHEDIT.
[Edited by Serge on 10-20-2000 at 07:25 PM]
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
|