Form not closong, freezes...important..help

I have the following code..
Form = new TfrmABC(NULL);
...some methods to load form data n stuff
do a ShowModal() for the form
i close dn return, then i do
Form->free();
This is where i am having a problem. The form fails to destroy and freezes
I get no error message.

While using debug, i get the message
Access voilation in module...'bordbk61.dll'. Read of address...

I have no event on the FormDestroy event

What can cause such a problem.

Appreciate the help.

Thanks,
Preetham.
kingpreethamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

andrewjbCommented:
Nothing obvioulsy wrong in those lines. Must be something in the form. Anything in the OnClose event?
0
kingpreethamAuthor Commented:
no, there is an event on the OnCreateEvent, but nothing OnDestroy or OnClose...
0
kretzschmarCommented:
try to use

Form->Release();

instead of

Form->free();

meikl ;-)
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

kretzschmarCommented:
oops, c is casesensitive, could be also release
0
RobnCommented:
Are you creating any threads or anything like that? Sounds to me like a memory leak or memory overwrite issue.
0
gmayoCommented:
Try:

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
      Action := caFree;
end;

So the form frees itself rather than you doing it manually.

Geoff M.
0
kingpreethamAuthor Commented:
I tried Form->Release();, there is no problem executing the Release, but then there
is transfer control to the FormDestroy method, there is nothing it does..however it hangs
at the end of execution of this method....
I am using threads, but not creating a thred in this form..
I have obj A creating a thread calling a function in obj B.
obj B creates the form and destroys it.
0
kingpreethamAuthor Commented:
EDIT:I have obj A creating a thread calling a function in obj B.
I have obj A creating a thread. This thread sends a message which is caught in a function in obj B.
0
RobnCommented:
Does the form interact with the thread at all, or does the thread interact with the form aside from creating and destroying it? Is it a modal form? Are you waiting on this threads at all?
0
kingpreethamAuthor Commented:
let me put it in more detail.
I have a.exe and b.ocx
a.exe starts a thread that sends messages.
b.ocx has a callback that activates upon receiving a message.
first, b.ocx creates the form(modal) it then waits for data from
the exe. After it got all the data, it waits until the user closes the
form.
When the user closes the form, it hangs.
0
RobnCommented:
How is the data being sent to the form?
0
kingpreethamAuthor Commented:
th exe calls a method of the ocx...the ocx gets the data, it then uses a CopyToObject interface to copy the data to the controls on the form
0
RobnCommented:
why does a.exe use a thread to communicate with the OCX file?
0
kingpreethamAuthor Commented:
i dont want the form to wait for all the data to open, i open the form and populate the controls as the thread passes data to it...
this is coz some of the controls are hidden in tabs of the form and need not be loaded when displaying the form initially..
0
StefaanCommented:
Hm, tough one, when your Thread updates the controls on the form, make sure that all the Form updates are in a procedure and you call it using a Synchronise.

Example, I have a thread which updates the caption of a button, so I make a UpdateGui method on my thread :

procedure TMyThread.UpdateGui;
begin
  // I passed the button that needs to be updated to the constructor,
  // or you could also create a property for it and set the property
  // when you create the Thread.
  FButton.Caption := 'New Caption';
end;

procedure TMyThread.Execute;
var
  lcv : Integer;
begin
  For lcv := 0 to 999 do
  begin
    // Do Some Stuff

    // Update the Gui
    Synchronise( UpdateGui );
  end;
end;


Everytime you make an update to the Gui from within your thread you should use the Synchronise, since the complete VCL isn't fully thread safe.
0
kingpreethamAuthor Commented:
what if UpdateGui is from another unit.
0
StefaanCommented:
Well, then that might be your problem.  I wouldn't know how to solve it correctly, but you might try to call that method from within a Synchronised method of your thread.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kingpreethamAuthor Commented:
Thanks  Stefaan, i created a Synchronised method and called it from there....it worked.
0
StefaanCommented:
Glad I could help you out :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.