Recent

Author Topic: Is there a way to Use form template in project template in Other project?  (Read 4679 times)

amartitegui

  • Jr. Member
  • **
  • Posts: 84
I mean, Is there a way to use a form template of a project template as just a form In other project?
thanks

Thaddy

  • Hero Member
  • *****
  • Posts: 14357
  • Sensorship about opinions does not belong here.
Yes, you can place your form and unit in the templates directory. It is not as comfortable to do as it is in Delphi but the effect is the same.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

WooBean

  • Full Member
  • ***
  • Posts: 230
I mean, Is there a way to use a form template of a project template as just a form In other project?
thanks

I guess that no, there is not such a way. It seems to me that (at least for Lazarus 1.8.0) the IDE has only prepared entry for a future feature "Template projects". 
Take a look at doc: http://wiki.lazarus.freepascal.org/IDE_Window:_New_Item#Template_Projects
So, we can use from the IDE main menu: File - New ... - Module - Form.
However, currently existing functionality is satisfying enough, IMHO.

WooBean
« Last Edit: March 15, 2018, 12:18:47 pm by WooBean »
Platforms: Win7/64, Linux Mint Ulyssa/64

amartitegui

  • Jr. Member
  • **
  • Posts: 84
Quote
Yes, you can place your form and unit in the templates directory. It is not as comfortable to do as it is in Delphi but the effect is the same.
Well.... close but not Exactly. You can Use templates within a project. Meaning, Cannot Add a form template form a project template in an allready built project...

Quote
So, we can use from the IDE main menu: File - New ... - Module - Form.
However, currently existing functionality is satisfying enough, IMHO.
Almost agree.... but if I create a different look of a form, and there are many procedures (mostly apearance and behavior) And always are the same... (on mouse down, mouse move.... on a header panel)... well its a insustantial time copy paste, and then change unit names...

I know I can Register a Tform descendant to be ready and used... but registering Form is not as easy as a component. I just did a couple of tries and found some problems. ...https://www.freepascal.org/~michael/articles/lazide2/lazide2.pdf
I guess Ill have to work on it maybe week end  %)
thanks anyway

amartitegui

  • Jr. Member
  • **
  • Posts: 84
Well I found a Way that I havent niticed before... mybe stupidly.
I f I have a Form, Dessigned in the project, (before Adding speciffic procedures that may differ on different forms), I just did:
Get all common (to all my equal looking forms) procedures, an form dessig to a new form.
Name it x example. FrmTemplate1 with unit FormTemplate1
That form wont be really used in the project actively, just as a "CANVAS" for my cloned Forms..

That Way, I just have to click File--> NEW--->INHERITED ELEMENT--> Inherited component from project.
And choose My FrmTemplate1 .

Everything works fine.
Its created as Unit1, form1. as a new Form, but with all procedures included in Pattern form
that way, In my Project I just Create a Folder (That I can see in my project manager)Named...: TEMPLATES To set there my "Will be" templates .
Even Better. I can MAke A FOLDER in my LAZARUS PROJECT main Folder CALLED COMMONFORMTEMPLATES.
That way I only have to add them as a new Unit to the project, and just use it that way.
Probably its something stupid and Im last to figure out... but well, It worked to me and maybe someone is looking for something like that.
thanks all

WooBean

  • Full Member
  • ***
  • Posts: 230
Well I found a Way that I havent niticed before... mybe stupidly.
...

Have you tested 'Frames' - heavily used by Lazarus itself for creating almost everything in IDE GUI (as I was able to pass through the excerptions of Lazarus source code)?
see http://wiki.freepascal.org/Frames
« Last Edit: March 15, 2018, 06:42:22 pm by WooBean »
Platforms: Win7/64, Linux Mint Ulyssa/64

WooBean

  • Full Member
  • ***
  • Posts: 230
Frames story ...

Honestly, reusing prepared frame modules in Lazarus at design time seems to me a task to be done in the future by Lazarus Team. In Delphi frames were easily integrated to the IDE designer's component palette and then .... drag and drop and ... a task done.
Maybe someone knows how to reach the same in Lazarus?

WooBean
« Last Edit: March 15, 2018, 05:43:03 pm by WooBean »
Platforms: Win7/64, Linux Mint Ulyssa/64

amartitegui

  • Jr. Member
  • **
  • Posts: 84
I've been using frames, but not very good result...
For example, If I have to duplicate in a form twice the same frame, loading data, with events...
It gets messy and throws exceptions. They both use same variable/class, and not a new instance.
If I do it with forms, Works with no problem. I host two instances of a form in a panel each, and I have no problem ...

i've got more problems with them. They are tricky.IMHO.
Also, If I make a frame to be hosted in a panel... sometimes, and other times I need it to  be shown in a form , I end Up making a form to host a frame.I rather make a form with a couple of properties to select regular borderstyle, single, resizable... or border none with a little own header. that way, in spite of using a frame, and having to host sometimes in a panel and other times in a form... I do directly a form. And If neded to show in panel I do, and if just wanto to pop it up..

Also, If I change a Frame at dessign time, and its in a form that I have opened in IDE, changes wont show always. I gotta go and take it from form, and add it again,....

Don't know, Didnt like'em very much. Maybe 'cause I've been working too much with .net and c# (also do), where components work kinda same easy using way as Delphi frames, and give me too many unexpected results.

Well, Just comment. Maybe someone has other way or finds his own.

Regards



jamie

  • Hero Member
  • *****
  • Posts: 6128
Yes, there seems to be a bug in the OI for frames.. At least that is the way I see it and it may have
originated from a early failed attempt in the Delphi days..

 When you allow the OI to create an event for a member in a frame, it'll pick one that may already
exist and then of course that event is now using one that it shouldn't.

  The issue is this, the OI does not prepend the Instance name of the frame along with the remaining
tag name that you would normally see, i.e. MyFrame.Edit1, Onclick = Edit1Click when it should be
MyFrameEdit1Click
 
 if there is a trick in the OI to force it to generate a unique tag name for the event I wish I knew what it was..

 So of course, if you were to have two or more instances of the same frame, all the EDIT1Click events end up pointing to the same one, this is in the frames and in the base hose form..

 To get around this, you can manually type out a instance name in the class for the event and then use
CLTRL+Shift+C  which will generate the method code for it.

 Then in the OI you can scroll through the list of  qualified events and you'll see the one you just made and then you can pick that.

 Yes, I wish one day they can fix this..  >:(
The only true wisdom is knowing you know nothing

taazz

  • Hero Member
  • *****
  • Posts: 5368
Yes, there seems to be a bug in the OI for frames.. At least that is the way I see it and it may have
originated from a early failed attempt in the Delphi days..

 When you allow the OI to create an event for a member in a frame, it'll pick one that may already
exist and then of course that event is now using one that it shouldn't.

  The issue is this, the OI does not prepend the Instance name of the frame along with the remaining
tag name that you would normally see, i.e. MyFrame.Edit1, Onclick = Edit1Click when it should be
MyFrameEdit1Click
 
No! the name of the event has nothing to do with where it is declared. Although a naming conversion is helpful it is only a convention, it has no real weight on where the handler is declared or from which control is used this is defined in the lfm file and it does not create any conflicts.
if there is a trick in the OI to force it to generate a unique tag name for the event I wish I knew what it was..
Of course there is a trick, its the double click on the event in the OI.
So of course, if you were to have two or more instances of the same frame, all the EDIT1Click events end up pointing to the same one, this is in the frames and in the base hose form..
no, you assume to much you do not test enough.

I mean, Is there a way to use a form template of a project template as just a form In other project?
thanks
I have no idea what you mean by form template but as far as I can remember you can use file\New... to add any kind of registered template in your active application.
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

 

TinyPortal © 2005-2018