Recent

Author Topic: "Common" Forms  (Read 4136 times)

JimKueneman

  • Full Member
  • ***
  • Posts: 220
"Common" Forms
« on: February 14, 2013, 03:24:17 am »
Is there a way to have a "common form" that I can use in many applications?  I have a settings/COM port setup dialog that I want to reuse for any application that uses the COM port.

Thanks,
Jim

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: "Common" Forms
« Reply #1 on: February 14, 2013, 05:53:48 am »
Yes, you can dedicate 1 .pas unit for the form class. You can save it to some common folder, and then refer to it by "Other unit files" in project options, so you can add it to uses list.

JimKueneman

  • Full Member
  • ***
  • Posts: 220
Re: "Common" Forms
« Reply #2 on: February 15, 2013, 04:19:57 am »
Thanks, that sort of worked.  One form it works fine.  The other has a TImage on it and when I try to create it it says that "EClassNotFound", "TImage not found". 

Jim

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: "Common" Forms
« Reply #3 on: February 15, 2013, 02:11:40 pm »
For TImage you need ExtCtrls in uses list. This information was not searched or memorized, but i Ctrl+click'ed TImage source code word on empty project.

JimKueneman

  • Full Member
  • ***
  • Posts: 220
Re: "Common" Forms
« Reply #4 on: February 16, 2013, 02:40:06 pm »
That did not do it.  I don't really understand it but I tried to add a TImage to the new app so the component would get registered with the the IDE and that did not work.  So finally I just registered TImage directly in the form unit I ma sharing:

begin
  RegisterComponent(TImage);
end.

Works fine now.  There is something special about how TImage is registered in the IDE.

Jim

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9864
  • Debugger - SynEdit - and more
    • wiki
Re: "Common" Forms
« Reply #5 on: February 16, 2013, 02:56:53 pm »
Just a general note: try to avoid the "Other unit files"

Instead: Create a "new package".

Save or copy the form into the package dir, and add it to the package. Or if you want to create a new form, choose add in the package, and choose "Form".

That way the IDE should manage all dependencies correctly. (Of course if you copied , then you may still have to tell the package about dependencies first.)

You can put all your forms into one package.

 

TinyPortal © 2005-2018