[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to detect form chansges?

Posted on 2000-02-20
6
Medium Priority
?
216 Views
Last Modified: 2012-06-21
Hello,

I have many TEdit and TDBCombo components on my form. Say I want to
detect (on form close) whether any of them were changed (not just
clicked), what would be the proper way to do this?

Thank you
Fatima
0
Comment
Question by:ffelaar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2539492
well if you dont want to use normal onchange event and only want to know on form close then maybe you can use a ini file to set whatever it is that you are doing when the components change.
on formcreate read the ini to set the components states etc and write states back to ini on form close.

if need example code just ask.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 2539518
yup, think this is the only way to do it
0
 
LVL 17

Accepted Solution

by:
inthe earned 400 total points
ID: 2539578
here an example of using ini file to save and load various types of component settings:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls,IniFiles, ComCtrls;

type
  TForm1 = class(TForm)
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    Edit1: TEdit;
    TrackBar1: TTrackBar;
    Edit2: TEdit;
    procedure FormDestroy(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  IniFile : TIniFile;
implementation

{$R *.DFM}

procedure TForm1.FormDestroy(Sender: TObject);
begin
IniFile:=Tinifile.Create('c:\myini.ini');
inifile.WriteBool('Checkboxes','CheckBox1',Checkbox1.Checked);
inifile.WriteBool('Checkboxes','CheckBox2',Checkbox2.Checked);
inifile.WriteBool('Checkboxes','CheckBox3',Checkbox3.Checked);
IniFile.WriteString('Edits_Text','Edit1',Edit1.Text);
IniFile.WriteString('Edits_Text','Edit2',Edit2.Text);
IniFile.WriteInteger('TrackBars','TrackBar1',Trackbar1.Position);
InIfile.Free;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
IniFile:=Tinifile.Create('c:\myini.ini');
Checkbox1.Checked := Inifile.ReadBool('Checkboxes','Checkbox1',False);
Checkbox2.Checked := Inifile.ReadBool('Checkboxes','Checkbox2',False);
Checkbox3.Checked := Inifile.ReadBool('Checkboxes','Checkbox3',False);
Edit1.Text := IniFile.ReadString('Edits_Text','Edit1','');
Edit2.Text := IniFile.ReadString('Edits_Text','Edit2','');
TrackBar1.Position := IniFile.ReadInteger('TrackBars','TrackBar1',0);
IniFile.Free;
end;

end.

if you mainly using edits and dblookups then the main one you be using is writestring('Lookup1','DBLookupCombobox1',bdlookupcombobox1.Text);
but i think this is good example to show for checkboxes etc too so you see of how to use writebool ,writeinteger etc..

let us know if this is help.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 10

Expert Comment

by:tonnybrandt
ID: 2539801
Assuming you want to know if any of them has changed, not exactly which one.
How about the modified property.
Something like this:

Changed := False;
For i := 0 to componentcount -1 do
   begin
   if components[i] is TEdit then
      if Tedit(components[i]).modified then
         changed := True;
   if components[i] is TDBCombo then
      if TDBCombo(components[i]).modified then
         changed := True;
   end;
If Changed then ...........

(i don't know for sure if TDBCombo has the modified property)
Good luck
0
 
LVL 2

Expert Comment

by:florisb
ID: 2539988
set property tag in change / click or whatever events that you can happen with.your components. You van also do all the detection in the FormClose I think?

If using an ini-file: consider the registry. See help, easy.

In formclose:

PSEUDOCODE!

for x := 0 to form1.componentcount -1 do
  if form1.components[x] is tedit then
    if tedit(form1.components[x]).tag <> 0 then
  begin
  case tedit(form1.components[x]).tag is
  // this component is changes, do something with if.
    0: //nothing
    1: //changed
    2: //deleted
  end;


Floris.


 
0
 

Author Comment

by:ffelaar
ID: 2552359
Thank you Inthe ...

It is the best solution to my problem that I have gotten from anyone. I appreciate it.

Kind regards,
ffelaar
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question