* * *

Author Topic: Modifying and using a Lazarus text form (LFM)  (Read 1633 times)


  • Jr. Member
  • **
  • Posts: 72
    • P S Technology, Inc.
Modifying and using a Lazarus text form (LFM)
« on: May 01, 2017, 01:59:34 am »
I wanted to use a form previous ly created using Delphi (DFM) in my Lazarus project, so I converted it to a Lazarus form text file (LFM). But I found that, if I edited the file and then built the project, the previous version was restored. I found that there was another copy in "lib\i386-win32\", so I used that in my project inspector. But now I made some edits using the WYSIWYG editor, and I got an error that the backup file could not be written to (I had made ir R/O). But now a dialog box seems to be "stuck" and I can't seem to close it. See attachments:

Actually, the application was running, so when it stopped, the form closed. I'm still confused about how the WYSIWIG editor interacts with the LFM files for the project. It works when I save the files and then copy them to two or three places, but sometimes the IDE changes the form from "TfmLazSerial_Test" to the previous "TfmComDrv32_Test". And then a default blank form appears when the application runs. I'm confused about how these various dependencies work, as well as the directives in the project and source files:
Code: Pascal  [Select]
  1. unit serialtestcpdrvmain;
  3. {$mode objfpc}{$H+}
  5. interface
  6. ...
  7. implementation
  9. {$R *.lfm}
  11. { TfmSerialTestCPdrv }
Project file (I removed the directives from my current project - didn't seem to make much difference)
Code: Pascal  [Select]
  1. program LazSerial_Test;
  3. uses
  4.   {$IFDEF UNIX}{$IFDEF UseCThreads}
  5.   cthreads,
  6.   {$ENDIF}{$ENDIF}
  7.   Interfaces, // this includes the LCL widgetset
  8.   Forms, LazSerialPort, LazSerial_TestMain;
  10. begin
  11. //  RequireDerivedFormResource:=True;
  12.   Application.Initialize;
  13.   Application.CreateForm(TfmLazSerial_Test, fmLazSerial_Test);
  14.   Application.Run;
  15. end.
« Last Edit: May 01, 2017, 02:09:20 am by PStechPaul »


  • Hero Member
  • *****
  • Posts: 5053
Re: Modifying and using a Lazarus text form (LFM)
« Reply #1 on: May 01, 2017, 04:05:01 am »
there is only one reason that the lfm is restored after you changed it outside the IDE you had it already open in the IDE. The IDE keeps track of opened code files (ee *.pp, *.pas etc) but I do not thing it keeps track about the .lfm files. So if you are going to edit them outside the IDE (which I really do not see the use of it especially since you can edit the text directly in the IDE) make sure that the form is not open in IDE before doing so.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64


  • Jr. Member
  • **
  • Posts: 72
    • P S Technology, Inc.
Re: Modifying and using a Lazarus text form (LFM)
« Reply #2 on: May 01, 2017, 07:54:17 am »
I would like to be able to edit the form using the graphical interface of the IDE. But it seemed that it was not updating the file actually used by the project. Maybe I need to close the LFM window and only use the form. Thanks!

[edit] I found that I had not correctly set the name of the form in Object Inspector, so it was looking at a different form. Now I am able to use the graphical editor to make changes to the form and the LFM file(s) are properly updated.

The Laz_Serial_Testmain.lfm file does not have the "Name" property, and a number of other properties are not included. They must be in some other file, probably LazSerial_Test.res
« Last Edit: May 01, 2017, 08:52:14 am by PStechPaul »



Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus