Hi everybody :) , i'm making some Procedure to make Buttons or Edit Controls, everything is fine, except that i can't store the Handler of each one,and i want to use the Handler of each after the proc call, take a look:



CreateButtonOrEdit PROC kbFlag:BYTE,kbType:DWORD,kbID:DWORD,kbText:DWORD,
kbFont:DWORD,HandlerWindow:DWORD,hWndX:DWORD,
kbX:DWORD,kbY:DWORD,kbW:DWORD,kbH:DWORD

LOCAL hFont:DWORD

.CODE

invoke CreateFontIndirect,kbFont
mov hFont,eax

cmp kbFlag,1
jz kbMakeButton

mov eax,ES_AUTOHSCROLL
or eax,WS_CHILD
or eax,WS_VISIBLE
or eax,WS_BORDER
jmp kbMain

kbMakeButton:
mov eax,BS_PUSHBUTTON
or eax,WS_CHILD
or eax,WS_VISIBLE

kbMain:

invoke CreateWindowEx,WS_EX_CLIENTEDGE,kbType,kbText,eax,kbX,kbY,kbW,kbH,HandlerWindow,kbID,hInstance,0
mov hWndX,eax

;###########################
;Heres start the problem , by now the Handler is in eax, and i want to move it to a
;Variable defined in de DATA? section as "hWndEdit1 HWND ?",
;so, the hWndX in a proc call contains the offset of that variable ??, not ??.
;
;I'm calling the Proc like this; the first parameter is TRUE if it's a button or false if it's and Edit.
;invoke CreateButtonOrEdit,TRUE,addr BtnClass,Button22,addr BText22,OFFSET ButtonFont,hWnd,hButton22,485,235,200,25
;
;
;invoke CreateButtonOrEdit,FALSE,addr EdtClass,Edit1,0,OFFSET ButtonFont,hWnd,hEdit1,255,25,200,20

;Any help out there ?? :grin:
;Thanks.... JaiKMw
;###########################


invoke SendMessage,eax,WM_SETFONT,hFont,0

invoke GetWindowLong,hWndX,GWL_EXSTYLE
and eax,not WS_EX_CLIENTEDGE
or eax,WS_EX_STATICEDGE
invoke SetWindowLong,hWndX,GWL_EXSTYLE,eax
invoke SetWindowPos,hWndX,0,0,0,0,0,SWP_NOSIZE or SWP_NOMOVE or SWP_FRAMECHANGED or SWP_NOZORDER or SWP_NOACTIVATE

mov eax,hWndX
ret
CreateButtonOrEdit ENDP
Posted on 2004-04-01 23:21:04 by JaiKMw
;so, the hWndX in a proc call contains the offset of that variable ??, not ??.
Yes. It should.
Handler is in eax, and i want to move it to a
;Variable defined in de DATA? section as "hWndEdit1 HWND ?",
mov  ecx,hWndX

mov [ecx],eax

Raymond
Posted on 2004-04-01 23:40:04 by Raymond
raymaond i was thinking of replying like you did but i think he wants some thing else i think he wants to reuse one process with different variables and store the different handles to some place like this

call:
call createproc,different params everytime
mov hWndX,eax <---- i think he wants the hwndx to be a variable to save the handle everytime
cmp some counter,somevariable
je do some thing else
push anothere set of different params
jmp call

do some thingelse:
nop nop nop
invoke ExitProcess,Null

then i think mov ecx,hwndX
mov ,eax
wont work
isnt it??
Posted on 2004-04-01 23:51:07 by bluffer
Thanks Raymond :), but yes bluffer it doesn't works, it only causes an error, i could use what you wrote like:

invoke CreateButtonOrEdit,x,y,z
;as you see, at the end the handler is in eax so..
mov xHwnd,eax

but i don't want to use too many mov's hWndX's, i know there's a way for moving it into the Proc, I've tried ,eax] but it doesn't work too..., also, what do you thought it wont work :) ???
Posted on 2004-04-02 05:21:18 by JaiKMw
Whenever you assume something.....

When I answered "Yes. It should.", I didn't think I had to go into further details. The following section was your code for calling the procedure:
;invoke CreateButtonOrEdit,TRUE,addr BtnClass,Button22,addr BText22,OFFSET ButtonFont,hWnd,hButton22,485,235,200,25
The hButton22 passed as the parameter would be the current value of that variable (if you are using the MASM syntax). Using the MASM syntax, the address of that variable would need to be stated as ADDR hButton22 and my suggested code would then work for storing the handle.

Your other option is to remove this handle as one of the parameters but declare it as a LOCAL variable in your proc. Then exit the proc with the handle as the return value in EAX and then store it wherever you want.

Note that passing the value of a variable instead of its address would result in a GPF (General Protection Fault) most of the time if you try to write to or read from that value interpreted as an address.

Raymond
Posted on 2004-04-02 09:32:32 by Raymond
:O, yes, :o , i missed that, LOL, thanks :)
Posted on 2004-04-02 17:02:55 by JaiKMw