Hi All,

After programming in Assembler in DOS for many years, I am making the great leap to Win32 programming. To help me convert I am reading and coding my way through Iczelion's excellent online tutorial documents. I implement my programs in RadASM.

My question today is about handling dialogs in RadASM. I shall explain as best I can, please consider the following code :

invoke CreateWindowEx,NULL,ADDR EditClass,NULL,\
WS_VISIBLE or WS_CHILD or ES_LEFT or ES_MULTILINE or\
ES_AUTOHSCROLL or ES_AUTOVSCROLL,0,\
0,0,0,hWnd,EditID,\
hInstance,NULL
mov hwndEdit,eax
invoke SetFocus,hwndEdit

I have taken this example from tutorial number 11, in this tutorial I learn how to create and use an edit box. I understand this and when I type the code into RadASM my programs will work. What confuses me is the relationship between this code and the dialog designer in RadASM. In RadASM I can use the dialog design thingy. So, I do the following....

1. Create my edit box using the dialog design thingy.

2. Give it a name like IDC_EDT1.

3. Define that in my .inc file .... IDC_EDT equ 1001.

4. Use the dialog in my code. eg :

invoke SendMessage, IDC_EDT1, WM_GETTEXT, MEMSIZE-1, pMemory
invoke SetFocus, IDC_EDT1

my program compiles and runs. My edit box appears on my form but I cannot interact with it. Can anyone suggest where I am going wrong with this?

Many Thanks,

Lightman.
Posted on 2004-10-06 14:17:04 by Lightman
I'm afraid SendMessage (and most other APIs working with windows) are expecting a window handle, a value obtained at runtime on return from some API calls (like CreateWindowEx or DialogBoxParam). You're passing it a user-defined ID.

For the dialog box you're working on you need GetDlgItem, when you pass it the dialog handle (the first parameter of the dialog procedure), and the ID (IDC_EDT1 in your code), you get the control's handle in EAX.

Hope that helps! :)
Posted on 2004-10-06 15:18:25 by QvasiModo
Thanks for that...

So the code would look like this......?


invoke GetDlgItem, hWnd, IDC_EDIT
mov hwndMyEdit, eax
invoke SendMessage, hwndMyEdit, WM_SETTEXT, NULL, ADDR MyMessage

invoke SetFocus, hwndMyEdit

As I get the item, save off eax for later use and then send out my message.

Regards,

Lightman.
Posted on 2004-10-07 03:07:41 by Lightman