I am having problems setting the text of an edit control. I click a button and the browse for folder pops up and when I select a folder, I want to put the path into an edit control. Seems I am missing something here! Maybe I have to handle some command send to my main window? Not sure what though.

As a test, I tried setting the text of an edit control with a string in response to WM_CREATE. I can add text with either
SendMessage or SetWindowText, which leads me to believe that I must handle some other message and set the text from there because I cannot add the text in respone to the button click in WM_COMMAND.?

LOCAL buffer1[128]:BYTE ; This should be MAX_PATH right?
; Create Text Boxes
invoke CreateControl,
mov hEdit1, eax
;This works here:
;invoke SetWindowText,hEdit1, ADDR TestText
;and this:
;invoke SendMessage,hEdit1,WM_SETTEXT,NULL,ADDR TestText

;But they don't work here:
.elseif uMsg == WM_COMMAND
.if wParam == 6
mov buffer1[0], 0
invoke BrowseForFolder,hWnd,ADDR buffer1,ADDR tstring,ADDR bstring
.if buffer1[0] != 0
;I can call mesagebox with the correct buffer1 text here.
;invoke SendMessage,hEdit1,WM_SETTEXT,NULL,ADDR buffer1
invoke SetWindowText,hEdit1,ADDR buffer1

What am I missing?
Posted on 2002-06-26 21:24:16 by Gunner
dude, it looks to me like your SetWindowText is pretty fine, but the problem appears to be that you are using a function that is part of an interface, not an API call. Check out the doco for that function here. Unless i am way off course here, it looks to me like you should be expecting an object pointer returned, not a string....
Posted on 2002-06-26 21:58:38 by sluggy
hEdit is a LOCAL and therefore gets trashed when WM_CREATE returns!
Posted on 2002-06-26 23:08:19 by gfalen

hEdit is a LOCAL and therefore gets trashed when WM_CREATE returns!

Set your hEdit in .data? to make it global.
Posted on 2002-06-27 00:39:44 by bazik
!?!? It works now that I put all my hEdits(x) in .data? Hmmm I guess I still have to catch on and get the VB thinking out of my head! I put the hEdits local so they won't be global... I tried to keep them "in scope" but I guess that doesn't work like it does in VB huh? Well anyway, I am still here! Sticking with Assembly! I look at my VB code now and it doesn't look right to me! I am studying way too much Assembly code ;) The VB app I am converting is 34kb (code only, not including the runtimes) and the Asm version is 10kb with the version resource ( do I really have to conform to MS standards and add the version resource?) Well, anyway, thank you everyone!

CreateControl is a proc I created because I need to create 5 edit and button controls and is easier to read than with 10 CreateWindows....
So, if I need a variable, don't do LOCAL because they are on the stack and *will* get thrashed? but put in .data?... Friend is printing out 15 pages a day for me of the MASM programmers guide so I don't have everything just yet...
Posted on 2002-06-27 01:11:15 by Gunner