Browse Source

Delphi IDE 2/3: add back VTI support *along with* (as opposed to "instead of") TIEmu support.

This patch adds back TMainForm.GetVTIWindow and uses in VTIStartUnit.

git-svn-id: file:///var/svn/tigccpp/branches/ide@1285 9552661e-59e3-4036-b4f2-dbe53926924f
debrouxl 15 years ago
parent
commit
70a81eaf7e
2 changed files with 44 additions and 8 deletions
  1. 33 0
      MainUnit.pas
  2. 11 8
      VTIStartUnit.pas

+ 33 - 0
MainUnit.pas

@@ -468,6 +468,7 @@ type
 		procedure SortFiles;
 		procedure DisplayFolderMessage;
 		procedure ClearDebugInfo;
+		function GetVTIWindow: HWnd;
 		function GetTiEmuInterface: ITiEmuOLE;
 		procedure SendFiles(FNList: array of string);
 		procedure ExecuteCommandLine(const Line: string);
@@ -4694,6 +4695,38 @@ begin
 	end;
 end;
 
+function TMainForm.GetVTIWindow: HWnd;
+begin
+	CurVTIType := cvVTINone;
+	Result := FindWindow ('TEmuWnd', 'Virtual TI-89');
+	if Result = 0 then begin
+		Result := FindWindow ('TEmuWnd', 'Virtual TI-92+');
+		if Result = 0 then begin
+			Result := FindWindow ('TEmuWnd', 'Virtual TI-92');
+			if Result <> 0 then
+				CurVTIType := cvVTITI92;
+		end else
+			CurVTIType := cvVTITI92Plus;
+	end else
+		CurVTIType := cvVTITI89;
+	if Result = 0 then begin
+		if Length (VTIPath) > 0 then begin
+			with TVTIStartForm.Create (Self) do try
+				if ShowModal = mrOK then begin
+					Result := VTIWindow;
+					CurVTIType := VTIType;
+				end else
+					Abort;
+			finally
+				Free;
+			end;
+		end else begin
+			ShowDefaultMessageBox ('Virtual TI is not running.', 'Error', mtProgramError);
+			Abort;
+		end;
+	end;
+end;
+
 function TMainForm.GetTiEmuInterface: ITiEmuOLE;
 var
 	Unknown: IUnknown;

+ 11 - 8
VTIStartUnit.pas

@@ -26,7 +26,7 @@ interface
 uses
 	MasterUnit,
 	Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
-	StdCtrls, ExtCtrls, ComObj, ActiveX, TiEmuOLELib_TLB;
+	StdCtrls, ExtCtrls;
 
 type
 	TVTIStartForm = class(TForm)
@@ -39,7 +39,8 @@ type
 	private
 		ProcessHandle: THandle;
 	public
-		TiEmuInterface: ITiEmuOLE;
+		VTIWindow: HWnd;
+		VTIType: TVTICalcType;
 	end;
 
 implementation
@@ -75,8 +76,6 @@ end;
 procedure TVTIStartForm.FindTimerTimer(Sender: TObject);
 var
 	ExitCode: Cardinal;
-	Unknown: IUnknown;
-	OLEResult: HResult;
 begin
 	if GetExitCodeProcess (ProcessHandle, ExitCode) then begin
 		if ExitCode <> STILL_ACTIVE then begin
@@ -84,11 +83,15 @@ begin
 			Exit;
 		end;
 	end;
-	OLEResult := GetActiveObject(CLASS_TiEmuOLE, nil, Unknown);
-	if OLEResult = S_OK then begin
-		OleCheck(Unknown.QueryInterface(ITiEmuOLE, TiEmuInterface));
+  VTIWindow := FindWindow ('TEmuWnd', 'Virtual TI-89');
+  if VTIWindow = 0 then begin
+    VTIWindow := FindWindow ('TEmuWnd', 'Virtual TI-92+');
+    if VTIWindow <> 0 then
+      VTIType := cvVTITI92Plus;
+  end else
+    VTIType := cvVTITI89;
+	if VTIWindow <> 0 then
 		ModalResult := mrOK;
-	end;
 end;
 
 end.