[Harbour] Re: Trap / run routine when MS Windows red X box closed?

Viktor Szakáts harbour.01 at syenar.hu
Tue Mar 2 05:20:55 EST 2010


Hi Saulius,

>> Oh yes, so you are using GTWIN.
>> No, for this GT "Close -> X" button cannot be manipulated.
> 
> It can, through API SetConsoleCtrlHandler(). Handles events:
> CTRL_C_EVENT
> CTRL_BREAK_EVENT
> CTRL_CLOSE_EVENT             <<<===
> CTRL_LOGOFF_EVENT
> CTRL_SHUTDOWN_EVENT

Can you show an example for that using current gtwin.c code?

We're already handling these events, so if doable, it should 
be implemented here:
---
static BOOL WINAPI hb_gt_win_CtrlHandler( DWORD dwCtrlType )
{
   BOOL bHandled;

   HB_TRACE(HB_TR_DEBUG, ("hb_gt_win_CtrlHandler(%lu)", ( HB_ULONG ) dwCtrlType));

   switch( dwCtrlType )
   {
      case CTRL_C_EVENT:
         bHandled = FALSE;
         break;

      case CTRL_CLOSE_EVENT:
      case CTRL_BREAK_EVENT:
         s_bBreak = HB_TRUE;
         bHandled = TRUE;
         break;

      case CTRL_LOGOFF_EVENT:
      case CTRL_SHUTDOWN_EVENT:
      default:
         bHandled = FALSE;
   }

   return bHandled;
}
---

Brgds,
Viktor



More information about the Harbour mailing list