From 868daf94f29ce1ffdd799a68c07bb668cd373bcd Mon Sep 17 00:00:00 2001 From: HP\李良庭 <liliangting@lanpucloud.cn:1111> Date: 星期二, 08 七月 2025 11:49:03 +0800 Subject: [PATCH] 提交分辨率自适应版本V3.1.0.1500 --- demo/TabTip/Unit1.pas | 88 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 88 insertions(+), 0 deletions(-) diff --git a/demo/TabTip/Unit1.pas b/demo/TabTip/Unit1.pas new file mode 100644 index 0000000..027c580 --- /dev/null +++ b/demo/TabTip/Unit1.pas @@ -0,0 +1,88 @@ +unit Unit1; + +interface + +uses + Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, TlHelp32, // 用于进程操作 + ShellAPI, ComObj, ActiveX; + +type + TForm1 = class(TForm) + Button1: TButton; + Edit1: TEdit; + procedure Button1Click(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; + +var + Form1: TForm1; + +implementation + +{$R *.dfm} + +procedure KillTabTipProcess; +var + ContinueLoop: BOOL; + FSnapshotHandle: THandle; + FProcessEntry32: TProcessEntry32; + hProcess: THandle; +begin + FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if FSnapshotHandle <> INVALID_HANDLE_VALUE then + begin + FProcessEntry32.dwSize := SizeOf(FProcessEntry32); + ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32); + + while ContinueLoop do + begin + if ('TabTip.exe' = string(FProcessEntry32.szExeFile)) then + begin + hProcess := OpenProcess(PROCESS_TERMINATE, False, FProcessEntry32.th32ProcessID); + if hProcess <> 0 then + begin + TerminateProcess(hProcess, 0); + CloseHandle(hProcess); + end; + end; + ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); + end; + CloseHandle(FSnapshotHandle); + end; +end; + +procedure OpenTabTip; +var + TabTipPath: string; + Tip: OleVariant; +begin + TabTipPath := 'C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe'; + + Writeln('IsNewVisable show TabTip'); + CoInitialize(nil); + try + Tip := CreateComObject(CLSID_UIHostNoLaunch) as IDispatch; + if VarIsClear(Tip) then + begin + Writeln('tip is nullptr'); + Exit; + end; + (Tip as ITipInvocation).Toggle(GetDesktopWindow); // 显示触摸键盘 + finally + CoUninitialize; + end; + +end; + +procedure TForm1.Button1Click(Sender: TObject); +begin + KillTabTipProcess; // 确保没有残留的TabTip进程 + //ShellExecute(0, nil, 'C:\Program Files\Common Files\Microsoft Shared\ink\TabTip.exe', nil, nil, SW_SHOWNORMAL); + OpenTabTip; +end; + +end. -- Gitblit v1.9.3