Newsgroups: comp.windows.ms.programmer
Path: utzoo!utgpu!watserv1!watmath!hyper.hyper.com!bonneau
From: bonneau@hyper.hyper.com (Paul Bonneau)
Subject: Re: Sensing focus in a dialog box
Message-ID: <1991Jun28.180952.6556@hyper.hyper.com>
Reply-To: bonneau@hyper.UUCP (Paul Bonneau,,)
Organization: HyperCube Inc.
References: <1991Jun25.210210.3046@beaver.cs.washington.edu> <1132@venice.SEDD.TRW.COM>
Date: Fri, 28 Jun 1991 18:09:52 GMT

In article <1132@venice.SEDD.TRW.COM> press@venice.sedd.trw.com (Barry Press) writes:
>In article <1991Jun25.210210.3046@beaver.cs.washington.edu> goble@cs.washington.edu (Brian Goble) writes:
>>I have a dialog box with a bunch of edit windows (single-line).  
>>When the user enters info into the first edit box and then tabs to
>>the next edit box I want to know that something is in that first
>>edit box and use it to load in some other info.
>
>You should look at the messages related to change of selection in the 
>dialog box.  If I recall right, it's EN_SELCHANGE, or something like that.
>When you get it, then you can do whatever.  The actual message you get is
>the control's ID (forgive me if this is not quite right; I'm doing it from
>memory) with  the notification message in a parameter.  Or maybe it's
>WM_COMMAND with the ID in wParam and the notification in lParam.  In any
>event, it's the standard notification message, and the selection change
>notification is the ticket.
>
The EN_CHANGE message is used to notify the owner that the
contents of an EditItem have been changed.  If a user is
typing away, it will be send with *every* keystroke.

I think the original question was how to detect that the
contents have changed after the focus has left the edit.  It
can be done with the following code fragment (put it in your
DialogProc):

if (message == WM_COMMAND && wParam == idEditInQuestion)
	switch (HIWORD(lParam))
		{
	default:
		break;

	case EN_SETFOCUS:
		SendMessage(LOWORD(lParam), EM_SETMODIFY, 0, 0L);
		break;

	case EN_KILLFOCUS:
		if ((BOOL)SendMessage(LOWORD(lParam), EM_GETMODIFY, 0, 0L))
			{
			/* Do whatever updates here. */
			}
		break;
		}

cheers - Paul Bonneau.
