Adding new component to pallete

I want to add a text property to some components (webEdit, WebLabel and others), add them to the component palette and use them by dragging and dropping in the visual editor.
I can make it now at runtime, but for many reasons I would like to have them in the palette.
I know how to make it in delphi but even though I read the documentation but am not clear of all the steps for achieving this in WebCore VSC.
Is there a sample of that? not for specialized components but for the very basic as I described above.

Do you have the typical register unit with the method Register in the interface where you call RegisterComponents() in this Register proc and add the Register proc call to the initialization section of this unit?
The standard TMS WEB Core framework components are installed via unit WEBLib.WEBReg.pas in the "Core Source" folder

My question emerged because I created a new package from the TMSWebCore options in VSC, but it just created a .plain dpk, and a dproj files.
I probably was expecting the basic skeleton as it happens in delphi, where you create a new component based on an existing one, and then it creates the unit or a new package including the one you just did.
But all that said, I can replicate that function by hand and will try as I did in Delphi many times.

OK I gave it a shot and try to add a component based on webedit. I named it TWebEditJD for the purposes of the test.
It was actually very simple, just like it was back on delphi for windows apps. I install it the same as installing the other packages, by right clicking on "Install". It does not fail and the component is added to the palette, in a new category named appropriately. I attached the code here.

HOWEVER am missing something, because the component type is added as TeditJD to the palette, and when I drop it on the form it is also that type. And in the .pas and .dfm.
I can change properties but the program won't compile because it can't find that declaration. Of course I added the path to my component on the dproj project..
I searched thoroughly on my files and there is absolutely no indication of that word ("TeditJD") to be found in my code. All references are to the full name: TWebEditJD.

So, am still missing something. I confess my lack of experience creating components, so probably there is a place I ignore where I should put the name. AFAIK, the file names don't have any effect on pascal, but I would like to know what am doing wrong.

Any advise is appreciated. (3.2 KB)

This is a known class name processing behavior of the compiler.

Structure your component class as:

unit WebEditJD;


  Classes, SysUtils, WEBLib.Controls, WEBLib.DesignIntf, Web, WEBLib.Graphics, WEBLib.StdCtrls,
  WEBlib.ComCtrls, WEBLib.ExtCtrls;

  TEditJD = class(TWebEdit)
    { Private declarations }
    FCode: integer;
    FJDatafield: string;
    { Protected declarations }
    { Public declarations }
    { Published declarations }
  property JDCode: integer read FCode write FCode;    { Published declarations }
  property JDataField: string read FJDataField write FJDataField;    { Published declarations }  { Published declarations }

  TWebEditJD = class(TEditJD);

procedure Register;


procedure Register;
  RegisterComponents('JDTMS Web', [TWebEditJD]);


This has a technical background for the IDE integration in Delphi where there is at design-time VCL stub components and due to limitations in Delphi with registering classes with the same name but for different frameworks (VCL & WEB).
As the compiler is identical in VSC as in Delphi, this limitation also affects VSC but is easy to workaround with the given class structuring as shown here.

Thanks Bruno. I did what you indicated.
Sadly somewhere in the process the class is still being renamed to TEditJD like before. Maybe there is some other step that must be done.

In order to do a "clean" build, removed the package using the TMSWebCore Options in the VSC IDE, restarted VSC. Then (before opening the project), deleted the .vsc and left only the three basic files (.dpk, .dproj and .pas). Then renamed all the "TEditJD" references to "TEditpJD" just to make it different. Searched for all instances of "TEditJD" in those three files and verified there is none. Only the ones with the mid "p" remain.
But when compiling, the name is changed "TEditJD". I searched and after compilation, this name appears in the .twcl. I changed there and watched it changed by the compiler.

Thinking it was some leftover in my Windows PC, I copied to the macbook the folder containing the basic three files again. I haven't tried this on the macbook, so am sure is clean and does not have any prior reference to this component.
And it happened there, consistent with the Windows version. "TEditJD" is nowhere in the code but it still is how it it compiles the component.

So, there is something else am missing.

I explained and showed with the code snippet that you should have a class TEditJD. If you want to use the component as TWebEditJD on the form, just descend TWebEditJD from TEditJD. Again, it is shown in the code snippet I shared here in the previous answer.

I see I wasn't completely clear on my previous reply and I mixed up my "attempts".

In my first attempt, I did exactly what you indicated:
I read and understood the code you posted.
Declare the class TEditJD = class(TWebEdit), and descend TWebEditJD from TEditJD. Then register TWebEditJD.
The problem I had with this is that the compiler fails with an error. It says that TEditJD is a duplicate identifier. It does not install. The screenshot in this reply and the code is for this attempt 1.

That is why I did the subsequent attempts inserting a "p". (it stands for spanish "Prueba").
Made other attempts with interesting results.
I will keep trying until I crack the code and post it when done.

Well I think I cracked the code: The offending part here is the word "Web".

I declared and registered my component as TEditJD and it works fine now.

The "Web" part on the component name declaration was messing with the compiling process.

For some reason I thought that the "Web" part on the component name needed to be somewhere for my component to work with WebCore but it seems I was wrong.

Will try to customize other components to fit my needs and will look for another "signature name". For now will stick with JD.

1 Like