mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-08 06:05:56 +02:00
LCL: Application.MainForm is now set before form handle is created
git-svn-id: trunk@10472 -
This commit is contained in:
parent
da0ece0f30
commit
db61aa7535
@ -557,6 +557,8 @@ type
|
|||||||
TForm = class(TCustomForm)
|
TForm = class(TCustomForm)
|
||||||
private
|
private
|
||||||
FClientHandle: HWND;
|
FClientHandle: HWND;
|
||||||
|
protected
|
||||||
|
procedure CreateWnd; override;
|
||||||
public
|
public
|
||||||
property ClientHandle: HWND read FClientHandle;
|
property ClientHandle: HWND read FClientHandle;
|
||||||
property DockManager;
|
property DockManager;
|
||||||
@ -880,6 +882,7 @@ type
|
|||||||
FApplicationHandlers: array[TApplicationHandlerType] of TMethodList;
|
FApplicationHandlers: array[TApplicationHandlerType] of TMethodList;
|
||||||
FApplicationType: TApplicationType;
|
FApplicationType: TApplicationType;
|
||||||
FCaptureExceptions: boolean;
|
FCaptureExceptions: boolean;
|
||||||
|
FCreatingForm: TForm;// currently created form (CreateForm), candidate for MainForm
|
||||||
FFindGlobalComponentEnabled: boolean;
|
FFindGlobalComponentEnabled: boolean;
|
||||||
FFlags: TApplicationFlags;
|
FFlags: TApplicationFlags;
|
||||||
FHint: string;
|
FHint: string;
|
||||||
@ -978,8 +981,9 @@ type
|
|||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure ControlDestroyed(AControl: TControl);
|
procedure ControlDestroyed(AControl: TControl);
|
||||||
Procedure BringToFront;
|
procedure BringToFront;
|
||||||
procedure CreateForm(InstanceClass: TComponentClass; var Reference);
|
procedure CreateForm(InstanceClass: TComponentClass; var Reference);
|
||||||
|
procedure UpdateMainForm(AForm: TForm);
|
||||||
procedure QueueAsyncCall(AMethod: TDataEvent; Data: PtrInt);
|
procedure QueueAsyncCall(AMethod: TDataEvent; Data: PtrInt);
|
||||||
procedure ReleaseComponent(AComponent: TComponent);
|
procedure ReleaseComponent(AComponent: TComponent);
|
||||||
function ExecuteAction(ExeAction: TBasicAction): Boolean; override;
|
function ExecuteAction(ExeAction: TBasicAction): Boolean; override;
|
||||||
|
@ -194,9 +194,8 @@ begin
|
|||||||
if Operation = opRemove then begin
|
if Operation = opRemove then begin
|
||||||
FLastMouseControlValid:=false;
|
FLastMouseControlValid:=false;
|
||||||
if AComponent=FMouseControl then FMouseControl:=nil;
|
if AComponent=FMouseControl then FMouseControl:=nil;
|
||||||
if AComponent = MainForm then begin
|
if AComponent=FCreatingForm then begin
|
||||||
FMainForm:= nil;
|
FCreatingForm:=nil;
|
||||||
Terminate;
|
|
||||||
end;
|
end;
|
||||||
if AComponent=FHintWindow then begin
|
if AComponent=FHintWindow then begin
|
||||||
FHintWindow:=nil;
|
FHintWindow:=nil;
|
||||||
@ -204,6 +203,10 @@ begin
|
|||||||
if AComponent=FHintTimer then begin
|
if AComponent=FHintTimer then begin
|
||||||
FHintTimer:=nil;
|
FHintTimer:=nil;
|
||||||
end;
|
end;
|
||||||
|
if AComponent = MainForm then begin
|
||||||
|
FMainForm:= nil;
|
||||||
|
Terminate;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -219,6 +222,7 @@ begin
|
|||||||
FLastMouseControlValid:=false;
|
FLastMouseControlValid:=false;
|
||||||
if AControl=FMouseControl then FMouseControl:=nil;
|
if AControl=FMouseControl then FMouseControl:=nil;
|
||||||
if AControl = MainForm then FMainForm:= nil;
|
if AControl = MainForm then FMainForm:= nil;
|
||||||
|
if AControl = FCreatingForm then FCreatingForm:= nil;
|
||||||
if Screen.FActiveControl = AControl then Screen.FActiveControl := nil;
|
if Screen.FActiveControl = AControl then Screen.FActiveControl := nil;
|
||||||
if Screen.FActiveCustomForm = AControl then
|
if Screen.FActiveCustomForm = AControl then
|
||||||
begin
|
begin
|
||||||
@ -1551,20 +1555,23 @@ begin
|
|||||||
|
|
||||||
ok:=false;
|
ok:=false;
|
||||||
try
|
try
|
||||||
|
if (FCreatingForm=nil) and (Instance is TForm) then
|
||||||
|
FCreatingForm:=TForm(Instance);
|
||||||
Instance.Create(Self);
|
Instance.Create(Self);
|
||||||
ok:=true;
|
ok:=true;
|
||||||
finally
|
finally
|
||||||
if not ok then
|
if not ok then begin
|
||||||
TComponent(Reference) := nil;
|
TComponent(Reference) := nil;
|
||||||
|
if FCreatingForm=Instance then
|
||||||
|
FCreatingForm:=nil;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (Instance is TForm) then begin
|
if (Instance is TForm) then begin
|
||||||
AForm:=TForm(Instance);
|
AForm:=TForm(Instance);
|
||||||
if (FMainForm = nil) and not (AForm.FormStyle in [fsMDIChild, fsSplash])
|
UpdateMainForm(AForm);
|
||||||
then begin
|
if FMainForm = AForm then
|
||||||
FMainForm := AForm;
|
|
||||||
AForm.HandleNeeded;
|
AForm.HandleNeeded;
|
||||||
end;
|
|
||||||
if not Assigned(FFormList) then
|
if not Assigned(FFormList) then
|
||||||
FFormList := TList.Create;
|
FFormList := TList.Create;
|
||||||
FFormList.Add(AForm);
|
FFormList.Add(AForm);
|
||||||
@ -1582,6 +1589,16 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TApplication.UpdateMainForm(AForm: TForm);
|
||||||
|
begin
|
||||||
|
if (FMainForm = nil)
|
||||||
|
and (FCreatingForm=AForm)
|
||||||
|
and (not (AppDestroying in FFlags))
|
||||||
|
and not (AForm.FormStyle in [fsMDIChild, fsSplash])
|
||||||
|
then
|
||||||
|
FMainForm := AForm;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TApplication.QueueAsyncCall(AMethod: TDataEvent; Data: PtrInt);
|
procedure TApplication.QueueAsyncCall(AMethod: TDataEvent; Data: PtrInt);
|
||||||
var
|
var
|
||||||
lItem: PAsyncCallQueueItem;
|
lItem: PAsyncCallQueueItem;
|
||||||
|
@ -1992,6 +1992,17 @@ end;
|
|||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
|
{ TForm }
|
||||||
|
|
||||||
|
procedure TForm.CreateWnd;
|
||||||
|
begin
|
||||||
|
if (Application<>nil) then
|
||||||
|
Application.UpdateMainForm(TForm(Self));
|
||||||
|
inherited CreateWnd;
|
||||||
|
end;
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
{ TFormPropertyStorage }
|
{ TFormPropertyStorage }
|
||||||
|
|
||||||
procedure TFormPropertyStorage.FormFirstShow(Sender: TObject);
|
procedure TFormPropertyStorage.FormFirstShow(Sender: TObject);
|
||||||
|
@ -59,7 +59,7 @@ type
|
|||||||
|
|
||||||
EDBEditError = class(Exception);
|
EDBEditError = class(Exception);
|
||||||
|
|
||||||
TMbcsByteType = (mbSingleByte, mbLeadByte, mbTrailByte);
|
//TMbcsByteType = (mbSingleByte, mbLeadByte, mbTrailByte);
|
||||||
|
|
||||||
|
|
||||||
{ TCustomMaskEdit }
|
{ TCustomMaskEdit }
|
||||||
@ -194,8 +194,10 @@ function MaskGetFldSeparator(const EditMask: string): Integer;
|
|||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
RegisterComponents('Additional',[TMaskEdit]);
|
RegisterComponents('Additional',[TMaskEdit]);
|
||||||
@ -204,10 +206,6 @@ end;
|
|||||||
function ByteType(const S: string; Index: Integer): TMbcsByteType;
|
function ByteType(const S: string; Index: Integer): TMbcsByteType;
|
||||||
begin
|
begin
|
||||||
Result := mbSingleByte;
|
Result := mbSingleByte;
|
||||||
{ ToDo:
|
|
||||||
if SysLocale.FarEast then
|
|
||||||
Result := ByteTypeTest(PChar(S), Index-1);
|
|
||||||
}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function MaskGetCharType(const EditMask: string; MaskOffset: Integer): TMaskCharType;
|
function MaskGetCharType(const EditMask: string; MaskOffset: Integer): TMaskCharType;
|
||||||
|
Loading…
Reference in New Issue
Block a user