News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

EnumChildWindows Proc problem

Started by Nilrem, May 24, 2005, 01:49:11 PM

Previous topic - Next topic

Nilrem

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

dougiem

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

Nilrem

Most gracious. I cannot see this documented, how did you know this? I know some languages take care of the mov eax, 1 automatically.

QvasiModo

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.

MichaelW

QuoteEnumChildWindows continues until the last child window is enumerated or the callback function returns FALSE.

MSDN: EnumChildWindows Function

MSDN: Argument Passing and Naming Convetions

eschew obfuscation

Nilrem

Missed it in my reference file. How embarrasing. When people say read everything, I now understand why. 8-D
Thanks everyone. :U 8-)