What does cancel property of button do?

What does cancel property of button do?
LVL 13
AshokAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Geert GruwezConnect With a Mentor Oracle dbaCommented:
this property is mostly used with modal forms

for the ok button, the property Default is set to True
for the cancel button, the property Cancel is set to True

This is allows someone using Enter or Esc (resp Ok button, Cancel button) to close the modal form

you get the modal result of a form (which button was pressed)
case Form.ShowModal of
  mrCancel: ShowMessage('Cancel was pressed');
  mrOk: ShowMessage('Ok was pressed');
else
  ShowMessage('Some other values');
end;
0
 
mlmccCommented:
If it is like the VB property, it allows you to cancel the action if you set it to TRUE

mlmcc
0
 
AshokAuthor Commented:
Esc key calls OnClick event handler of the button

Following are choices to pick the correct answer from
a) It automatically displays Cancel as the Button caption
b) It determines if the button's OnClick event handler is called when the Escape key <Esc> is pressed on the keyboard
c) It calls the parent forms' OnClose event
d) It causes popup menu to be displayed when the button is clicked which permits the user to select Cancel

d is incorrect answer.

In this test, it allows to select only one answer.  Are there more than 1 correct answer for above?

Thanks,
Ashok
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
HubbleFlubbleCommented:
Please note that to give a ModalResult back from ShowModal on that form, you have to set the ModalResult property of the button to mrCancel.
0
 
Geert GruwezConnect With a Mentor Oracle dbaCommented:
it's b
0
 
Geert GruwezOracle dbaCommented:
just check the delphi code for the keystroke:
procedure TCustomButton.CMDialogKey(var Message: TCMDialogKey);
begin
  with Message do
    if  (((CharCode = VK_RETURN) and FActive) or
      ((CharCode = VK_ESCAPE) and FCancel)) and
      (KeyDataToShiftState(Message.KeyData) = []) and CanFocus then
    begin
      Click;
      Result := 1;
    end else
      inherited;
end;

Open in new window

0
 
AshokAuthor Commented:
Geert_Gruwez,

I thought so.

What about a?
When we use Cancel property, does it by default also change Caption to "Cancel"?

This can be only verified if you have Delphi installed on your computer.

Thanks,
Ashok
0
 
Geert GruwezConnect With a Mentor Oracle dbaCommented:
no, this is a misdeception

this happens when you change the kind property to bkCancel of a TBitBtn
0
 
Geert GruwezOracle dbaCommented:
verified ?
or from experience :)
0
 
AshokAuthor Commented:
I have not verified as I have Window 7 64 bit and no Delphi installed.

But from experience, as far as I remember.
I might be wrong.

Ashok
0
All Courses

From novice to tech pro — start learning today.