Jump to content

Create a new TUniForm class


Recommended Posts

Hi,

I would like to create a new component with a inheritance from TuniForm class.

On Delphi IDE the new component assistant interface doesn't permit to select TuniForm class !

Is it possible do to inheritance  on this object class ?

 

Thanks

Link to comment
Share on other sites

Sorry....i've just fond the solution myself !

1) I've created a new "application form" with the IDE

2) I've customized properties et functions of this form

3) I've used this new class for the inheritance of my main application form

;)

 

Link to comment
Share on other sites

That is the code of my First unit :

unit UniMainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,  Controls, Forms, uniGUITypes, uniGUIAbstractClasses,  uniGUIClasses, uniGUIForm
  , uDefUser {a unit to manager user};

type
  TUniMainForm = class(TUniForm)
    procedure UniFormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    user:TUser;
  end;

implementation

{$R *.dfm}

uses
  UniGUIVars, MainModule, uniGUIApplication;

procedure TUniMainForm.UniFormCreate(Sender: TObject);
begin
  initUser(user, True);
end;


initialization
  RegisterMainFormClass(TUniMainForm);

end.

 

That is the code of my 2d unit :

unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, DateUtils
  , Vcl.Imaging.GIFImg, Vcl.Menus, Vcl.Imaging.jpeg, Vcl.Imaging.pngimage
  , Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls, Buttons, Data.DB
  , uniGUITypes, uniGUIForm, UniListBox, UniMemo, UniLabel, UniPanel, UniPageControl,
  UniButton, UniSpeedButton, uniGUIRegClasses,  uniguiclasses, uniMultiItem, UniBitBtn,
  uniGUIBaseClasses, uniSplitter, uniComboBox, uniScreenMask, uniHTMLMemo,
  uniBasicGrid, uniDBGrid, uniRadioGroup, uniGroupBox, uniSpinEdit,
  uniDateTimePicker, uniMainMenu, uniCheckBox,
  uniImage, uniRadioButton, uniScrollBox
  , uniMainForm
  ;

type
  TMainForm = class(TUniMainForm)
    PanelUtilisateur: TUniPanel;
    BtnDeconnectUser: TUniSpeedButton;
    UniPanelTop: TUniPanel;
    UniLogoMini: TUniImage;
    UniLabelTitre: TUniLabel;
    UniPanelFond: TUniPanel;
    UniPanelActions: TUniPanel;
    LabelUtilisateur: TUniLabel;
    bkImage: TUniImage;
    UniScrollBox1: TUniScrollBox;
    BtnAction1: TUniBitBtn;
    BtnAction2: TUniBitBtn;
    BtnAction3: TUniBitBtn;
    BtnAction4: TUniBitBtn;
    procedure UniFormCreate(Sender: TObject);
    procedure UniFormShow(Sender: TObject);
    procedure BtnDeconnectUserClick(Sender: TObject);
    procedure UniFormScreenResize(Sender: TObject; AWidth, AHeight: Integer);
    procedure BtnAction1Click(Sender: TObject);
    procedure BtnAction2Click(Sender: TObject);
    procedure BtnAction3Click(Sender: TObject);
    procedure BtnAction4Click(Sender: TObject);
  private
    { Private declarations }
    idFct:byte;
    bNeedConnexion:boolean;
    procedure GoAction(id:byte; bRefresh:boolean=False);
  public
    { Public declarations }
    function GetIdAction : byte;
  end;

function MainForm: TMainForm;

implementation
{$R *.dfm}

uses
  UniGUIVars, MainModule, UniGUIApplication, ServerModule;


//------------------------------------------------------------------------------
function MainForm: TMainForm;
begin
  Result := TMainForm(UniMainModule.GetFormInstance(TMainForm));
end;

procedure TMainForm.UniFormCreate(Sender: TObject);
begin
...

end;

procedure TMainForm.UniFormShow(Sender: TObject);
begin
...

end;

procedure TMainForm.UniFormScreenResize(Sender: TObject; AWidth, AHeight: Integer);
begin
  GoAction(idFct);
end;

procedure TMainForm.BtnDeconnectUserClick(Sender: TObject);

begin
  close;
end;

procedure TMainForm.BtnAction1Click(Sender: TObject);
begin
  GoAction(1);
end;

procedure TMainForm.BtnAction2Click(Sender: TObject);
begin
  GoAction(2);
end;

procedure TMainForm.BtnAction3Click(Sender: TObject);
begin
  GoAction(3);
end;

procedure TMainForm.BtnAction4Click(Sender: TObject);
begin
  GoAction(4);
end;

//------------------------------------------------------------------------------
function TMainForm.GetIdAction : byte;
begin
  result:=idFct;
end;

procedure TMainForm.GoAction(id:byte; bRefresh:boolean);
var w,h:integer;
    titre:string;
    bOk:boolean;
begin
  if (user.Login='')and(idFct>0) then exit;

...

end;


end.

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...