Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to prevent a user from closes Windows Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
02-Nov-02
Category
System
Language
Delphi 2.x
Views
76
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Radikal Q3 


When the user closes Windows having our application opened, it is possible that 
occur in a wrong moment (without recording data, in the middle of a process, etc).

Answer:

This can be avoided capturing the message that send Windows to all the applications 
when the user wants to close Windows: the  message WM_QUERYENSESSION
 
To capture the message and to send it to our treatment code of the message:
1   
2        TForm1 = class(TForm)
3        ..........
4          private
5            procedure WMQueryEndSession(var Msg: TWMQueryEndSession); message 
6   WM_QUERYENDSESSION;
7        ..........
8        end; 


Simply...we must add the next line in the Private part of the form:
9   
10      procedure WMQueryEndSession(var Msg: TWMQueryEndSession); message 
11  WM_QUERYENDSESSION; 


and later, in the implementation, we put the treatment code of the message:
12  
13  procedure TForm1.WMQueryEndSession(var Msg: TWMQueryEndSession);
14  begin
15    MessageBox(Handle, 'Cierra antes el programa', nil, MB_OK);
16    Msg.result := 0;
17  end;


If instead of aborting the close of Windows, we want that follows being 
accomplished, enough with which we change the Msg.result:=0 for Msg.result:=1.
 
NOTE: The behavior of the message defers in win98 and WinNT, as soon as watches you the help of the message WM_QUERYENDSESSION.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC