This example shows how the WinQueryActiveWindow can be used to find the active window.
#define INCL_WINWINDOWMGR #include <OS2.H> HWND hwndActive; hwndActive = WinQueryActiveWindow(HWND_DESKTOP)