The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages - More
> Delphi Programming
|
MessageDlg Help
Discuss MessageDlg Help in the Delphi Programming forum on Dev Shed. MessageDlg Help Delphi Programming forum discussing Delphi related topics including Kylix, C++ Builder, and more. Delphi is a high-performance language, originally based on the PASCAL language.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

August 19th, 2004, 01:46 PM
|
|
Contributing User
|
|
Join Date: Jul 2004
Posts: 113

Time spent in forums: 1 Day 7 h 56 m 21 sec
Reputation Power: 9
|
|
|
MessageDlg Help
I am asking too much questions today
Code:
procedure TfrmAbout.FormClose(Sender: TObject; var Action: TCloseAction);
Var
sel: Integer;
begin
MessageDlg('You are about to exit. Are you sure?',mtConfirmation, mbOKCancel, 0);
if sel = mrOK then Close();
end;
what if the user presses cancel? how can I return back to frmabout without any changes?
|

August 19th, 2004, 02:45 PM
|
|
Contributing User
|
|
Join Date: Jan 2004
Location: England
Posts: 952
  
Time spent in forums: 4 Days 23 h 38 m 44 sec
Reputation Power: 13
|
|
Test the value returned by MessageDlg and if it is mrOK, the OK button was clicked.
Code:
if MessageDlg('You are about to exit. Are you sure?',
mtConfirmation, mbOKCancel, 0) = mrOK then
Action := caFree
else
Action := caNone;
|

August 19th, 2004, 04:16 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Your other option is to add code to the OnCloseQuery event instead of the OnClose event.
Code:
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if MessageDlg('You are about to exit. Are you sure?',
mtConfirmation, mbOKCancel, 0) = mrCancel then
CanClose := false;
end;
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|

August 23rd, 2004, 01:48 AM
|
|
Contributing User
|
|
Join Date: Jul 2004
Posts: 113

Time spent in forums: 1 Day 7 h 56 m 21 sec
Reputation Power: 9
|
|
|
thank u both for your help,
now, is there a way to set 'cancel' button as a default option?
|

August 23rd, 2004, 11:45 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
|
Not that I know of, but you can make your own dialog form and make Cancel the default button for that form.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|