Recent

Author Topic: How to delete from app illegal form?  (Read 494 times)

dpap

  • Jr. Member
  • **
  • Posts: 52
How to delete from app illegal form?
« on: February 20, 2025, 08:59:22 pm »
I am migrating my Windows application from Delphi 2007 to lazarus 3.6.
While trying to convert a module/form I am encountering problems related to a component appearing again and again after deleting it, so I decided to delete the entire unit that I had already included to project.
So I deleted the pas and lfm files and everything with the module name and the backup directory.
But when I reload the project, the module and form code appear, causing the same errors. I have spent hours trying to remove them but without success.
Where are they located and does the project find and restore them?

Boleeman

  • Hero Member
  • *****
  • Posts: 897
Re: How to delete from app illegal form?
« Reply #1 on: March 22, 2025, 10:54:59 pm »
Hi Dpap.

Go to File, Open and open the file ending with .lfm

You will see something like:

Code: Pascal  [Select][+][-]
  1. object PreviewForm: TPreviewForm
  2.   Left = 138
  3.   Height = 885
  4.   Top = 150
  5.   Width = 1365
  6.   Caption = 'PDF Preview'
  7.   ClientHeight = 885
  8.   ClientWidth = 1365
  9.   DesignTimePPI = 120
  10.   OnCreate = FormCreate
  11.   OnDestroy = FormDestroy
  12.   Position = poScreenCenter
  13.   LCLVersion = '2.2.4.0'
  14.   object Panel1: TPanel
  15.     Left = 25
  16.     Height = 17
  17.     Top = 868
  18.     Width = 463
  19.     Caption = 'Panel1'
  20.     TabOrder = 0
  21.   end
  22.   object PaintBox1: TPaintBox
  23.     Left = 1
  24.     Height = 827
  25.     Top = 41
  26.     Width = 1347
  27.     OnPaint = PaintBox1Paint
  28.   end  

Then delete the offending object and save and then reload the project.

Also if the  the module and form code appear, causing the same errors then open the lpr file and delete or comment out the part that is unwanted and save.

Sometimes resource files do not load so do //{$R *.res}

or if the form is not working in   Application.CreateForm(TPreviewForm, PreviewForm);

create a Newform and change to: Application.CreateForm(TNewform, Newform);

Also delete any not needed component names like say for instance purecode in uses like in Forms, main_test, libmupdf, purecode

purecode loads a ruler component in this case.

Code: Pascal  [Select][+][-]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses
  6.   {$IFDEF UNIX}
  7.   cthreads,
  8.   {$ENDIF}
  9.   {$IFDEF HASAMIGA}
  10.   athreads,
  11.   {$ENDIF}
  12.   Interfaces, // this includes the LCL widgetset
  13.   Forms, main_test, libmupdf, purecode
  14.   { you can add units after this };
  15.  
  16. {$R *.res}
  17.  
  18. begin
  19.   RequireDerivedFormResource:=True;
  20.   Application.Scaled:=True;
  21.   Application.Initialize;
  22.   Application.CreateForm(TPreviewForm, PreviewForm);
  23.   Application.Run;
  24. end.


Lastly did you change
program project1;
{$mode delphi}

to

program project1;
{$mode objfpc}

Codes behave differently in the 2 different modes.
« Last Edit: March 22, 2025, 11:13:24 pm by Boleeman »

 

TinyPortal © 2005-2018