(1) While creating the units and the package, can I include forms already designed using the IDE or it's impossible to do so and I need to dinamically create the forms at runtime, as already does TSplashAbout?
Suppose your component is named "TAboutDlg". Inherit this component from TComponent so that it can appear on the component palette. Implement a method TAboutDlg.Show which displays the splash form itself. You can design this form as usual in the Lazarus form designer, i.e. add some labels for the application name, its version or whatever you like, and a button to close the form (--> TAboutForm). In TAboutDlg.Show create an instance of TAboutForm, show it modally and then destroy it. That's all...
// in unit "splashdlg"
type
TAboutDlg = class(TComponent)
private
FApplicationName: String;
FAPplicationVersion: String;
FApplicationIcon: TIcon;
public
procedure Show;
property ApplicationName: String read FApplicationName write FApplicationName;
property ApplicationVersion: String read FApplicationVersion write FApplicationVersion;
property ApplicationIcon: TIcon read FApplicationIcon write FApplicationIcon;
// etc.
end;
procedrue TAboutDlg.Show;
var
Frm: TAboutForm;
begin
Frm := TAboutForm.Create(nil); // TAboutForm should be stored in a separate unit "aboutfrm"
try
Frm.ApplicationNameLabel.Caption := FApplicationName;
Frm.ApplicationVersionLabel.Caption := FApplicationVersion;
Frm.ApplicationIcon.Assign(FApplicationIcon);
// etc.
Frm.ShowModal;
finally
Frm.Free;
end;
end;
// in units splashfrm
procedure TForm1.Button1click(Sender: TObject);
begin
Close; // or alternatively: set the close button's ModalResult to mrClose, and this method is not needed.
end;
(2) Ok that I need to use the menù "Package -> New Package ...", but before that, I'm stuck at the "Project Wizard", so which type of "New Project" is more adapt to the tipology of my component? "Application"? "Program"?
Menu "File" > "New" > "Package" > "Package", or easier: Menu "Package" > "New Package". Navigate to the folder in which you want to store the package and its files, enter the package name, "OK". Then, in the package editor under "Files" add the units which you wrote for this package, following above example, "splashdlg.pas" and "splashfrm.pas" (you can also add "splashfrm.lfm", but not necessary). Under "Requirements" you should add "LCL" as a "new requirement", and any other packages which are needed by your component.
Now you should be able to "compile" the package. If it succeeds write a small test application, just a form with a button to open the about form:
procedure TForm1.Button1Click(Sender: TObject);
var
about: TAboutDlg;
begin
about := TAboutDlg.Create(nil);
try
about.ApplicationName := 'My test application';
about.ApplicationVersion := '1.0.0';
about.AppliationIcon := Icon;
about.Show;
finally
about.Free;
end;
end;
When this works as expected you can prepare the component for usage at designtime. Add a procedure "Register" to the splashdlg unit (the one with "TSplashDlg"):
procedure Register;
begin
RegisterComponents('the_palette_for_my_component', [TSplashDlg]);
end;
And in the package editor check the box "register unit" for the "splashdlg" unit - now this item has a green triangle in this treeview icon.
You can click "Use" > "Install" now, and the IDE will rebuild itself to contain the new component on the palette that you specified in the RegisterComponents call.
Sometimes, when the new component is buggy, the new IDE may not start any more. In this case, you should know that the folder with the lazarus binary ("lazarus.exe" on Windows) contains a backup of the previously used version, lazarus.old(.exe). Delete the new lazarus and rename lazarus.old to lazarus - and you will be able to run the previous version and to fix the component.