The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: oex on February 22, 2012, 11:52:13 PM

Title: Focus
Post by: oex on February 22, 2012, 11:52:13 PM
I've just started playing with windows controls.... I added a text box and that seems simple enough but what is the proper way to kill focus?

So basically like a webpage I want to remove focus from a text field when clicking on the main page (try with the search box on this page.... click in it then click the page background)

I'm assuming from some quick searches it has something to do with the WM_KILLFOCUS message? But I'm not sure if I have to set some property of the main window or of the control itself?

Sorry guys a stupid query I know but in the past I have coded only html page or command prompt interfaces except in VB which did it all for me :lol

Should I put:
invoke SetFocus, hWnd

In the wndproc WM_LBUTTONDOWN?
Title: Re: Focus
Post by: dedndave on February 23, 2012, 12:07:46 AM
the WM_SETFOCUS and WM_KILLFOCUS messages are not normally sent to a window "manually"
they are used to tell you when you have focus, or are about to loose it

instead, use the SetFocus function to set the focus to the main window
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646312%28v=vs.85%29.aspx
it will send messages to the window that will loose focus and the one that will get it - and change focus, of course   :P
Title: Re: Focus
Post by: oex on February 23, 2012, 12:10:42 AM
OK good I think I got this, ty