DeanSmith
asked on
Form Loading
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.CreateAppli cation);
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?
If Assigned( frInformation ) Then
frInformation.Show
else
begin
frInformation := TfrInformation.CreateAppli
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?
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.
Cheers,
Raymond.
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;
DataSource.Enabled:=false {at design time}
then for rhe Information form:
frmInformation.OnShow (Sender);
begin
DataSource.Enabled:=true;
end;
ASKER
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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(Se
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.