?
Solved

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

Posted on 2003-12-10
19
Medium Priority
?
391 Views
Last Modified: 2010-04-05
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.
0
Comment
Question by:kingpreetham
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
  • 3
  • +3
19 Comments
 
LVL 12

Expert Comment

by:andrewjb
ID: 9913701
Nothing obvioulsy wrong in those lines. Must be something in the form. Anything in the OnClose event?
0
 

Author Comment

by:kingpreetham
ID: 9913721
no, there is an event on the OnCreateEvent, but nothing OnDestroy or OnClose...
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9913818
try to use

Form->Release();

instead of

Form->free();

meikl ;-)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 9913827
oops, c is casesensitive, could be also release
0
 
LVL 2

Expert Comment

by:Robn
ID: 9913947
Are you creating any threads or anything like that? Sounds to me like a memory leak or memory overwrite issue.
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9913948
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
 

Author Comment

by:kingpreetham
ID: 9914814
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
 

Author Comment

by:kingpreetham
ID: 9914844
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
 
LVL 2

Expert Comment

by:Robn
ID: 9914863
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
 

Author Comment

by:kingpreetham
ID: 9915021
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
 
LVL 2

Expert Comment

by:Robn
ID: 9915119
How is the data being sent to the form?
0
 

Author Comment

by:kingpreetham
ID: 9915159
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
 
LVL 2

Expert Comment

by:Robn
ID: 9915168
why does a.exe use a thread to communicate with the OCX file?
0
 

Author Comment

by:kingpreetham
ID: 9915188
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
 
LVL 3

Expert Comment

by:Stefaan
ID: 9918825
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
 

Author Comment

by:kingpreetham
ID: 9923652
what if UpdateGui is from another unit.
0
 
LVL 3

Accepted Solution

by:
Stefaan earned 960 total points
ID: 9926406
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
 

Author Comment

by:kingpreetham
ID: 9928587
Thanks  Stefaan, i created a Synchronised method and called it from there....it worked.
0
 
LVL 3

Expert Comment

by:Stefaan
ID: 9928609
Glad I could help you out :-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

762 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