The beggin of my projects, is simple: (the names of Forms you can change, of your way)
0 - my Directory Structure:
c:\NameApplication\PRJ\(my project files and sub-folders (Win32\Debug or Release, example) to DCU and another binary files)
c:\NameApplication\EXE\(my app.exe)
c:\NameApplication\SKN\(all *.SKINRES files, except ALLSKINS.SKINRES hehehehe)
c:\NameApplication\FRM\(all *.frm and .pas files)
c:\NameApplication\DB\(myDatabase.FDB (firebird))
c:\NameApplication\DM\(all my DataModules)
etc...
So, my project stay clean and easy for maintenance
1 - 1 DataModule for "my components of Support" (all components that not use Database needs) - my "dmSuporteGeral.pas"
ex.: TdxSkinController for example... etc!
2 - 1 DataModule for "my components for Database manipulation" (all components that use Database needs) - my "dmDBprincipal.pas"
ex.: TFIBTable, TFIBDatabase, etc...!
3 - 1 Form with definitions general to create anothers forms in my projects. I always call it of: fFRMBaseGeral.pas
ex.: this form will content my primary definitions, as: TdxRibbon, TdxRibbonStatusBar, TdxBarManager (important for dxRibbon use), etc...
and my events implementation, as: onFormCreate, onFormClose, etc...
Without TdxBarManager component in your project with TdxRibbon, you'll have a "Access Violation" error!
4 - So, we have: 2 DataModule and 1 Form (primary)
5 - My fFRMBaseGeral is descendent from "TdxRibbonForm", or be, TfFRMBaseGeral = class(TdxRibbonForm). So, I can use all property and another definitions from
"DevExpress Form", as the property: DisableAero := True;
6 - The sequence for "AUTO-CREATE FORMS" is only 2 forms (1 datamodule and 1 form):
1º - DMSuporte
2º - FRMMainExec (my form main)
The Form "FRMBaseGeral" is not AUTO-CREATED ok!, as anothers forms in project!
7 - In my example, see that I use just little components ok!
------------------------- My DataModule Support Generic ------------- AUTO-CREATE --------------------
---------------------------- My Form Base to all anothers Forms ------------- NOT AUTO-CREATE -----------------
------------------------------- MY GENERIC UNIT TO ALL MY FUNCTIONS -----------------------------------------------------
****************************************************************************************************************************
NOTE SPECIAL ABOUT HOW TO DO ONE FORM BASE (AS MY PROJECT)
1 - create 1 Form (as normally) with your attribute needs (as, Ribbom, BarManager, etc...)
2 - add in "Uses clausule INTERFACE the reference to unit "dxRibbonForm"
3 - change the CLASS original "TfFRMBaseGeral = class(TForm)" to "TfFRMBaseGeral = class(TdxRibbonForm)"
4 - now, create another form for be the "MAIN FORM" - this form should be INHERITED from "fFRMBASEGERAL"
5 - change in "PROJECT -> OPTION -> FORMS -> Main Form" the Form main for the new Form (in my case "FRMMainExec")
6 - I use, just, the DataModule and FormMain as AUTO-CREATE! The another Forms, will be "not-AUTO-CREATED"
NOTE: Only do changes in the FRMBaseGeral in ultimate case, because you can to promove errors in chain in the anothers Forms
****************************************************************************************************************************
-------------------------------- TEXT FORM to my FORM
0 - my Directory Structure:
c:\NameApplication\PRJ\(my project files and sub-folders (Win32\Debug or Release, example) to DCU and another binary files)
c:\NameApplication\EXE\(my app.exe)
c:\NameApplication\SKN\(all *.SKINRES files, except ALLSKINS.SKINRES hehehehe)
c:\NameApplication\FRM\(all *.frm and .pas files)
c:\NameApplication\DB\(myDatabase.FDB (firebird))
c:\NameApplication\DM\(all my DataModules)
etc...
So, my project stay clean and easy for maintenance
1 - 1 DataModule for "my components of Support" (all components that not use Database needs) - my "dmSuporteGeral.pas"
ex.: TdxSkinController for example... etc!
2 - 1 DataModule for "my components for Database manipulation" (all components that use Database needs) - my "dmDBprincipal.pas"
ex.: TFIBTable, TFIBDatabase, etc...!
3 - 1 Form with definitions general to create anothers forms in my projects. I always call it of: fFRMBaseGeral.pas
ex.: this form will content my primary definitions, as: TdxRibbon, TdxRibbonStatusBar, TdxBarManager (important for dxRibbon use), etc...
and my events implementation, as: onFormCreate, onFormClose, etc...
Without TdxBarManager component in your project with TdxRibbon, you'll have a "Access Violation" error!
4 - So, we have: 2 DataModule and 1 Form (primary)
5 - My fFRMBaseGeral is descendent from "TdxRibbonForm", or be, TfFRMBaseGeral = class(TdxRibbonForm). So, I can use all property and another definitions from
"DevExpress Form", as the property: DisableAero := True;
6 - The sequence for "AUTO-CREATE FORMS" is only 2 forms (1 datamodule and 1 form):
1º - DMSuporte
2º - FRMMainExec (my form main)
The Form "FRMBaseGeral" is not AUTO-CREATED ok!, as anothers forms in project!
7 - In my example, see that I use just little components ok!
------------------------- My DataModule Support Generic ------------- AUTO-CREATE --------------------
Code:
unit uDMSuporte;
interface
uses
System.SysUtils, System.Classes, Vcl.Dialogs, Vcl.Forms, {for use generic = procedures, functions, variables, consts, etc...}
//
dxSkinsCore, cxClasses, cxLookAndFeels, dxSkinsForm {because of Skins components hehehe}
//
;
type
TDMSuporte = class(TDataModule)
dxSkinController1: TdxSkinController; // component
procedure DataModuleCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
DMSuporte: TDMSuporte;
implementation
{ %CLASSGROUP 'Vcl.Controls.TControl' } // for use of "Pallete Controls"
{$R *.dfm}
uses
uFNCgeral; //my generic unit of functions
procedure TDMSuporte.DataModuleCreate(Sender: TObject);
begin
//
// DMSuporte.dxSkinController1.SkinName := 'UserSkin';
//
if dxSkinController1.UseSkins then
UsarSkinsNoAplicativo; //procedure in "uFNCgeral.pas"
end;
end.
---------------------------- My Form Base to all anothers Forms ------------- NOT AUTO-CREATE -----------------
Code:
unit uFRMBaseGeral;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
//
cxControls, cxClasses, cxGraphics, cxLookAndFeels,
//
cxLookAndFeelPainters, dxSkinsDefaultPainters, dxSkinsdxBarPainter, {Painters needs for my project}
dxSkinsdxRibbonPainter,
//
dxSkinsCore, dxRibbonSkins,
//
dxRibbonCustomizationForm, dxRibbon, dxBar, dxStatusBar, dxRibbonStatusBar,
//
dxRibbonForm {Class parent of my Main Form}
//
;
type
TfFRMBaseGeral = class(TdxRibbonForm) // my form (class) inherited
dxRibbon1: TdxRibbon; // component
dxRibbonStatusBar1: TdxRibbonStatusBar; // component
dxBarManager1: TdxBarManager; // component
procedure FormCreate(Sender: TObject); // event onCreate
private
{ Private declarations }
public
{ Public declarations }
end;
var
fFRMBaseGeral: TfFRMBaseGeral;
implementation
{$R *.dfm}
uses uDMSuporte, uFNCgeral;
procedure TfFRMBaseGeral.FormCreate(Sender: TObject);
begin
DisableAero := True; //important for use the new layout of forms using DevExpress
//
if bCarregadoSkinLoadFromFile then //defined in "uFNCgeral.pas"
dxRibbon1.ColorSchemeName := sdxSkinsUserSkinName; //const with SkinName
{
As all forms are INHERITED from FRMBASEGERAL, so, all form will have the same appearance in basic components inherited!
}
end;
end.
--------------------------- My Forms Main = my Application Form ------------ AUTO-CREATE -----------------
unit uFRMMainExec;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
//
uFRMBaseGeral, {my Form parent - general for all another forms in project}
//
cxGraphics, cxControls, cxLookAndFeels,
//
cxLookAndFeelPainters, dxSkinsdxRibbonPainter, dxSkinsdxBarPainter, dxSkinsDefaultPainters, {Painters}
//
dxRibbonSkins, dxSkinsCore, , dxSkinMcSkin,
//
dxRibbonCustomizationForm, dxRibbonStatusBar, dxRibbon,
//
cxClasses, dxBar, dxStatusBar
//
;
type
TfFRMMainExec = class(TfFRMBaseGeral) //inherited class
procedure FormCreate(Sender: TObject); //event onCreate
private
{ Private declarations }
public
{ Public declarations }
end;
var
fFRMMainExec: TfFRMMainExec;
implementation
{$R *.dfm}
procedure TfFRMMainExec.FormCreate(Sender: TObject);
begin
inherited;
WindowState := wsMaximized; // definided in Desig as "Position = poScreenCenter" for all forms and only here as wsMaximized (why? anwser...)
end;
end.
------------------------------- MY GENERIC UNIT TO ALL MY FUNCTIONS -----------------------------------------------------
Code:
unit uFNCgeral;
interface // here definitions for "GLOBAL use" in my project, as PUBLIC definitions
//uses = not needs for while
procedure UsarSkinsNoAplicativo;
var
bCarregadoSkinLoadFromFile: Boolean = false;
implementation //LOCAL definitions of the implementation
uses
System.SysUtils, Vcl.Forms, {for use generic = procedures, functions, variables, consts, etc...}
//
uDMSuporte, {DataModule of Support}
//
dxSkinsDefaultPainters; {Painters}
procedure UsarSkinsNoAplicativo;
var
sCaminhoExecutavel : String; //path of my EXE
sSkinArquivo, sSkinNome: String; //Skin names (file and skin in use)
i1, i2 : Integer;
begin
{ sdxSkinsUserSkinName = variable with SkinName in use (in "dxSkinsDefaultPainters.pas")
dxSkinsUserSkinLoadFromFile('filexxxx.SKINRES') = boolean return
dxSkinController1.Refresh = force update components skinned, if needs}
// --------------------------------------------------------------------
//
try
sSkinArquivo := 'Pumpkin.skinres'; // my preference hehehe
sSkinNome := 'Pumpkin';
//
sCaminhoExecutavel := ExtractFilePath(Application.ExeName);
i1 := Length(sCaminhoExecutavel);
i2 := Pos('\EXE\', sCaminhoExecutavel);
Delete(sCaminhoExecutavel, i2, (i1 - i2)); //delete char not needs = '\EXE\' for to use 'SKN\' = my path of files .SKINRES
//
if FileExists(sCaminhoExecutavel + 'SKN\' + sSkinArquivo, false) then
bCarregadoSkinLoadFromFile := dxSkinsUserSkinLoadFromFile(sCaminhoExecutavel + 'SKN\' + sSkinArquivo, sSkinNome) {if not error = true}
else
DMSuporte.dxSkinController1.UseSkins := false; //if error, disable Skin use in application
finally
end;
end;
end.
****************************************************************************************************************************
NOTE SPECIAL ABOUT HOW TO DO ONE FORM BASE (AS MY PROJECT)
1 - create 1 Form (as normally) with your attribute needs (as, Ribbom, BarManager, etc...)
2 - add in "Uses clausule INTERFACE the reference to unit "dxRibbonForm"
3 - change the CLASS original "TfFRMBaseGeral = class(TForm)" to "TfFRMBaseGeral = class(TdxRibbonForm)"
4 - now, create another form for be the "MAIN FORM" - this form should be INHERITED from "fFRMBASEGERAL"
5 - change in "PROJECT -> OPTION -> FORMS -> Main Form" the Form main for the new Form (in my case "FRMMainExec")
6 - I use, just, the DataModule and FormMain as AUTO-CREATE! The another Forms, will be "not-AUTO-CREATED"
NOTE: Only do changes in the FRMBaseGeral in ultimate case, because you can to promove errors in chain in the anothers Forms
****************************************************************************************************************************
-------------------------------- TEXT FORM to my FORM
Code:
"FRMBaseGeral.DFM" -----------------------
object fFRMBaseGeral: TfFRMBaseGeral
Left = 0
Top = 0
BorderIcons = []
BorderStyle = bsDialog
Caption = 'fFRMBaseGeral'
ClientHeight = 444
ClientWidth = 750
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
ShowHint = True
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object dxRibbon1: TdxRibbon
Left = 0
Top = 0
Width = 750
Height = 27
ApplicationButton.Visible = False
BarManager = dxBarManager1
ColorSchemeName = 'Blue'
EnableTabAero = False
QuickAccessToolbar.Visible = False
ShowMinimizeButton = False
ShowTabGroups = False
SupportNonClientDrawing = True
Contexts = <>
TabOrder = 0
TabStop = False
end
object dxRibbonStatusBar1: TdxRibbonStatusBar
Left = 0
Top = 421
Width = 750
Height = 23
Panels = <>
Ribbon = dxRibbon1
Font.Charset = DEFAULT_CHARSET
Font.Color = clDefault
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
end
object dxBarManager1: TdxBarManager
AllowReset = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Segoe UI'
Font.Style = []
CanCustomize = False
Categories.Strings = (
'Default')
Categories.ItemsVisibles = (
2)
Categories.Visibles = (
True)
PopupMenuLinks = <>
ShowFullMenusAfterDelay = False
UseF10ForMenu = False
UseSystemFont = True
Left = 48
Top = 136
DockControlHeights = (
0
0
0
0)
end
end
---------------------- create by: File -> New -> Other -> Inheritable Items -> choice fFRMBaseGeral --------------------------
inherited fFRMMainExec: TfFRMMainExec
BorderIcons = [biSystemMenu, biMinimize, biMaximize]
BorderStyle = bsSizeable
Caption = 'fFRMMainExec'
ClientHeight = 445
ClientWidth = 729
ExplicitWidth = 745
ExplicitHeight = 484
PixelsPerInch = 96
TextHeight = 13
inherited dxRibbon1: TdxRibbon
Width = 729
ExplicitWidth = 729
end
inherited dxRibbonStatusBar1: TdxRibbonStatusBar
Top = 422
Width = 729
ExplicitTop = 422
ExplicitWidth = 729
end
inherited dxBarManager1: TdxBarManager
Left = 424
Top = 112
DockControlHeights = (
0
0
0
0)
end
end
-------------------------------------------
object DMSuporte: TDMSuporte
OldCreateOrder = False
OnCreate = DataModuleCreate
Height = 473
Width = 744
object dxSkinController1: TdxSkinController
SkinName = 'UserSkin'
Left = 56
Top = 16
end
end