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