The information in this article applies to:
SUMMARY
Although the concepts of "input focus," "active application," and
"active window" are very closely related, there are differences among
them.
MORE INFORMATION
The following discussion contains detailed definitions of the terms
"input focus," "active window," and "active application," as well as a
demonstration of those differences that you can perform using Windows
Write.
Active ApplicationFor more information on the active application, refer to the documentation for the WM_ACTIVATEAPP message in the "Microsoft Windows Software Development Kit (SDK) Reference, Volume 1." The following is also from "Programmer's Guide to Windows, Second Edition," page 655: FocusFor more information on focus, refer to the documentation for the WM_SETFOCUS and WM_KILLFOCUS messages and for the GetFocus, SetFocus, and EnableWindow functions in the "SDK Reference, Volume 1." The following is from the book Programming Windows, Second Edition by Charles Petzold, published by Microsoft Press, pages 89-90: Focus, Focus, Who's Got the Focus?Petzold also indicates that Windows sends keyboard messages to icons differently than it does to windows with the focus. This difference is noted in the following excerpt from the "Microsoft Windows Software Development Kit Reference, Volume 1," page 4-381: If a window is active but doesn't have the focus (that is, no window has the focus), any key pressed will produce the WM_SYSCHAR, WM_SYSKEYDOWN, or WM_SYSKEYUP message.For more information on the active window, refer to the documentation for the WM_ACTIVATE message and for the GetActiveWindow and SetActiveWindow functions in the "Microsoft Windows Software Development Kit Reference, Volume 1." Demonstration of Differences Between Focus, Active Application, and Active WindowThe following is an experiment you can do that will clarify the differences among active application, active window, and input focus, and show you how the user can specify which attribute is assigned to which window:Open Windows Write and choose Find from the Find menu. You'll now have a pop-up window that is a child of Write. Arrange your screen so that the Write, Find, and Program Manager windows are all on the screen together. If you click in the Program Manager window, both the Write window's and the Find dialog window's caption bars will be set to the inactive color, and the Program Manager window's caption bar will be set to the active color. At this point, Program Manager is the active application; it is also the active window and has the input focus. Click in the Write window; it will become the active application, as well as the active window, and will get the input focus. Click in the Find window; although it is now the active window, it is not the active application (Write is) nor does it have the input focus: the focus is in the Find What box, which is an edit control window that is a child of the Find dialog window, which is itself a pop-up-style window that is a child of Write. (Note that in this discussion the term "child windows" is used in terms of parent-child relationships rather than the child window style WS_CHILD.) At this point, you can move the input focus from box to box within the Find dialog window by using the TAB key (or by clicking with the mouse). There are three or four controls you can move between: Find What, Whole Word, Match Upper/Lowercase, and Find Next (available only if there is some text in the Find What box). Now press ALT+F6. This will make Write the active window instead of Find, and the focus will be set to the Write window as well; this is indicated by the flashing vertical caret. Press ALT+F6 a second time. Find will be the active window again, and the input focus will be set to whichever control it was last set to (Find What, Whole Word, Match Upper/Lowercase, or Find Next). Finally, you can use ALT+TAB to return to the Program Manager, making it the active application, the active window, and the one with the input focus. If you press ALT+TAB again, you will make Write the active application, Find the active window, and set the input focus to one of Find's controls (whichever one last had the focus). Additional query words:
Keywords : kb16bitonly kbSDKPlatform kbGrpUser kbWndw |
Last Reviewed: November 10, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |