[comp.windows.ms] Hilighting Text in edit fields

pdavid@polyslo.CalPoly.EDU (Paul C. David) (07/04/89)

Just wondering.  Does anyone know how to highlight text
in edit fields, i.e. when the focus is set to it? 
			Thanks, Paul.

-- 
Paul C. David		pdavid@polyslo.CalPoly.EDU
California Polytechic State University, San Luis Obispo
Home of the six-year or 60,000 mile undergraduate degree 

marco@hpmcaa.mcm.hp.com (Marco Dalla-Gasperina) (07/05/89)

>Just wondering.  Does anyone know how to highlight text
>in edit fields, i.e. when the focus is set to it? 
>			Thanks, Paul.
>
>-- 
>Paul C. David		pdavid@polyslo.CalPoly.EDU
>California Polytechic State University, San Luis Obispo
>Home of the six-year or 60,000 mile undergraduate degree 
>----------

hWnd = GetDlgItem(hDlg,nDlgItemNumber);
lResult = SendMessage(hWnd,EM_SETSEL,0,MAKELONG(0,32767));

this will make the entire string black.

No Bugs,
marco

brent@well.UUCP (Brent Southard) (07/06/89)

In article <12265@polyslo.CalPoly.EDU> pdavid@polyslo.CalPoly.EDU (Paul C. David) writes:
>Just wondering.  Does anyone know how to highlight text
>in edit fields, i.e. when the focus is set to it? 

You send the EM_SETSEL message to the edit window to highlight text.  In
order to do that when the window gets the focus, you will have to subclass
the edit window and look for an incoming WM_SETFOCUS message.  If you need
more information on subclassing, try Petzold's book for a pretty good
description.  Subclassing is a necessary technique for doing involved
Windows programming.

	brent
-- 
brent southard  (313) 656-8349   |   oh mona mona
ImageTech Corp  (313) 362-3141   |   you can close your eyes
                                 |   i've got a twelve gauge surprise
usenet:  ...!well!brent          |   waiting for you             -- James Taylor

bturner@hpcvlx.HP.COM (Bill Turner) (07/07/89)

> You send the EM_SETSEL message to the edit window to highlight text.  In
> order to do that when the window gets the focus, you will have to subclass
> the edit window and look for an incoming WM_SETFOCUS message.

Not necessarily -- when the edit field gets the focus, it sends an EN_SETFOCUS
notification to its parent (WM_COMMAND, wParam == edit field ID,
LOWORD(lParam) == EN_SETFOCUS)

--Bill Turner (bturner@hp-pcd.hp.com)
HP Corvallis Information Systems