This shows you the differences between two versions of the page.
finding_20which_20window_20has_20input_20focus [2018/03/31 13:19] 127.0.0.1 external edit |
finding_20which_20window_20has_20input_20focus [2018/04/16 10:54] (current) richardrussell Added syntax highlighting |
||
---|---|---|---|
Line 1: | Line 1: | ||
=====Finding which window has input focus===== | =====Finding which window has input focus===== | ||
- | //by Richard Russell, April 2010//\\ \\ The **WINLIB5** (and **WINLIB5A**) libaries contain the [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#setfocus|PROC_setfocus]] routine which allows you to set the input focus to a specified child window (or the main output window). However, there is no related function to return the handle of the window which currently has input focus.\\ \\ The code below implements just such a function. It returns the handle of the child window (or main output window) which currently has input focus. If none of the windows 'owned' by your program have input focus, the function returns zero:\\ | + | //by Richard Russell, April 2010//\\ \\ The **WINLIB5** (and **WINLIB5A**) libaries contain the [[http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#setfocus|PROC_setfocus]] routine which allows you to set the input focus to a specified child window (or the main output window). However, there is no related function to return the handle of the window which currently has input focus.\\ \\ The code below implements just such a function. It returns the handle of the child window (or main output window) which currently has input focus. If none of the windows 'owned' by your program have input focus, the function returns zero: |
+ | |||
+ | <code bb4w> | ||
DEF FN_getfocus | DEF FN_getfocus | ||
LOCAL H%, O%, W% | LOCAL H%, O%, W% | ||
Line 10: | Line 12: | ||
SYS "AttachThreadInput", O%, W%, FALSE | SYS "AttachThreadInput", O%, W%, FALSE | ||
= H% | = H% | ||
+ | </code> |