Solved

What does cancel property of button do?

Posted on 2011-09-07
10
371 Views
Last Modified: 2012-05-12
What does cancel property of button do?
0
Comment
Question by:Ashok
10 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
If it is like the VB property, it allows you to cancel the action if you set it to TRUE

mlmcc
0
 
LVL 36

Accepted Solution

by:
Geert Gruwez earned 500 total points
Comment Utility
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
 
LVL 13

Author Comment

by:Ashok
Comment Utility
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
 

Expert Comment

by:HubbleFlubble
Comment Utility
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
 
LVL 36

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 500 total points
Comment Utility
it's b
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
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
 
LVL 13

Author Comment

by:Ashok
Comment Utility
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
 
LVL 36

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 500 total points
Comment Utility
no, this is a misdeception

this happens when you change the kind property to bkCancel of a TBitBtn
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
verified ?
or from experience :)
0
 
LVL 13

Author Comment

by:Ashok
Comment Utility
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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now