Solved

Form Loading

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is there a maximum column width (in pixels) in a TListView? 22 102
code issue 8 99
find a node in VST 2 63
DBGrid or StringGrid ? 6 68
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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 this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 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

21 Experts available now in Live!

Get 1:1 Help Now