谁能让 MDI 中的子窗口 ShowModal
想达到什么效果?
如果一定要参照如下代码:
{*******************************************************}
{ }
{ ComQuery User Interface Classes }
{ }
{ Author 笑傲江湖 } }
{ 1999,2000 NARI IS Corporation }
{ }
{*******************************************************}
unit CQUIClses;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, ToolWin, StdCtrls, ExtCtrls;
type
TCQPropertyFormStyle = (pfNormal, pfDialog, pfNoCancelDialog, pfMDIChild, pfInside);
TCQPlusInfoFormClass = class of TCQPlusInfoForm;
TCQPlusInfoForm = class(TForm)
private
FPropertyFormStyle: TCQPropertyFormStyle;
protected
procedure CreateParams(var Params: TCreateParams); override;
public
constructor CustomCreate(AOwner: TComponent; AStyle: TCQPropertyFormStyle;
AParent: TWinControl; CustomData: array of const;
UseDefaultUI: Boolean = True); virtual;
constructor CustomCreateByID(AOwner: TComponent; AStyle: TCQPropertyFormStyle;
AParent: TWinControl; CustomData: array of const; AID: Integer;
UseDefaultUI: Boolean = True); virtual;
destructor Destroy; override;
procedure RefreshFormControlsData(ANode: TTreeNode); overload; virtual;
procedure RefreshFormControlsData(); overload; virtual;
property PropertyFormStyle: TCQPropertyFormStyle read FPropertyFormStyle;
end;
TCQQryUnitInfoFormClass = class of TCQQryUnitInfoForm;
TCQQryUnitInfoForm = class(TCQPlusInfoForm)
private
FSql: string;
FSqlCache: string;
FQryUnitID: Integer;
FQryAppID: Integer;
public
property Sql: string read FSql write FSql;
property SqlCache: string read FSqlCache write FSqlCache;
property QryUnitID: Integer read FQryUnitID write FQryUnitID;
property QryAppID: Integer read FQryAppID write FQryAppID;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
end;
{------------------------------------------------------------------------------}
implementation
{------------------------------------------------------------------------------}
constructor TCQPlusInfoForm.CustomCreate(AOwner: TComponent; AStyle: TCQPropertyFormStyle;
AParent: TWinControl; CustomData: array of const; UseDefaultUI: Boolean = True);
begin
FPropertyFormStyle := AStyle;
Create(AOwner);
case AStyle of
pfNormal :
begin
if FormStyle <> fsNormal then FormStyle := fsNormal;
if BorderStyle <> bsSizeable then BorderStyle := bsSizeable;
Position := poScreenCenter;
end;
pfDialog..pfNoCancelDialog :
begin
if FormStyle <> fsNormal then FormStyle := fsNormal;
if BorderStyle <> bsDialog then BorderStyle := bsDialog;
Position := poScreenCenter;
end;
pfMDIChild :
begin
if FormStyle <> fsMDIChild then FormStyle := fsMDIChild;
if BorderStyle <> bsSizeable then BorderStyle := bsSizeable;
Position := poDefault;
end;
pfInside :
begin
BorderStyle := bsNone;
if AParent <> nil then Parent := AParent;
Align := alClient;
end;
end;
if UseDefaultUI then
begin
end;
end;
constructor TCQPlusInfoForm.CustomCreateByID(AOwner: TComponent; AStyle: TCQPropertyFormStyle;
AParent: TWinControl; CustomData: array of const; AID: Integer;
UseDefaultUI: Boolean = True);
begin
CustomCreate(AOwner, AStyle, AParent, CustomData, UseDefaultUI);
end;
destructor TCQPlusInfoForm.Destroy;
begin
inherited;
end;
procedure TCQPlusInfoForm.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params) ;
if FPropertyFormStyle = pfInside then
with Params do
begin
Style := Style and (not WS_CAPTION) and (not WS_SYSMENU);
Style := (Style or WS_CHILD) and (not WS_POPUP) ;
Style := Style or WS_TABSTOP ;
end;
end;
procedure TCQPlusInfoForm.RefreshFormControlsData(ANode: TTreeNode);
begin
end;
procedure TCQPlusInfoForm.RefreshFormControlsData();
begin
end;
{------------------------------------------------------------------------------}
constructor TCQQryUnitInfoForm.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FSql := '';
FSqlCache := '';
FQryUnitID := -1;
FQryAppID := -1;
end;
destructor TCQQryUnitInfoForm.Destroy;
begin
inherited;
end;
end.
调用实现:
function CQCreateDialogForm(AOwner: TComponent;
AFormClass: TCQPlusInfoFormClass; AParent: TWinControl): TCQPlusInfoForm;
begin
Result := AFormClass.CustomCreate(AOwner, pfDialog, AParent, []);
try
Result.ShowModal;
except
on E: Exception do CQShowMessage(E.message);
end;
end;
function CQCreateInsideForm(AOwner: TComponent;
AFormClass: TCQPlusInfoFormClass; AParent: TWinControl;
AComponentList: TComponentList): TCQPlusInfoForm;
begin
Result := AFormClass.CustomCreate(AOwner, pfInside, AParent, []);
try
Result.Show;
AComponentList.Add(Result);
except
on E: Exception do CQShowMessage(E.message);
end;
end;
function CQCreateInsideFormNotShow(AOwner: TComponent;
AFormClass: TCQQryUnitInfoFormClass; AParent: TWinControl;
AComponentList: TComponentList): TCQQryUnitInfoForm;
begin
Result := AFormClass.CustomCreate(AOwner, pfInside, AParent, []);
try
//Result.Show;
AComponentList.Add(Result);
except
on E: Exception do CQShowMessage(E.message);
end;
end;
procedure CQCreateMDIChildForm(AOwner: TComponent;
AFormClass: TCQPlusInfoFormClass; AParent: TWinControl);
begin
AFormClass.CustomCreate(AOwner, pfMDIChild, AParent, []).Show;
end;
procedure CQCreateMDIChildForm(AOwner: TComponent;
AFormClass: TCQPlusInfoFormClass; AParent: TWinControl; AID: Integer);
begin
AFormClass.CustomCreateByID(AOwner, pfMDIChild, AParent, [], AID).Show;
end;