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 February 26th, 2013, 08:17 AM
fatmonk fatmonk is offline
The Monk that is Fat.
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: UK
Posts: 106 fatmonk User rank is Corporal (100 - 500 Reputation Level)fatmonk User rank is Corporal (100 - 500 Reputation Level)fatmonk User rank is Corporal (100 - 500 Reputation Level)fatmonk User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 18 h 45 m 17 sec
Reputation Power: 13
Confirm (or not) TForm Close [lazarus/pascal]

Is there some way to interupt the Close function of a form and pop up a confirmatoin dialog?

When File->Exit is selected from my main form I run a couple of checks to make sure the user has saved any changes they have made in the application. The user is presented with a MessageDLG asking i fthey are sure they want to exit - and the application only closes if they respond mrYes.

That works fine but I'd like to call the same routine when the top right (in Windows) close button is clicked.

I can get the checks and dialog to be called by setting that functoin in the OnClose event for the main TForm, but this does not allow me to cancel the application closing when the user clicks mrNo.

I get the feeling this is either going to be really easy and I'll feel stupid for asking, or it's going to be difficult (for me as a newbie to lazarus and pascal) to implement.

Thanks,

FM

PS I have experience in the past with Borland C++ builder, but am new to the quirks of pascal in lazarus.

Reply With Quote
  #2  
Old February 26th, 2013, 09:01 AM
fatmonk fatmonk is offline
The Monk that is Fat.
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: UK
Posts: 106 fatmonk User rank is Corporal (100 - 500 Reputation Level)fatmonk User rank is Corporal (100 - 500 Reputation Level)fatmonk User rank is Corporal (100 - 500 Reputation Level)fatmonk User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 18 h 45 m 17 sec
Reputation Power: 13
Proving the rule that no matter how long you've been looking, as soon as you post a question on a forum you'll find the answer yourself...

The OnCloseQuery event was staring me in the face... I've used that and set CanClose to true or false depending on the MessageDLG response.

Job done.

-FM

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreDelphi Programming > Confirm (or not) TForm Close [lazarus/pascal]

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