Title: Writing MS outlook style apps
Question: Want to write applications which look like MS outlook and doesn't clutter entire screen with many windows?
Answer:
Design your forms as usually, but set every form's BorderStyle=bsNone except main form.
Then in the main form you need to drop a panel which will serve as placeholder for your data entry/edit forms.
In your main form you need to write something similar as below.
acXxxxx are the actions which execute when you click an element (menu item, button, speed button etc) associated with that action via Action property.
=================
TfrmIMMain
......................
private
(*
used to make an app to fill entire screen...
for explanation see my article "Make your app to fill entire screen excluding taskbar"
*)
procedure WMSettingChange( var Msg: TMessage);message WM_SETTINGCHANGE;
public
ActiveDetailForm: TForm;//Form which is currently active
procedure SetActiveDetailForm(F: TForm; ParentControl: TWinControl);
end;
var
frmIMMain: TfrmIMMain;
implementation
uses imdata, imSoftL, imSuppl, imEqDet, imDesk, imSpareP, imCateg,
imLocL, imUserL, imEqList, imEqByUsr, imImpBlb, imSftLic, imSupL,
imEqDetR, imRptPrm, imdmRep, imSftLicRepPrm, imSparePR, imSparePPrm,
imSftDetR, imSoftDetRPrmDlg;
{$R *.DFM}
// for explanation read my article at delphi3000.com ....
function GetWindowsWorkArea: TRect;
begin
SystemParametersInfo(SPI_GETWORKAREA, 0, @Result, 0);
end;
procedure TfrmIMMain.WMSettingChange( var Msg: TMessage);
var
R: TRect;
begin
if (Msg.WParam=SPI_SETWORKAREA) then
begin
R:=GetWindowsWorkArea;
SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top);
end;
Msg.Result:=0;
end;
procedure TfrmIMMain.FormCreate(Sender: TObject);
var
R: TRect;
begin
// fill entire screen....
R:=GetWindowsWorkArea;
SetBounds(R.Left, R.Top, R.Right-R.Left, R.Bottom-R.Top);
end;
// show Software List form
procedure TfrmIMMain.acSoftwareListExecute(Sender: TObject);
begin
if (Sender is TAction) then
begin
(Sender as TAction).Checked:=True;
fcbSoftList.Down:=True;
end;
//paWorkArea is the panel which is used as a placeholder for forms
SetActiveDetailForm(frmIMSoftList, paWorkArea);
end;
// show equipment details form...
procedure TfrmIMMain.acEquipmentDetailsExecute(Sender: TObject);
begin
if (Sender is TAction) then
begin
(Sender as TAction).Checked:=True;
fcbEqDet.Down:=True;
end;
SetActiveDetailForm(frmIMEqDet, paWorkArea);
end;
// set Active form to look like in MS outlook.......
// ParentControl is TPanel, but it could be any windowed control (which has
window Handle property)
procedure TfrmIMMain.SetActiveDetailForm(F: TForm; ParentControl:
TWinControl);
begin
if ActiveDetailFormF then
begin
if Assigned(ActiveDetailForm) then
ActiveDetailForm.Hide;
//the following two lines do what we need...
F.Parent:=ParentControl;
F.Align:=alClient;
ActiveDetailForm:=F;
F.Show;
end;
end;
procedure TfrmIMMain.FormActivate(Sender: TObject);
begin
//set the default form on startup.
if not Assigned(ActiveDetailForm) then
acEquipmentDetailsExecute(acEquipmentDetails);
end;