The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Nilrem on May 24, 2005, 01:49:11 PM

Title: EnumChildWindows Proc problem
Post by: Nilrem on May 24, 2005, 01:49:11 PM
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
Title: Re: EnumChildWindows Proc problem
Post by: dougiem on May 24, 2005, 05:40:36 PM
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
Title: Re: EnumChildWindows Proc problem
Post by: Nilrem on May 24, 2005, 09:46:51 PM
Most gracious. I cannot see this documented, how did you know this? I know some languages take care of the mov eax, 1 automatically.
Title: Re: EnumChildWindows Proc problem
Post by: QvasiModo on May 24, 2005, 10:54:18 PM
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.
Title: Re: EnumChildWindows Proc problem
Post by: MichaelW on May 24, 2005, 11:11:14 PM
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)

Title: Re: EnumChildWindows Proc problem
Post by: Nilrem on May 25, 2005, 05:41:57 PM
Missed it in my reference file. How embarrasing. When people say read everything, I now understand why. 8-D
Thanks everyone. :U 8-)