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 track a TEdit at an OnExit event 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
27-Aug-02
Category
VCL-General
Language
Delphi 2.x
Views
105
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I'm getting a trouble with an special event inside a OnExit event. I need to know 
at OnExit of a TEdit Control, when the user clicks a button such as the Cancel 
button. The user may exit the TEdit just with a correct data or when the Cancel 
Button was clicked. How can I track this?

Answer:

Assuming that "BlockExit" is a global variable or field of your form:
1   
2   procedure TForm1.FormCreate(Sender: TObject);
3   begin
4     BlockExit := false;
5   end;
6   
7   procedure TForm1.Edit1Exit(Sender: TObject);
8   begin
9     BlockExit := (Edit1.Text <> 'OK');
10  end;
11  
12  procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
13  begin
14    if BlockExit then
15    begin
16      Beep;
17      Beep;
18      MessageDlg('Wrong data in Edit1', mtError, [mbOK], -1);
19      Edit1.SetFocus;
20      CanClose := false;
21    end
22    else
23      CanClose := true;
24  end;
25  
26  procedure TForm1.btnCancelClick(Sender: TObject);
27  begin
28    BlockExit := false;
29    Close;
30  end;
31  
32  procedure TForm1.btnOKClick(Sender: TObject);
33  begin
34    Close;
35  end;


			
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