Hello MASM forum,
I am new to assembly and this forum! I have question about setting focus to a text area and then copying it.
I have Dialog with three text areas. First is user-input, second is output and third is output. I have .if statements setup to handle the button pressing. I originally only had one data field, so I was able to copy it with no problem specifying a certain dig item. However I added a second output and now I want to have it copy the selected string. I'm not very sure how I can specify which text area was selected last.
So far I have this:
.elseif eax==IDC_COPY
.if eax== 1003
invoke SendDlgItemMessage,hWnd,1003,EM_SETSEL,0,-1
invoke SendDlgItemMessage,hWnd,1003,WM_COPY,0,0
.elseif eax==1009
invoke SendDlgItemMessage,hWnd,1009,EM_SETSEL,0,-1
invoke SendDlgItemMessage,hWnd,1009,WM_COPY,0,0
.endif
.elseif eax==IDC_EXIT
invoke SendMessage,hWnd,WM_CLOSE,0,0
I added else/if statement to eax == selected area? However this did not work.
Any help is appreciated!
-fel0n
If you handle WM_SETFOCUS it's wParam contains the handle to the window that lost focus.
or you could use WM_KILLFOCUS and the handle that comes as the first parameter.
I personally would handle KILLFOCUS in the winproc of the edit's and store it in a variable only if it is one of the two edits...
This application sounds tricky to use without a mouse... i would also put a hot key for the button press because getting there by pressing tab will cause issues. Unless all this button is doing is CTRL-A CTRL-C. I like being able to use the keyboard. Just an opinion.
i don't know if i'm right, but you should store the hWnd of the edit controls when you create them
then when the IDC_COPY message is called
match the hWnd of the window proc with the created window handles to find which window was used
on a side note, with the code you posted, if eax==IDC_COPY, it can't be 1003 or 1002, yet you check
immediately after if it is or not
perhaps you shouldn't be checking if eax==1003, instead you should be checking a different value, i don't
know where because i can't see the rest of your code
hope this helps in some way
invoke SendDlgItemMessage,hWnd,1003,WM_GETTEXTL,addr buffer,0
invoke SendDlgItemMessage,hWnd,1009,WM_SETTEXT,addr buff,0
Hi
I use this
.if uMsg==WM_INITDIALOG
invoke GetDlgItem, hWnd,1002
invoke SetFocus,eax
fel0n,
Unless you have written you own word procewssor which I doubt, TEXT AREA means in the Windows context an EDIT CONTROL which is usually a CHILD window of a normal dialog or WNDCLASSEX type window. Create the edit control, get it HANDLE and then you can use the EM_ series of text messages to control the content.