Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

What does cancel property of button do?

Posted on 2011-09-07
10
Medium Priority
?
387 Views
Last Modified: 2012-05-12
What does cancel property of button do?
0
Comment
Question by:Ashok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 101

Expert Comment

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

mlmcc
0
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 2000 total points
ID: 36499902
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
ID: 36499967
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:HubbleFlubble
ID: 36499978
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 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 2000 total points
ID: 36499983
it's b
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 36499992
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
ID: 36499997
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 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 2000 total points
ID: 36500001
no, this is a misdeception

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

Expert Comment

by:Geert Gruwez
ID: 36500004
verified ?
or from experience :)
0
 
LVL 13

Author Comment

by:Ashok
ID: 36500017
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

719 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