Let me start out by saying, I am still very new to this world of programming asm (instead of VB).

My problem:

I am trying to have an edit control automatically highlite the text within it when it is clicked on.

I have downloaded and read everything and I managed to come up with:

invoke SendMessage,hEdit2,EM_SETSEL,0,-1

Thing is, I don't know what message to put it under in my WndProc. I've tried my uMsg == WM_KILLFOCUS, WM_NEXTDLGCTL,WM_SETFOCUS and even the WM_COMMAND with my hEdit id (101) no luck.

So basically I need to know what message is given when someone clicks into a textbox (edit control).

I'm sure it's easy, I just can't find it.
Posted on 2001-11-24 02:09:49 by CsnWltr
If you look in the Platform SDK documentation under "Edit Control Notification
Messages" it will state:

"The system sends each request to the edit control's parent window in the
form of a WM_COMMAND message. The message includes the edit control
identifier in the low-order word of the wParam parameter, the handle of
the edit control in the lParam parameter, and an edit control notification
message corresponding to the user's action in the high-order word of the
wParam parameter.

An application should examine each notification message and respond
appropriately. The following table lists each edit control notification
message and the action that generates it."

So we can deduce that when the edit control needs to notify us about something
(e.g. when it recieves input focus) it will do so via WM_COMMAND, with the
appropriate data in the wParam and lParam parameters.

If you look in table it lists EN_SETFOCUS as being "The user has selected this
edit control." -- exactly what we want. Putting it all together we can see
that when the user selects the edit control we will recieve a WM_COMMAND
message in the parent (assigned in CreateWindow() when creating the
edit control) window procedure, the low word of wParam containing our edit
control identifier, the high word of wParam containing the notification
message.

-- somewhere before --
#define MY_EDIT 69

-- parent windows window procedure --
case WM_CREATE:
hedit = CreateWindow ("edit", "Select Me!", WS_VISIBLE | WS_CHILD | ES_WANTRETURN | ES_MULTILINE,
0, 0, 100, 100, hwnd, (HMENU) MY_EDIT, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
return 0;

case WM_COMMAND:
if (LOWORD (wParam) == MY_EDIT && HIWORD (wParam) == EN_SETFOCUS)
SendMessage (hedit, EM_SETSEL, 0, -1);

Windowing and Messaging are very important concepts in Win32 you should
probably spend sometime reading Petzold or http://msdn.microsoft.com/

Cheers,
Boggy
Posted on 2001-11-24 03:47:14 by Boggy Digital
Thanks Boggy.

For some reason I never came across that section before. It was foolish of me not to look up WM_COMMAND.

Now the only problem I have is how to use LOWWORD and HIGHWORD in MASM32. In the meantime I just used the entire hexvalue.

But it doens't really matter that much though because for some reason my "invoke SendMessage,hEdit2,EM_SETSEL,0,-1" won't work when called after clicking in the edit box. It works just fine if I have another button SetFocus to hEdit2 which in turn runs the line stated earilier.
Posted on 2001-11-24 15:29:49 by CsnWltr
eax = value (wParam whatever...)

movzx ebx,ax
shr eax,16

now ebx contains the loword . this hiword in eax is shifted
16 bit to the right so it should contain the
hiword now...

maybe theres a better way to do this...
Posted on 2001-11-24 19:52:19 by _mob