Error of closing with simple Viewer CAD in a DLL
Posted: 04 Nov 2015, 14:04
Daniel
I created a DLL to make simple Viewer. If I use the DLL called dynamically, i have an error when I make FreeLibrary(DLLHandle)
I do not have this error with a static DLL ?
What is the correct procedure to free the component ?
The code to open
FDNavigatorDX:=TsgDrawingNavigator.Create(Self);
FDNavigatorDX.Parent:=Self;
FDNavigatorDX.AutoFocus:=True;
FDNavigatorDX.RectZooming:=True;
FDNavigatorDX.OnChangeScale:=sgPaintBoxScaling;
FDNavigatorDX.DoubleBuffered:=True;
FDNavigatorDX.Picture.Graphic:=nil;
FDNavigatorDX.BeginUpdate;
try
FDNavigatorDX.LoadFromFile(OpenDialog.FileName);
Caption := OpenDialog.FileName + ' Editor';
FDNavigatorDX.Align:=alClient;
FDNavigatorDX.FitToSize;
finally
FDNavigatorDX.EndUpdate;
FDNavigatorDX.Update;
end;
if FGraphicDX <> FDNavigatorDX.Picture.Graphic then
begin
FGraphicDX:=FDNavigatorDX.Picture.Graphic;
if FGraphicDX is TsgCADImage then
FImg:=TsgCADImage(FGraphicDX)
else
FImg := nil;
end;
...
The code to formclose (I do not know if it's right)
Try
FDNavigatorDX.Picture.Graphic:=Nil;
FDNavigatorDX.Align:=alNone;
If Assigned(FDNavigatorDX) Then
FDNavigatorDX.Free;
FGraphicDX:=Nil;
FImg:=Nil;
Except
End;
Action:=caFree;
I created a DLL to make simple Viewer. If I use the DLL called dynamically, i have an error when I make FreeLibrary(DLLHandle)
I do not have this error with a static DLL ?
What is the correct procedure to free the component ?
The code to open
FDNavigatorDX:=TsgDrawingNavigator.Create(Self);
FDNavigatorDX.Parent:=Self;
FDNavigatorDX.AutoFocus:=True;
FDNavigatorDX.RectZooming:=True;
FDNavigatorDX.OnChangeScale:=sgPaintBoxScaling;
FDNavigatorDX.DoubleBuffered:=True;
FDNavigatorDX.Picture.Graphic:=nil;
FDNavigatorDX.BeginUpdate;
try
FDNavigatorDX.LoadFromFile(OpenDialog.FileName);
Caption := OpenDialog.FileName + ' Editor';
FDNavigatorDX.Align:=alClient;
FDNavigatorDX.FitToSize;
finally
FDNavigatorDX.EndUpdate;
FDNavigatorDX.Update;
end;
if FGraphicDX <> FDNavigatorDX.Picture.Graphic then
begin
FGraphicDX:=FDNavigatorDX.Picture.Graphic;
if FGraphicDX is TsgCADImage then
FImg:=TsgCADImage(FGraphicDX)
else
FImg := nil;
end;
...
The code to formclose (I do not know if it's right)
Try
FDNavigatorDX.Picture.Graphic:=Nil;
FDNavigatorDX.Align:=alNone;
If Assigned(FDNavigatorDX) Then
FDNavigatorDX.Free;
FGraphicDX:=Nil;
FImg:=Nil;
Except
End;
Action:=caFree;