Delphi Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreDelphi Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 19th, 2004, 01:46 PM
Ruh Ruh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 113 Ruh User rank is Private First Class (20 - 50 Reputation Level)Ruh User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 7 h 56 m 21 sec
Reputation Power: 9
Send a message via MSN to Ruh
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?

Reply With Quote
  #2  
Old August 19th, 2004, 02:45 PM
rossM rossM is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: England
Posts: 952 rossM User rank is Corporal (100 - 500 Reputation Level)rossM User rank is Corporal (100 - 500 Reputation Level)rossM User rank is Corporal (100 - 500 Reputation Level)rossM User rank is Corporal (100 - 500 Reputation Level) 
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;

Reply With Quote
  #3  
Old August 19th, 2004, 04:16 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,390 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 22 h 32 m 40 sec
Reputation Power: 4080
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

Reply With Quote
  #4  
Old August 23rd, 2004, 01:48 AM
Ruh Ruh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 113 Ruh User rank is Private First Class (20 - 50 Reputation Level)Ruh User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 7 h 56 m 21 sec
Reputation Power: 9
Send a message via MSN to Ruh
thank u both for your help,

now, is there a way to set 'cancel' button as a default option?

Reply With Quote
  #5  
Old August 23rd, 2004, 11:45 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,390 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 1 Day 22 h 32 m 40 sec
Reputation Power: 4080
Not that I know of, but you can make your own dialog form and make Cancel the default button for that form.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > MessageDlg Help

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap