Ok, when debugging this it only enumerates one of the child windows, I know this because when it comares the classname it only compares it once when I know there are more child windows etc.
Here is my code.
.data?
hInstance dd ?
handle dd ?
beenclicked dd ?
Pixel dd ?
hdcontext dd ?
hwndname HWND ?
ChildHandle HWND ?
hwndChildApp HWND ?
position dd ?
ClassNameBuffer dd ? ; Place to store class name of child window
;#########################################################################
.data
click_crd POINT <?>
AppletClassName db "MSAWT_Comp_Class",0 ; Applet to find
;#########################################################################
invoke EnumChildWindows, hwndname, ADDR WndEnumChild, NULL
By the way I already have the correct handle of the parent.
WndEnumChild Proc hwndChild:DWORD,lParam:DWORD
mov lParam, NULL
invoke GetClassName, hwndChild, ADDR ClassNameBuffer, 50 ; Get the class name, store it ClassNameBuffer
invoke strcmp, ADDR ClassNameBuffer, ADDR AppletClassName, 16 ; Check to see if this is the right child window
test eax,eax
je @f
invoke szCmp, ADDR hwndChild, ADDR hwndname ; Already got the handle?
test eax, eax
jnz @f
push hwndChild ; Push it
pop hwndChildApp ; Pop it back here, making hwndname == ChildHandle
@@:
invoke RtlZeroMemory, OFFSET ClassNameBuffer, SIZEOF ClassNameBuffer
ret
WndEnumChild endp
Hope this helps.
dougiem
EnumChildWindowsB proc hWin:dword,lParam:dword
local className [21]:byte
invoke GetClassName,hWin,addr className,21
invoke lstrcmpi,addr className,addr MatchClass
cmp eax,0
jne,@F
; match found here
@@: mov eax,1 ; must return non zero to keep searching
ret
EnumChildWindowsB endp
Most gracious. I cannot see this documented, how did you know this? I know some languages take care of the mov eax, 1 automatically.
Hi :)
The return value goes in EAX, as defined in the winapi calling convention. Check out MSDN to see what return values are expected from callback functions, and you can also search the board to find out more about calling conventions.
QuoteEnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE.
MSDN: EnumChildWindows Function (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/windows/windowreference/windowfunctions/enumchildwindows.asp)
MSDN: Argument Passing and Naming Convetions (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vccelng4/html/elgrfArgumentPassingandNamingConventions.asp)
Missed it in my reference file. How embarrasing. When people say read everything, I now understand why. 8-D
Thanks everyone. :U 8-)