Aloha
I am trying to make a program that enumerates all the windows and child windows and puts all of them in a listbox. I have had success in the past when I made a program that just enumerates all top-level windows. This time, I want child windows too. I can't seem to get it to work. Have a look at this code:


invoke EnumWindows,ADDR EnumWndProc,0 ;Enumerate
.........

EnumWndProc proc Handle:DWORD
invoke EnumProc,Handle
invoke EnumChildWindows,Handle,ADDR EnumChildProc,0
mov eax,Handle
ret
EnumWndProc endp

EnumChildProc proc Handle:DWORD
invoke EnumProc,Handle
mov eax,Handle
ret
EnumChildProc endp

EnumProc proc Handle:DWORD
LOCAL Buffer[256]:BYTE
LOCAL WndClass[48]:BYTE
LOCAL WndText[48]:BYTE

inc Looper
invoke GetClassName,Handle,ADDR WndClass,48
invoke GetWindowText,Handle,ADDR WndText,48
invoke wsprintf,ADDR Buffer,ADDR CtlStr,Looper,Handle,ADDR WndClass,ADDR WndText
invoke SendDlgItemMessage,hWnd,600,LB_ADDSTRING,0,ADDR Buffer

ret
EnumProc endp

You experienced coders are probably going to tell me that there's forty things wrong this code, but I am too new to MASM (about 3 months) to figure out what's wrong. Please help!
Posted on 2004-09-25 10:21:01 by yo|dude|mon
Should be something like


EnumWndProc proc Handle:DWORD, lparam:DWORD
invoke EnumProc,Handle
invoke EnumChildWindows,Handle,ADDR EnumChildProc,0
mov eax,Handle
ret
EnumWndProc endp

EnumChildProc proc Handle:DWORD, lparam:DWORD
invoke EnumProc,Handle
mov eax,Handle
ret
EnumChildProc endp
...
Posted on 2004-09-25 10:36:25 by roticv
I just didn't think I needed to add in the lParam thing (I didn't use it in my previous enumeration project). Is it absolutely necessary?
Posted on 2004-09-25 10:53:13 by yo|dude|mon
I just tried it and it works fine now, thanks a lot!

Final remarks: Since usually nothing is passed thru the lParam, I didn't think I had to use it. I know now that is false.
Posted on 2004-09-25 10:56:40 by yo|dude|mon
I just tried it and it works fine now, thanks a lot!

Final remarks: Since usually nothing is passed thru the lParam, I didn't think I had to use it. I know now that is false.

As a little sidenote, this is valid for ALL callback procedures. Make sure that you always have the same parameters in the same order as Windows expects, and using the same calling convention too. The OS just can't read your source and guess! ;)
Posted on 2004-09-25 11:12:00 by QvasiModo