MainModule

<< Click to Display Table of Contents >>

Navigation:  Technology Overview > Forms and Modules >

MainModule

Application MainModule

Application MainModule

 

 MainModule can be considered as heart of each session. It is a special purpose DataModule which is automatically created and added to project each time a new project is created. MainModule has a many important roles in a uniGUI application. Some of these roles are not visible to the developers. For developers MainModule can be a used a central module to place session's shared resources, such as database connections, shared variables and etc. For example, you can declare public variables in MainModule's public section and then access it from other forms in session. Below example demonstrates a common practice in uniGUI to share data among various forms in a session. Since each session has its private copy of MainModule it will be ensured that each form will access its private set of data in its session.

 

  TUniMainModule = class(TUniGUIMainModule)
  private
    { Private declarations }
  public
    { Public declarations }
    aUserName, aPassword: string;
  end;

 

Later you can access these variables from other forms in application:

 

procedure TMainForm.UniButton1Click(Sender: TObject);
begin
  UniLabel1.Caption := UniMainModule.aUserName + ' ' + UniMainModule.aPassword;
end;

 

Also see Web Sessions.