Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

What is wrong with my code ?

Posted on 2004-10-08
10
Medium Priority
?
241 Views
Last Modified: 2012-05-05
I write a vcl that use own editor.
I load into package next code and install it. All is perfect. I reCompile how many I wish. All is perfect.

I drop a mine vcl to a form. If I wish I can recompile the package and all is OK.

The problem come from here :

I double click on my vcl and open my editor. OK . Close it. OK. But if I try to recompile the vcl get an rtl60.dpk error message.

OR ... drop my vcl.. double click to open my editor...close my editor.. try to close my Delphi ... get an error message as my Delphi can read some memory address.

The code is next ( a sample code not my real code from vcl but get some errors )/

COMPONENT CODE:

unit Test;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, DesignIntf, DesignEditors;

type
  TTest = class(TCustomControl)
  private
    { Private declarations }
  protected
    { Protected declarations }
  public
    { Public declarations }
  published
    { Published declarations }
  end;

  type
  TgnEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure Register;

implementation

uses editor;

// 8<-------- TgnEditor -------->8 \\

procedure TgnEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: ShowEditor(TTest(Component));
  end;
end;

function TgnEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := 'Edit...';
  end;
end;

function TgnEditor.GetVerbCount: Integer;
begin
  Result := 1;
end;


procedure Register;
begin
  RegisterComponents('Samples', [TTest]);
  RegisterComponentEditor(TTest, TgnEditor);
end;

end.
0
Comment
Question by:ginsonic
[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
  • 6
  • 3
10 Comments
 
LVL 9

Author Comment

by:ginsonic
ID: 12261070
EDITOR CODE:

unit editor;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, dialogs,
  test;

  procedure ShowEditor(FTest: TTest);

type
  TEdits = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Edits: TEdits;

implementation

{$R *.dfm}

procedure ShowEditor(FTest: TTest);
var FForm: TEdits;
begin;
  FForm := TEdits.Create(nil);
  FForm.Caption := Format(' %s Editor', [FTest.Name]);
  FForm.Show;
end;

end.
0
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12262893
one thing I can see right away is this:

procedure ShowEditor(FTest: TTest);
var FForm: TEdits;
begin;
  FForm := TEdits.Create(nil);
  FForm.Caption := Format(' %s Editor', [FTest.Name]);
  FForm.Show;

  FForm.Free //add this line!!!
end;

you need to free that variable there, else is a memory leak problem
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12262997
My editor can be close just if click on close button from title bar ( the X one ). I think that is enough to free the form editor.

Somebody else get same problems when use the code ?
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 9

Author Comment

by:ginsonic
ID: 12263029
In same time I'm sure that isn't a FForm.Free problem. How you can see is a blank form so not much memmory used.

I tested with FForm opened ( to see if is a destroy problem ) to recompile my package. Same rtl60.dpk error.
0
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 2000 total points
ID: 12263424
unless you have caFree in the Action of the OnClose event, the form is not freed automatically
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12265189
If I use a ShowModal all work perfect. The problem to bee the free of form !?!?
BlackTigerX can you tell me more about how to use an action to free ?
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12265237
procedure ShowEditor(FTest: TTest);
var FForm: TEdits;
begin;
  FForm := TEdits.Create(nil);
  try
    FForm.Caption := Format(' %s Editor', [FTest.Name]);
    FForm.ShowModal;
  finally
//    FForm.Release; // if is TForm
    FForm.Free;
  end;
end;
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12265252
Don't wish to use a modal form. The BlackTigerX comment is the solution to my problem. Thanks to all for support!
See you on net :)
0
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 12267306
please disregard this (my own) comment:

FForm.Show;

  FForm.Free //add this line!!!

(duh... the form would be shown and immediatly be gone)...
0
 
LVL 9

Author Comment

by:ginsonic
ID: 12269260
Ni problem :) The answer was the caFree action on close. Thanks again !
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

636 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