[comp.lang.pascal] Turbo Vision Dialog Problem

garlangr@en.ecn.purdue.edu (Mark T Garlanger) (06/30/91)

I am having a problem with Turbo Pascal 6.0.  I am trying to learn it's new
TurboVision Library, and one of the example programs seems to have a major
flaw.   The program is TVDEMO.  The Mouse Dialog in does not free it's 
self from memory.  The amount of memory available decreases by 512 bytes
each time you use the mouse dialog.  I tried to fix it by calling Done, it
helped but still 88 bytes are lost.  Below is the relevent code(with 
another question).

procedure Mouse;
var
  D: PDialog;
begin
  D := New(PMouseDialog, Init);
  D^.HelpCtx := hcNoContext; **** should this line be place in the if block??
  if ValidView(D) <> nil then
  begin
    D^.SetData(MouseReverse);
    if Desktop^.ExecView(D) <> cmCancel then
      D^.GetData(MouseReverse);
    D^.Done;		******* I add this line.
  end;
end;

Then I notice that Mouse was also allocating a pointer to a scroll bar,
so I add the following destructor to the dialog:

Destructor TMouseDialog.Done;
Begin
  MouseScrollBar^.Done; 
  TDialog.Done;
End;

This also did not work, It left 136 Bytes used!  I commented out 
'MouseScrollBar^.Done;' and memory loss went back DOWN to 88???  Since
I have no idea what is happening here, I'm hoping one of you can shed some
light on this.

BTW: Why does Done needs to declared virtual, and Init does not?

				Thanks,
				  Mark

-- 
-------------------------
Mark Garlanger          |
garlangr@ecn.purdue.edu |
-------------------------