Recent

Author Topic: [SOLVED] Custom form  (Read 16732 times)

pcurtis

  • Hero Member
  • *****
  • Posts: 951
[SOLVED] Custom form
« on: December 16, 2021, 07:59:36 pm »
I want to make a custom form with a few extra properties, no problem.

My question is how can I make this form the default in Lazarus?
« Last Edit: December 20, 2021, 11:03:21 am by pcurtis »
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Lulu

  • Full Member
  • ***
  • Posts: 173
Re: Custom form
« Reply #1 on: December 16, 2021, 08:29:22 pm »
If by 'default form' you means the main form, simply move the line where it is created to the first position in your project .lpr file. It must be created first.
wishing you a nice life

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #2 on: December 17, 2021, 09:17:28 am »
By default I mean create this by default

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, [b]MyForm[/b], Controls, Graphics, Dialogs;
  9.  
  10. type
  11.   TForm1 = class([b]TMyForm[/b])
  12.   private
  13.  
  14.   public
  15.  
  16.   end;
  17.  
  18. var
  19.   Form1: TForm1;
  20.  
  21. implementation
  22.  
  23. {$R *.lfm}
  24.  
  25. end.
  26.  

and automatically add MyComponents to the projects requirements.
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 811
Re: Custom form
« Reply #3 on: December 17, 2021, 09:21:03 am »
I guess, it requires modifying Lazarus sources.
29.12.2021 - migration to DynamicData 4.1 is completed - complete overhaul of data access driver.
My project still requires full Delphi 2009 support to be ported to Lazarus.
It's time to finally do it, because Delphi 2009 is 14 years old.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #4 on: December 17, 2021, 09:22:46 am »
Any idea where?
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

zeljko

  • Hero Member
  • *****
  • Posts: 1412
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Custom form
« Reply #5 on: December 17, 2021, 01:56:16 pm »
Maybe you should look into "New..." command in ide (just below New Form).
You can register your own customform as package in ide and then create it via "New..." cmd (so no need to touch lazarus sources), or of course you can override "New Form" cmd with your own in lazarus sources.

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #6 on: December 17, 2021, 04:40:17 pm »
@zeliko Looks like the way to go. How do I add my form there as a project?
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

dsiders

  • Hero Member
  • *****
  • Posts: 821
Re: Custom form
« Reply #7 on: December 17, 2021, 05:26:55 pm »
Maybe you should look into "New..." command in ide (just below New Form).
You can register your own customform as package in ide and then create it via "New..." cmd (so no need to touch lazarus sources), or of course you can override "New Form" cmd with your own in lazarus sources.

Are you referring to the facilities in components/custform package? If so, it needs to be installed into the IDE.
Preview Lazarus 2.3.0 documentation at: https://dsiders.gitlab.io/lazdocsnext

GetMem

  • Hero Member
  • *****
  • Posts: 4026
Re: Custom form
« Reply #8 on: December 17, 2021, 05:46:11 pm »
@pcurtis
Quote
Looks like the way to go. How do I add my form there as a project?
You cannot add your form as project. That doesn't even make sense.

1. Open your project
2. Create a new form(uMyNewForm/fMyNewForm), save unit
3. Go to File->New->Inherited Item->Inherited Project component
4. Select fMyNewForm, press OK
5. The IDE will create a new form, which inherits from fMyNewForm

Is this what you are after?

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #9 on: December 17, 2021, 06:20:14 pm »
Can I make a project template and add it there? (don't mention Tools => Project Templates. That completely sucks)
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

jamie

  • Hero Member
  • *****
  • Posts: 5192
Re: Custom form
« Reply #10 on: December 18, 2021, 12:28:08 pm »
I guess a question would be is, are you trying to add these properties to all forms ever created in the system or just the initial form?
The only true wisdom is knowing you know nothing

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #11 on: December 18, 2021, 01:36:20 pm »
Just the initial form
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

jamie

  • Hero Member
  • *****
  • Posts: 5192
Re: Custom form
« Reply #12 on: December 18, 2021, 04:08:07 pm »
What I do for something like that is use the "New project From File" option. that lets you go select a PAS file unit which can be your first unit..

  You create a simple project with all of your properties added, uses etc. Save that project as a base project for example and when ever you need a new project you can use the "new project From File" then you can navigate over to that project you created and load the unit file, it will start you off from that point on and should not affect the base project you grabbed that from.

The only true wisdom is knowing you know nothing

pcurtis

  • Hero Member
  • *****
  • Posts: 951
Re: Custom form
« Reply #13 on: December 18, 2021, 04:52:01 pm »
OK thanks for the tip, but that only solves half the problem. What if my unit has certain package requirements? How do I add them?
Windows 10 20H2
Laz 2.2.0
FPC 3.2.2

jamie

  • Hero Member
  • *****
  • Posts: 5192
Re: Custom form
« Reply #14 on: December 18, 2021, 05:32:35 pm »
if you have a folder full of special base projects you can simply open any one of those to start a new project and then use the SaveProjectAs to a new folder before you start editing.

 I think that maybe the Tools menu has the Template option to set a path to a template folder section where you can fetch these from but I am not so sure if laz has built in safeguards to keep you from over writing them.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018