trichview.com

trichview.support




freeing controls


Return to index


Author

Message

Michael Philbrick

Posted: 02/11/2005 1:49:09


Sergey,


Here is my code:


  with rvMacNav do begin

    btnYes := TBitBtn.Create(nil);

    AddControlEx('', btnYes, -1, rvvaMiddle);

    FormatTail;

    with btnYes do begin

      Kind := bkYes;

      Default := False;

      Width := 50;

      OnClick := btnYesClick;

    end;

  end;


My understanding is that I do not need to free this component. If I call

rvMacNav.Clear, according to the documentation, this component will be freed.


However, that does not seem to be the result I am getting. I may create and

destroy multiple instances during one session. In each case I will create

an instance, later call Clear, then create another instance, call Clear,

etc. I will never create two instances without clearing in between.


However, when I run this code in a rvMacNavKeyUp event:


if (btnYes <> nil) and (btnYes.Parent <> nil) and (char(Key) in ['Y','N'])

then ...


It will return True in the following instance:


1) create the component with the above code.

2) call rvMacNav.Clear

3) create the component again.

4) call rvMacNav.Clear


In other words, it will not return True the first time it is created and

supposedly destroyed with Clear. It will only happen after the second and

subsequent Clear statements.


I realize that there may be some problems with my code and I cannot really

send you all of it. Therefore, could you clarify a few things for me:


1) Is it true that calling TRichViewEdit.Clear should completely free a component

so TComponent=nil?

2) Is there any problem with creating multiple instances of a component without

calling Clear?

3) Is there any way to destroy the component without calling Clear?

4) What is the best way to test to see if a component exists? I thought about

SelectControl or FindControl but I really don't want the overhead of iterating

through all the items in the document. There must be something simpler than

the test I used, particularly because it appears to fail the second time

around.


Thanks.


(I know that I have been asking a lot of questions, but that is a good thing

-- I am doing so much more with this component that I could do with the last

word processing component I used!!)





Powered by ABC Amber Outlook Express Converter