This example uses WinFocusChange to change the focus to the selected window, using the handle returned by WinQueryFocus.
#define INCL_WININPUT /* Window Input Functions */ #include <os2.h> HWND hwndNewFocus; /* Handle of new focus window */ BOOL fSuccess; /* success indicator */ MPARAM mpParam1; /* Parameter 1 (select boolean) */ case WM_SETSELECTION: /* if window is being selected, change focus to the window */ if (SHORTFROMMP(mpParam1)) { if ((hwndNewFocus = WinQueryFocus(HWND_DESKTOP)) != 0L) fSuccess = WinFocusChange(HWND_DESKTOP, hwndNewFocus, 0L); }