FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Dialog closing via Alt-F4 or X button
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Dialog closing via Alt-F4 or X button
Posted: Thu Apr 24, 2014 08:32 AM

Guys:

How can I detect that the user closed a dialog via the Alt-F4 or pressing the ESC key ? Thank you.

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Dialog closing via Alt-F4 or X button
Posted: Thu Apr 24, 2014 12:50 PM

Hunter,

use VALID clause.

EMG

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Dialog closing via Alt-F4 or X button
Posted: Thu Apr 24, 2014 01:07 PM
Hunter

I usually turn off the ESC key on my dialogs with this valid clause :
Code (fw): Select all Collapse
VALID(!GETKEYSTATE( 27 ))


As for ALT-F4, ( as Enrico mentions ) that is the same as closing with the X and you can trap that on the Windows with Valid ..
Code (fw): Select all Collapse
Local lOk1


  ACTIVATE DIALOG oGrps NOWAIT ;  // It has to be NonModal --> NOWAIT clause
           ON INIT oGrps:Move(0,0);
           ON PAINT (PalBmpDraw( hDC, 0, 0, oBmp:hBitmap ));
           VALID (!GETKEYSTATE( 27 ))  // do not allow esc key here

ACTIVATE WINDOW oWndChild ;
   ON INIT (  ;
           oWndChild:bResized := {|| oGrps:SetSize( oWndChild:nWidth, oWndChild:nHeight, .t. ) }, ;
           oGrps:ReFresh());
           VALID ( IIF( !lOk1, ExitPgm( .T.,@lOk1,oRsUtil,oBmp,oFontB ) , .F. )) // traps alt f4 and close with X


Rick Lipkin
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM
Re: Dialog closing via Alt-F4 or X button
Posted: Thu Apr 24, 2014 06:46 PM

Enrico, Rick:

Thank you very much ! Worked perfectly.

Continue the discussion