subcalls.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
KbdGetFocus (1.2)
Overview                                            Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_KBD
 
USHORT KbdGetFocus(fWait, hkbd)
USHORT fWait;    /* wait/no-wait flag */
HKBD hkbd;       /* keyboard handle   */
 
The KbdGetFocus function retrieves the focus for the specified logical
keyboard. The focus determines which logical keyboard receives keystrokes
from the physical keyboard. A logical keyboard cannot receive keystrokes
unless it has the focus.
 
A process can retrieve the focus at any time, but it must wait if the focus
is already being used by another process or thread. If a process has the
focus, another process cannot receive the focus until the original process
frees it by using the KbdFreeFocus function. If more than one process is
waiting for the focus, MS OS/2 chooses which one receives the focus.
 
An application must set the focus to an opened keyboard handle before
calling functions such as KbdCharIn.
 
Parameter  Description
────────────────────────────────────────────────────────────────────────────
 
fWait      Specifies whether to wait for the focus to become available. If
           this parameter is IO_WAIT, the function waits for the focus. If
           the parameter is IO_NOWAIT, the function returns immediately
           whether or not it retrieved the focus.
 
hkbd       Identifies the logical keyboard that receives the focus. The
           handle must have been created previously by using the KbdOpen
           function.
 
Return Value
 
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be one of the following:
 
     ERROR_KBD_FOCUS_ALREADY_ACTIVE
     ERROR_KBD_INVALID_HANDLE
     ERROR_KBD_UNABLE_TO_FOCUS
 
Example
 
This example opens a logical keyboard and calls KbdGetFocus to retrieve the
focus for the opened keyboard. Once the KbdFreeFocus function is called, the
focus goes to any process that is waiting for it by calling KbdGetFocus. If
no process is waiting, MS OS/2 uses the default keyboard:
 
HKBD hkbd;
KbdOpen(&hkbd);
KbdGetFocus(IO_WAIT, hkbd);  /* retrieves focus of logical keyboard */
    .
    .
    .
KbdFreeFocus(hkbd);          /* frees the focus                     */
 
See Also
 
KbdCharIn, KbdFreeFocus, KbdOpen