Hi, I have an extern funktion and want to Send A Message to it, or get access to an editfeld.

Winmain PROC hDlg:HWND......

...
...

Winmain ENDP


Funktion1 PROC ...

;How to access the Winmain hande ?
;Send a message vor example ?

Funktion1 ENDP

Thanks !
Posted on 2003-03-15 17:06:39 by Forginforcer
You need to have an external function, which the external module will call, passing in the handle to the window or edit box it wants you to manipulate. You then have to store that handle so that you can use it at any time from within your dll.
Posted on 2003-03-15 17:38:45 by sluggy
You can create a global variable to store the editfield's handle after its creation. after this, you can use it from any proc in your module:

.data?
...
ehwnd dd ? ; the global variable

.code
...
...
Winmain PROC hDlg:HWND......
...
...
; supposing you are creating the editfield through a CreateWindow api call:
push ...
call CreateWindow
mov ehwnd, eax ; stores the editfield's handle in the ehwnd variable
...
...
Winmain ENDP


Funktion1 PROC ...
...
...
; now you can send messages to the editfield:
push ...
push ehwnd
call SendMessage
...
...
Funktion1 ENDP

NB: I have omitted error handling to keep the code clean. I suggest you to add it

I hope this can help you :alright:
Posted on 2003-03-15 21:01:30 by SilentFuneral
Thanks for you help.

What I have to do, if I have a button or editfeld as a resource ?
How to store the handle then ?

Greets Red Forginforcer
Posted on 2003-03-16 03:03:02 by Forginforcer
Hi!

If you have a Resource Dialog, you can get the Handle of a Button or whatever with the GetDlgItem-function.

.data?
hButton1 dd ? ;to store handle

.code
push ; specify the ID of the control in your ResourceEditor
push
call GetDlgItem

mov hButton1,eax ; stores the handle in the variable



Now you have the handle of the button from the dialog box
Posted on 2003-03-16 03:40:41 by ChigpA
hm....
How to get the handle in the variable ?

the Id of the button is ID_BUTTONa. How to get the hanlde in the handlevarable ?

Greets Red Forginforcer
Posted on 2003-03-16 03:46:20 by Forginforcer