How to prevent quit when ESC in MENU

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

How to prevent quit when ESC in MENU

#1 Post by alepap »

Hi,

Here is a simple menu. I would like to prevent quitting the application when ESC is pressed. Instead, I would like to have the equivalent of ALT-F on the last ESC. Now, the last ESC quits the application.

Thanks,

Alexandre

Code: Select all

#INCLUDE "adsdbe.CH"
#include "AppEvent.ch"
#include "Dmlb.ch"
#include "FileIO.ch"
#INCLUDE "xbp.ch"
#INCLUDE "inkey.CH"
#INCLUDE "dccolor.CH"
#INCLUDE "dcdialog.CH"
#include "Directry.ch"
#include "os.ch"
#include "Dmlb.ch"
#include "DLL.CH"

MEMVAR dCCOLOR
MEMVAR oMainWindow

*******************************************************************************
FUNCTION Main()

   LOCAL Getlist[0], GetOptions, ;
         oMenuBar, oMenuFiles, oMenuConfig, oMenuHelp
         
   PUBLIC pPath := DC_CurPath()
   PUBLIC oMainWindow

   DCMENUBAR oMenuBar

      DCSUBMENU oMenuFiles PROMPT 'Files' PARENT oMenuBar

         DCMENUITEM 'Sales' PARENT oMenuFiles ;
            WHEN {||Empty(oMainWindow:drawingArea:childList())} ;
            ACTION {|o|o:=Thread():new(),o:Start({||sGUI_SAL()})} // TRANSACTIONS: SALES QUOTE ...

         DCMENUITEM 'Customers' PARENT oMenuFiles ;
            WHEN {||Empty(oMainWindow:drawingArea:childList())} ;
            ACTION {|o|o:=Thread():new(),o:Start({||sGUI_CUS()})} // CUSTOMER

         DCMENUITEM 'Quit' PARENT oMenuFiles ;
            ACTION {|o|o:=Thread():new(),o:Start({||sGUI_QUIT()})} // QUIT
            
      DCSUBMENU oMenuConfig PROMPT 'Configuration' PARENT oMenuBar

         DCMENUITEM 'Transaction Date' PARENT oMenuConfig ;
            WHEN {||Empty(oMainWindow:drawingArea:childList())} ;
            ACTION {|o|o:=Thread():new(),o:Start({||sGUI_TRADAT()})} // SET DATE AUTORIZED

         DCMENUITEM 'Currency' PARENT oMenuConfig ;
            WHEN {||Empty(oMainWindow:drawingArea:childList())} ;
            ACTION {|o|o:=Thread():new(),o:Start({||sGUI_CUR()})} // SET ALL CURRENCYS


      DCSUBMENU oMenuHelp PROMPT 'Help' PARENT oMenuBar

         DCMENUITEM 'Manual' PARENT oMenuHelp ;
            WHEN {||Empty(oMainWindow:drawingArea:childList())} ;
            ACTION {|o|o:=Thread():new(),o:Start({||sGUI_MANUAL()})} // 

         DCMENUITEM 'About' PARENT oMenuHelp ;
            WHEN {||Empty(oMainWindow:drawingArea:childList())} ;
            ACTION {|o|o:=Thread():new(),o:Start({||sGUI_ABOUT()})} // 

   DCGETOPTIONS WINDOWWIDTH 1100 WINDOWHEIGHT 650 ;

   DCREAD GUI TITLE 'SEGOVI' PARENT @oMainWindow  ;
      OPTIONS GetOptions ;
      EVAL {|o|o:setFrameState(XBPDLG_FRAMESTAT_MAXIMIZED)}


RETURN nil
********************************************************************************
PROC appsys ; RETURN
********************************************************************************
FUNCTION SalesReport()

  DCMSGBOX 'In Sales Report'

RETURN nil
********************************************************************************
FUNCTION sGUI_SAL()

RETURN nil
********************************************************************************
FUNCTION sGUI_CUS()

RETURN nil
********************************************************************************
FUNCTION sGUI_QUIT()

   QUIT

RETURN nil
********************************************************************************
FUNCTION sGUI_TRADAT ; RETURN nil 
FUNCTION sGUI_CUR() ; RETURN nil 

FUNCTION sGUI_MANUAL() ; RETURN nil 
FUNCTION sGUI_ABOUT() ; RETURN nil 


User avatar
Tom
Posts: 1165
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: How to prevent quit when ESC in MENU

#2 Post by Tom »

Code: Select all

DCGETOPTIONS ... NOESCAPEKEY
Edit:

Change this:

Code: Select all

 DCMENUITEM 'Quit' PARENT oMenuFiles ;
            ACTION {|o|o:=Thread():new(),o:Start({||sGUI_QUIT()})} // QUIT
to this:

Code: Select all

 DCMENUITEM 'Quit' PARENT oMenuFiles ;
            ACTION {||sGUI_QUIT()} ACCELKEY xbeK_ALT_F // QUIT
There's no need to start a thread for quitting the app.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

Re: How to prevent quit when ESC in MENU

#3 Post by alepap »

Thank you Tom.

User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

Re: How to prevent quit when ESC in MENU

#4 Post by alepap »

NOESCAPEKEY works fine. It will not quit the application.

Is it possible to show the File menu if ESC is pressed in this context.

step1
the menu is showing the submenu config.
User hits ESC.

step2
the menu show File Config Help (the menubar only)
User hits ESC

step3
At this point only the MENUBAR is showed.
On ESC, I want to show the submenu File

Thank you,


Alexandre

User avatar
rdonnay
Site Admin
Posts: 4722
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: How to prevent quit when ESC in MENU

#5 Post by rdonnay »

There is very little control you have over the menu system in Windows.

Almost every Xbase++ class accepts the posting of an event, except XbpMenu and XbpMenuBar.

Windows requires that the user press and release the ALT key, then press the ENTER key.
The eXpress train is coming - and it has more cars.

User avatar
alepap
Posts: 94
Joined: Tue Jul 28, 2015 5:15 am

Re: How to prevent quit when ESC in MENU

#6 Post by alepap »

Ok, very well, I will get use to it. The main problem was the ESC that quits.
Perfect!

Choo choo !!!

Post Reply