mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-07 01:57:57 +02:00
IDE: focus editor window when file is opened from command line in IDEInstances (issue on MS Windows)
git-svn-id: trunk@50680 -
This commit is contained in:
parent
77a52ceced
commit
dd154546c3
@ -51,7 +51,7 @@ type
|
||||
TStartNewInstanceResult = (ofrStartNewInstance, ofrDoNotStart, ofrModalError,
|
||||
ofrForceSingleInstanceModalError, ofrNotResponding);
|
||||
TStartNewInstanceEvent = procedure(const aFiles: TStrings;
|
||||
var outResult: TStartNewInstanceResult) of object;
|
||||
var outResult: TStartNewInstanceResult; var outSourceWindowHandle: HWND) of object;
|
||||
TGetCurrentProjectEvent = procedure(var outProjectFileName: string) of object;
|
||||
|
||||
TMessageParam = record
|
||||
@ -737,6 +737,7 @@ var
|
||||
xResult: TStartNewInstanceResult;
|
||||
xFiles: TStrings;
|
||||
xParams: TMessageParams;
|
||||
xSourceWindowHandle: HWND = 0;
|
||||
begin
|
||||
xResult := ofrStartNewInstance;
|
||||
if Assigned(FStartNewInstanceEvent) then
|
||||
@ -744,7 +745,7 @@ begin
|
||||
xFiles := TStringList.Create;
|
||||
try
|
||||
TIDEInstances.AddFilesFromParams(aInParams, xFiles);
|
||||
FStartNewInstanceEvent(xFiles, xResult);
|
||||
FStartNewInstanceEvent(xFiles, xResult, xSourceWindowHandle);
|
||||
finally
|
||||
xFiles.Free;
|
||||
end;
|
||||
@ -752,7 +753,7 @@ begin
|
||||
|
||||
SetLength(xParams, 5);
|
||||
xParams[0] := TIDEInstances.MessageParam(PARAM_RESULT, IntToStr(Ord(xResult)));
|
||||
xParams[1] := TIDEInstances.MessageParam(PARAM_HANDLEBRINGTOFRONT, IntToStr(Application.MainFormHandle));
|
||||
xParams[1] := TIDEInstances.MessageParam(PARAM_HANDLEBRINGTOFRONT, IntToStr(xSourceWindowHandle)); // do not use Application.MainFormHandle here - it steals focus from active source editor
|
||||
xParams[2] := TIDEInstances.MessageParam(PARAM_MODALERRORMESSAGE, dlgRunningInstanceModalError);
|
||||
xParams[3] := TIDEInstances.MessageParam(PARAM_FORCEUNIQUEMODALERRORMESSAGE, dlgForceUniqueInstanceModalError);
|
||||
xParams[4] := TIDEInstances.MessageParam(PARAM_NOTRESPONDINGERRORMESSAGE, dlgRunningInstanceNotRespondingError);
|
||||
|
@ -186,7 +186,7 @@ type
|
||||
procedure HandleSelectFrame(Sender: TObject; var AComponentClass: TComponentClass);
|
||||
procedure OIChangedTimerTimer(Sender: TObject);
|
||||
procedure LazInstancesStartNewInstance(const aFiles: TStrings;
|
||||
var Result: TStartNewInstanceResult);
|
||||
var Result: TStartNewInstanceResult; var outSourceWindowHandle: HWND);
|
||||
procedure LazInstancesGetOpenedProjectFileName(var outProjectFileName: string);
|
||||
public
|
||||
// file menu
|
||||
@ -9400,7 +9400,7 @@ begin
|
||||
end;
|
||||
|
||||
procedure TMainIDE.LazInstancesStartNewInstance(const aFiles: TStrings;
|
||||
var Result: TStartNewInstanceResult);
|
||||
var Result: TStartNewInstanceResult; var outSourceWindowHandle: HWND);
|
||||
var
|
||||
xParams: TDoDropFilesAsyncParams;
|
||||
I: Integer;
|
||||
@ -9433,6 +9433,11 @@ begin
|
||||
Result := ofrStartNewInstance;
|
||||
end;
|
||||
|
||||
if (SourceEditorManager.ActiveSourceWindow <> nil)
|
||||
and (SourceEditorManager.ActiveSourceWindow.HandleAllocated)
|
||||
then
|
||||
outSourceWindowHandle := SourceEditorManager.ActiveSourceWindow.Handle;
|
||||
|
||||
if Result in [ofrStartNewInstance, ofrModalError, ofrForceSingleInstanceModalError] then
|
||||
Exit;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user