Deactivate ESC Key in a form

RI0207RI0207 Member Posts: 17
Hi All
How to deactivate ESC Key at a Form. There's some checking on the credit Limit in this form once the user Press OK.. But users can bypass this checking by Pressing ESC Key/ by close (X) the form which i should not allow... How to deactivate ESC key in the form

Awaits the reply...

Answers

  • garakgarak Member Posts: 3,263
    There are two ways if found, so fast as i can, in my brain.

    first: call the the Form in Lookupmode from other form like this
    BoolVariable := false;
    
    while not BoolVar do begin
      BoolVar := form.runmodal(62034) = Action::LookupOK;
    end;
    

    Other way is programming in the Form "YourFormIdOrName" self.
    Name	DataType	Subtype	Length
    VarAction	Action		
    
    Form - OnOpenForm()
    clear(VarAction);
    
    Form - OnQueryCloseForm() : Boolean
    if (CurrForm.LOOKUPMODE = CurrForm.LOOKUPMODE::YES) then begin
      if (VarAction = ACTION::LookupOK) then //or (VarAction = ACTION::LookupCancel) then
        EXIT(true);
    end;
    message('You must press OK); // or Cancel');
    exit(false);
    
    //behind OK Button
    <Control12> - OnPush()
    VarAction := ACTION::LookupOK;
    
    //behind Cancel button
    <Control13> - OnPush()
    VarAction := ACTION::LookupCancel;
    

    BUT NOTE:
    ESC IS LIKE LOOKUPCANCEL :!:

    Regards
    Do you make it right, it works too!
  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Use Form - OnQueryCloseForm() : Boolean.

    But be careful. If you don't create at least one exit condition, you won't be able to exit the form and NAV. You'll have to exit NAV by terminating the process.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • RI0207RI0207 Member Posts: 17
    Thanks a LOT Garak....It did works for me with very minor modifications.

    I couldn't compile my form (it was closing, asking want to send error report etc) after i put your coding as it is...then i made some small changes as per below and got what i want...


    IF (Vact = ACTION::LookupOK) THEN
    EXIT(TRUE) ELSE
    BEGIN
    MESSAGE('You must press OK');
    EXIT(FALSE);
    END;

    I took out the
    IF(CurrForm.LOOKUPMODE = CurrForm.LOOKUPMODE::YES) , other parts all reamin same...

    Thanks a million... =D>
  • garakgarak Member Posts: 3,263
    Please, you're welcome.
    Do you make it right, it works too!
Sign In or Register to comment.