OK, I know I've seen this addressed on this board before, but I can't seem to find it. What I'm looking for is a way to detect when the EDITTEXT control on my dialog box loses focus. As I understand it, the WM_KILLFOCUS message is sent to the window before it loses the focus. Is this message sent to the edit-control itself rather than the dialog box? How would I go about intercepting this? I suppose I could just call GetFocus during each iteration of the message loop, but that seems kind of cheesy. Any help/explanation/clarification would be appreciated.
Posted on 2001-03-13 06:05:00 by Q
There are a couple of things you can do, but first I'll explain focus.... When a window gets focus, it is sent WM_SETFOCUS, ther wParam is the handle of the window which lost focus. When a window loses focus it gets a WM_KILLFOCUS and the wParam is the handle of the window which is going to get it. I'll warn you now, playing with the focus, I have found, rapidly turns into a nightmare, I've rarely seen a program which can work properly once the WM_KILLFOCUS and WM_SETFOCUS have been intercepted, and things have been done. I always find another way to do the processing required. anyway, the best thing you can do is subclass the window, this means creating a WNDPROC to handle your edit control, everything except WM_KILLFOCUS should be passed onto the original EditProc, you can then do you little bit of extra processing, and pass that on also. If you need an explanation on subclassing then take a look at the tutorials, it's pretty easy really (honest). Umbongo
Posted on 2001-03-13 08:42:00 by umbongo