This example uses WinIsThreadActive to verify that the active window belongs to the current thread before querying and enabling the system menu window via WinIsWindowEnabled and WinEnableWindow.

#define INCL_WINWINDOWMGR   /* Window Manager Functions */
#define INCL_WINFRAMEMGR    /* Window Frame Functions   */
#include <os2.h>

HAB   hab;                  /* Anchor-block handle      */
HWND    hwndSysmenu;        /* System menu window       */
HWND    hwnd;               /* Parent window            */
BOOL  fSuccess;             /* Success indicator        */

/* If the active window belongs to the current thread,  */
/* query the enabled status of the system menu          */
if (WinIsThreadActive(hab))
   {
     /* Obtain the handle for the system menu */
     hwndSysmenu = WinWindowFromID(hwnd,FID_SYSMENU);

     /* If the system menu is disabled, enable it */
     if (!WinIsWindowEnabled(hwndSysmenu))
        fSuccess = WinEnableWindow(hwndSysmenu, TRUE);
   }


[Back] [Next]