Solved

Form Loading

Posted on 1999-01-13
5
162 Views
Last Modified: 2010-04-06
I have a main form in my DB application which loads other forms from a toolbar, I use the

If Assigned( frInformation ) Then
                 frInformation.Show
    else
        begin
             frInformation := TfrInformation.CreateApplication);
             frInformation.Show;
        end;

which works great My problem is this in this form (frInformation) I have a bunch of data controls linked to a data source. The OnDataChange event on this data source I have a routine that draw on the form (frInformation). problem is as the form load the OnDataChange event is triggered, I cannot use the if assigned(frInformation) because it does not work(it works by not on loading but if run once the user has control it does not change what am I doing wrong) , so how can i tell if thoses control are ready to recieve data?
0
Comment
Question by:DeanSmith
5 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1356334
I'm not sure if I understood your problem...

How about adding an OnPaint event handler for the frInformation form. In this frInformation.FormPaint handler you could set a global variable to true.

var frInformationIsReady : boolean = false;

procedure frInformation.FormPaint(Sender: TObject);
begin
  frInformationIsReady:=true;
end;

And in the frInformation.FormClose handler you could set this variable to false again.

Now this variable tells you if the frInformation form is ready to receive data.

Does this help?

Regards, Madshi.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1356335
Another approach might be to assign the OnDataChange event in the OnShow event of the form so that it is not triggered when you load the form. (ie: Do not assign this event at design time.

Cheers,

Raymond.
0
 
LVL 1

Expert Comment

by:martin_g
ID: 1356336
Another thing you could do is set:

DataSource.Enabled:=false {at design time}

then for rhe Information form:

frmInformation.OnShow (Sender);
begin
  DataSource.Enabled:=true;
end;

0
 

Author Comment

by:DeanSmith
ID: 1356337
maybe I can give you some more information

three files (datamodule, mainform, detailsform)
in datmodule I have query with a datasource
in mainform I have a button that lauches detialsform
in detailsform I have a status bar which displays if the datasource is in browse/insert/edit mode.

in the datamodule/datasource ondatachange event I have a routine that check to see what the state is and displays it on the statusbar of the details form.

problem is
if the detailsform is loading and a ondatachange event is triggered whether it is enabled in the detailsform.onshow or detailsform.Activated it still comes up with a access violation







0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 190 total points
ID: 1356338
Set the enabled property of the datasource component to false. When the details form shown (OnShow event) set the enabled property of the DataSource to true.

Cheers,

Raymond.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mydac connection data base issue 3 166
Delphi cmd execution 6 67
How to renew a Delphi rad-studio licence? 5 69
Twebbrowser add css to the header 3 29
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

831 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