<< Click to Display Table of Contents >> Navigation: Technology Overview > Forms and Modules > MainModule |
Application MainModule
MainModule can be considered the heart of a session. It is a special purpose DataModule which is automatically created and added to the project each time a new project is created. MainModule has many important roles in a uniGUI application. Some of these roles are not visible to the developers. For developers, MainModule can be used to place resources shared by a session, such as database connections, shared variables, etc. For example, you can declare public variables in MainModule's public section and then access them from other forms in the session. The following 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 uniGUI Application Architecture.