Solved

Form Loading

Posted on 1999-01-13
5
153 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now