Browse Source

增加虚拟键盘的处理

张洋 1 week ago
parent
commit
9ce30c90f8

+ 0 - 102
bin/Win32/Debug/zhipuzi_pos_windows/skin/virtual_keyboard.xml

@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Window size="780,225" caption="0,0,0,16" roundcorner="3,3" shadowsize="3" showshadow="true">
-     <Font id="0" name="微软雅黑" size="16" default="true" />
-     <VerticalLayout bkcolor="#FF000000">
-          <HorizontalLayout height="16" bkcolor="#FF000000">
-               <Control />
-      <Button name="closebtn" text="X" width="24" height="15" bkcolor="#FF000000" 
-           textcolor="#FFFFFFFF" align="center"/>
-    </HorizontalLayout>
-
-     <HorizontalLayout height="49" childpadding="7" padding="2,2,2,2">
-      <Button name="btn_q" text="q" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_w" text="w" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_e" text="e" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_r" text="r" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_t" text="t" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_y" text="y" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_u" text="u" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_i" text="i" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_o" text="o" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_p" text="p" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_backspace" text="Backspace" width="122" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-    </HorizontalLayout>
-
-     <HorizontalLayout height="49" childpadding="7" padding="2,2,2,2">
-      <Control width="33" height="45" bkcolor="#FF000000"/>
-      <Button name="btn_a" text="a" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_s" text="s" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_d" text="d" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_f" text="f" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_g" text="g" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_h" text="h" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_j" text="j" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_k" text="k" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_l" text="l" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-     <Button name="btn_apos" text="&apos;" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_enter" text="Enter" width="106" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-    </HorizontalLayout>
-
-     <HorizontalLayout height="49" childpadding="7" padding="2,2,2,2">
-      <Button name="btn_shift_l" text="Shift" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_z" text="z" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_x" text="x" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_c" text="c" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_v" text="v" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_b" text="b" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_n" text="n" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_m" text="m" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_comma" text="," width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_dot" text="." width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_question" text="?" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_shift_r" text="Shift" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-    </HorizontalLayout>
-
-     <HorizontalLayout height="49" childpadding="7" padding="2,2,2,2">
-      <Button name="btn_num_symbol" text="123" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_ctrl" text="Ctrl" width="53" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_handwriting" text="手写板" width="98" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_space" text="空格" width="376" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-      <Button name="btn_switch_ime" text="中/英" width="98" height="45" bkcolor="#FF302F37" 
-           textcolor="#FFFFFFFF" align="center"/>
-    </HorizontalLayout>
-  </VerticalLayout>
-</Window>

+ 0 - 79
zhipuzi_pos_windows/control/CAIXuexiPageFoodItemUI.cpp

@@ -1,79 +0,0 @@
-#include "CAIXuexiPageFoodItemUI.h"
-
-#include "../pch/pch.h"
-
-CAIXuexiPageFoodItemUI::CAIXuexiPageFoodItemUI()
-{
-
-}
-
-
-CAIXuexiPageFoodItemUI::~CAIXuexiPageFoodItemUI()
-{
-}
-
-void CAIXuexiPageFoodItemUI::DoEvent(TEventUI& event)
-{
-	if (event.Type == UIEVENT_BUTTONUP)
-	{
-		m_pManager->SendNotify(this, DUI_MSGTYPE_CLICK);
-	}
-	else if (event.Type == UIEVENT_MOUSEENTER)
-	{
-		HCURSOR hcur = LoadCursor(NULL, IDC_HAND);  //加载系统自带鼠标样式
-		HWND hwnd = m_pManager->GetPaintWindow(); // 获取绘图窗口句柄
-		//SetClassLong(hwnd, GCL_HCURSOR, (long)hcur);
-	}
-	else if (event.Type == UIEVENT_MOUSELEAVE)
-	{
-		HCURSOR hcur = LoadCursor(NULL, IDC_ARROW);  //加载系统自带鼠标样式
-		HWND hwnd = m_pManager->GetPaintWindow(); // 获取绘图窗口句柄
-		//SetClassLong(hwnd, GCL_HCURSOR, (long)hcur);
-	}
-
-	CVerticalLayoutUI::DoEvent(event);
-}
-
-void CAIXuexiPageFoodItemUI::SetFoodInfo(CFood info)
-{
-	m_foodinfo = info;
-}
-
-CFood CAIXuexiPageFoodItemUI::GetFoodInfo()
-{
-	return m_foodinfo;
-}
-
-void CAIXuexiPageFoodItemUI::UpdateShow()
-{
-	if (m_is_youtu)
-	{
-		CControlUI* pImage = static_cast<CControlUI*>(this->FindSubControl(_T("image")));
-
-		//获取本地图片的路径
-		std::wstring imagepath = m_foodinfo.getImageTmpPath();
-		if (CSystem::IsFileExist(imagepath.c_str()))
-		{
-			//图片已经存在,直接显示
-			pImage->SetBkImage(imagepath.c_str());
-		}
-	}
-
-	CLabelUI* pName = static_cast<CLabelUI*>(this->FindSubControl(_T("foodname")));
-	pName->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.name).c_str());
-
-	CLabelUI* pPrice = static_cast<CLabelUI*>(this->FindSubControl(_T("price")));
-
-	std::wstring price = L"¥" + CLewaimaiString::UTF8ToUnicode(m_foodinfo.price);
-	if (m_foodinfo.is_nature == "1")
-	{
-		price += L"起";
-	}
-
-	pPrice->SetText(price.c_str());
-}
-
-void CAIXuexiPageFoodItemUI::SetYoutuModel(bool is_youtu)
-{
-	m_is_youtu = is_youtu;
-}

+ 0 - 34
zhipuzi_pos_windows/control/CAIXuexiPageFoodItemUI.h

@@ -1,34 +0,0 @@
-#pragma once
-
-#include "../pch/pch.h"
-
-#include "../zhipuzi/CFood.h"
-#include "../zhipuzi/CFoodpackage.h"
-
-
-/**
- * 商品和商品套餐的ITEM,都用这个
- */
-class CAIXuexiPageFoodItemUI : public CVerticalLayoutUI
-{
-public:
-	CAIXuexiPageFoodItemUI();
-	~CAIXuexiPageFoodItemUI();
-
-	void DoEvent(TEventUI& event);
-
-	void SetFoodInfo(CFood info);
-
-	CFood GetFoodInfo();
-
-	//刷新显示
-	void UpdateShow();
-
-	void SetYoutuModel(bool is_youtu);
-
-private:
-	CFood m_foodinfo;
-
-	//默认有图模式
-	bool m_is_youtu = true;
-};

+ 0 - 5
zhipuzi_pos_windows/control/ControlEx.h

@@ -37,7 +37,6 @@
 #include "CZhengcanOrderItemUI.h"
 #include "CShoukuanOrderItemUI.h"
 #include "CFoodXuexiImageItemUI.h"
-#include "CAIXuexiPageFoodItemUI.h"
 
 class CDialogBuilderCallbackEx : public IDialogBuilderCallback
 {
@@ -183,10 +182,6 @@ public:
 		{
 			return new CFoodXuexiImageItemUI;
 		}
-		else if (_tcscmp(pstrClass, _T("AIXuexiFoodItem")) == 0)
-		{
-			return new CAIXuexiPageFoodItemUI;
-		}
 
 		return NULL;
 	}

+ 242 - 4
zhipuzi_pos_windows/helper/CSystem.cpp

@@ -293,7 +293,7 @@ BOOL CSystem::IsAppRunning()
 
 void CSystem::RunHotKey(int mod, int key)
 {
-	BYTE mod_key;
+	BYTE mod_key = 0;
 
 	if (mod == 1)
 	{
@@ -320,14 +320,19 @@ DWORD CSystem::GetWindowsMajorVersion()
 	using RtlGetVersionFn = LONG(WINAPI*)(OSVERSIONINFOW*);
 
 	const HMODULE ntdll = ::GetModuleHandleW(L"ntdll.dll");
-	const auto rtlGetVersion = reinterpret_cast<RtlGetVersionFn>(
-		::GetProcAddress(ntdll, "RtlGetVersion"));
+	if (ntdll == nullptr)
+	{
+		return 0;
+	}
 
-	if (rtlGetVersion == nullptr)
+	const FARPROC proc = ::GetProcAddress(ntdll, "RtlGetVersion");
+	if (proc == nullptr)
 	{
 		return 0;
 	}
 
+	const auto rtlGetVersion = reinterpret_cast<RtlGetVersionFn>(proc);
+
 	OSVERSIONINFOW versionInfo = {};
 	versionInfo.dwOSVersionInfoSize = sizeof(versionInfo);
 
@@ -361,3 +366,236 @@ std::wstring CSystem::GetTouchKeyboardPath()
 
 	return L"";
 }
+
+// 设置开关:enable=true 全部开启,false 全部关闭
+bool CSystem::SetTouchKeyboardAutoInvoke(bool enable)
+{
+	std::wstring kRegPath = L"Software\\Microsoft\\TabletTip\\1.7";
+
+	std::vector<std::wstring> valuesToSet;
+	if (CSystem::GetWindowsMajorVersion() < 10)
+	{
+		// Win7:控制"文本框旁边图标"需要这 4 个值
+		valuesToSet = {
+			L"ShowIPTIPTouchTarget",
+			L"EnableEdgeTarget",
+			L"EnableFloatingTIPAnimation",
+			L"HideEdgeTabOnPenOutOfRange"
+		};
+	}
+	else
+	{
+		valuesToSet.push_back(L"EnableDesktopModeAutoInvoke");
+	}
+
+	HKEY hKey = nullptr;
+	LONG result = RegCreateKeyExW(
+		HKEY_CURRENT_USER, kRegPath.c_str(), 0, nullptr,
+		REG_OPTION_NON_VOLATILE, KEY_SET_VALUE | KEY_WOW64_64KEY,
+		nullptr, &hKey, nullptr);
+	if (result != ERROR_SUCCESS) return false;
+
+	DWORD value = enable ? 1u : 0u;
+	for (const auto& name : valuesToSet)
+	{
+		RegSetValueExW(hKey, name.c_str(), 0, REG_DWORD,
+			reinterpret_cast<BYTE*>(&value), sizeof(value));
+	}
+	RegCloseKey(hKey);
+
+	// Win7 上必须重启 TabTip
+	if (CSystem::GetWindowsMajorVersion() < 10)
+	{
+		CSystem::RestartWin7TabTip();
+	}
+
+	DWORD_PTR dwResult = 0;
+	SendMessageTimeoutW(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
+		reinterpret_cast<LPARAM>(kRegPath.c_str()),
+		SMTO_ABORTIFHUNG, 5000, &dwResult);
+	return true;
+}
+
+
+// 读取当前状态,未设置时默认 true
+// Win7 下两个值都为 1 才算开启;任一为 0 即视为关闭
+bool CSystem::GetTouchKeyboardAutoInvoke(bool* enabled)
+{
+	// 注册表路径
+	std::wstring kRegPath = L"Software\\Microsoft\\TabletTip\\1.7";
+
+	std::vector<std::wstring> valuesToRead;
+	if (CSystem::GetWindowsMajorVersion() < 10)
+	{
+		valuesToRead.push_back(L"InPlaceUI");
+		valuesToRead.push_back(L"TipbandDesiredVisibility");
+	}
+	else
+	{
+		valuesToRead.push_back(L"EnableDesktopModeAutoInvoke");
+	}
+
+	*enabled = true;
+	HKEY hKey = nullptr;
+	if (RegOpenKeyExW(HKEY_CURRENT_USER, kRegPath.c_str(), 0,
+		KEY_QUERY_VALUE | KEY_WOW64_64KEY, &hKey) != ERROR_SUCCESS)
+	{
+		return true; // 键不存在,默认开启
+	}
+
+	// 任一明确为 0 即视为关闭
+	for (const auto& name : valuesToRead)
+	{
+		DWORD value = 0, size = sizeof(value), type = 0;
+		LONG r = RegQueryValueExW(hKey, name.c_str(), nullptr,
+			&type, reinterpret_cast<BYTE*>(&value), &size);
+		if (r == ERROR_SUCCESS && type == REG_DWORD && value != 1)
+		{
+			*enabled = false;
+			break;
+		}
+		// 值不存在 → 当作默认开启,继续看下一个
+	}
+	RegCloseKey(hKey);
+	return true;
+}
+
+void CSystem::RestartWin7TabTip()
+{
+	// 直接 API 杀进程,不会弹黑窗口
+	KillProcessByName(L"TabTip.exe");
+
+	// 稍等一下让进程彻底退出
+	Sleep(200);
+
+	// 重新启动,SW_HIDE 避免闪窗口
+	ShellExecuteW(nullptr, L"open",
+		L"C:\\Program Files\\Common Files\\Microsoft Shared\\Ink\\TabTip.exe",
+		nullptr, nullptr, SW_HIDE);
+}
+
+bool CSystem::KillProcessByName(const std::wstring& processName)
+{
+	HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
+	if (hSnapshot == INVALID_HANDLE_VALUE) return false;
+
+	PROCESSENTRY32W pe = {};
+	pe.dwSize = sizeof(pe);
+
+	bool killed = false;
+	if (Process32FirstW(hSnapshot, &pe))
+	{
+		do
+		{
+			if (_wcsicmp(pe.szExeFile, processName.c_str()) == 0)
+			{
+				HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pe.th32ProcessID);
+				if (hProc)
+				{
+					if (TerminateProcess(hProc, 0))
+						killed = true;
+					CloseHandle(hProc);
+				}
+			}
+		} while (Process32NextW(hSnapshot, &pe));
+	}
+	CloseHandle(hSnapshot);
+	return killed;
+}
+
+bool CSystem::RunHidden(const std::wstring& commandLine)
+{
+	STARTUPINFOW si = {};
+	si.cb = sizeof(si);
+	si.dwFlags = STARTF_USESHOWWINDOW;
+	si.wShowWindow = SW_HIDE;
+
+	PROCESS_INFORMATION pi = {};
+
+	// CreateProcess 第二参数必须可写
+	std::vector<wchar_t> cmd(commandLine.begin(), commandLine.end());
+	cmd.push_back(0);
+
+	BOOL ok = CreateProcessW(nullptr, cmd.data(), nullptr, nullptr, FALSE,
+		CREATE_NO_WINDOW, nullptr, nullptr, &si, &pi);
+	if (ok)
+	{
+		WaitForSingleObject(pi.hProcess, 5000);
+		CloseHandle(pi.hProcess);
+		CloseHandle(pi.hThread);
+	}
+	return ok != FALSE;
+}
+
+void CSystem::ShowSystemKeyboard(HWND hwnd)
+{
+	// Win10+ 优先使用 TabTip 的 Toggle(更接近托盘点击行为)
+	if (CSystem::GetWindowsMajorVersion() >= 6)
+	{
+		// ITipInvocation (undocumented but widely used)
+		struct ITipInvocation : public IUnknown
+		{
+			virtual HRESULT STDMETHODCALLTYPE Toggle(HWND hwnd) = 0;
+		};
+
+		const CLSID CLSID_UIHostNoLaunch =
+		{ 0x4CE576FA, 0x83DC, 0x4F88, { 0x95, 0x1C, 0x9D, 0x07, 0x82, 0xB4, 0xE3, 0x76 } };
+
+		const IID IID_ITipInvocation =
+		{ 0x37C994E7, 0x432B, 0x4834, { 0xA2, 0xF7, 0xDC, 0xE1, 0xF1, 0x3B, 0x83, 0x4B } };
+
+		HRESULT hrInit = ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
+		bool needUninit = SUCCEEDED(hrInit);
+
+		ITipInvocation* pTip = nullptr;
+		HRESULT hr = ::CoCreateInstance(
+			CLSID_UIHostNoLaunch,
+			nullptr,
+			CLSCTX_INPROC_HANDLER | CLSCTX_LOCAL_SERVER,
+			IID_ITipInvocation,
+			reinterpret_cast<void**>(&pTip));
+
+		if (SUCCEEDED(hr) && pTip)
+		{
+			hr = pTip->Toggle(hwnd);
+			pTip->Release();
+
+			if (needUninit) ::CoUninitialize();
+			if (SUCCEEDED(hr)) return;
+		}
+
+		if (needUninit) ::CoUninitialize();
+
+		// Toggle 失败再尝试拉起 TabTip.exe
+		std::wstring tabTipPath = CSystem::GetTouchKeyboardPath();
+		if (tabTipPath.empty())
+			tabTipPath = L"C:\\Program Files\\Common Files\\microsoft shared\\ink\\TabTip.exe";
+
+		if (CSystem::IsFileExist(tabTipPath))
+		{
+			HINSTANCE hRet = ::ShellExecuteW(hwnd, L"open", tabTipPath.c_str(), nullptr, nullptr, SW_SHOWNORMAL);
+			if ((INT_PTR)hRet > 32) return;
+
+			LOG_ERROR("TabTip.exe 启动失败,错误码: " << (INT_PTR)hRet);
+		}
+	}
+
+	// 兜底:传统屏幕键盘
+	HINSTANCE hOskRet = ::ShellExecuteW(
+		hwnd, L"open", L"C:\\Windows\\System32\\osk.exe", nullptr, nullptr, SW_SHOWNORMAL);
+
+	if ((INT_PTR)hOskRet <= 32)
+	{
+		LOG_ERROR("osk.exe 启动失败,错误码: " << (INT_PTR)hOskRet);
+	}
+}
+
+void CSystem::HideSystemKeyboard()
+{
+	// Windows 10+ 触摸键盘 TabTip.exe 的主窗口。
+	HWND hTabTipWnd = ::FindWindowW(L"IPTip_Main_Window", nullptr);
+	if (hTabTipWnd != nullptr)
+	{
+		::PostMessageW(hTabTipWnd, WM_SYSCOMMAND, SC_CLOSE, 0);
+	}
+}

+ 22 - 0
zhipuzi_pos_windows/helper/CSystem.h

@@ -48,7 +48,29 @@ public:
 
 	static void RunHotKey(int mod, int key);
 
+	//获取当前程序运行的Windows系统的主版本号【windows2000-XP:5  windows vista、7、8:6  windows 10、11:10】
 	static DWORD GetWindowsMajorVersion();
 
 	static std::wstring GetTouchKeyboardPath();
+
+	//设置虚拟键盘是否自动弹出,enable=true 开启,false 关闭
+	static bool SetTouchKeyboardAutoInvoke(bool enable);
+
+	//获取虚拟键盘是否自动弹出,enabled=true 开启,false 关闭
+	static bool GetTouchKeyboardAutoInvoke(bool* enabled);
+
+	//重启win7的TabTip.exe
+	static void RestartWin7TabTip();
+
+	//杀死进程,不走system,避免弹黑窗
+	static bool KillProcessByName(const std::wstring& processName);
+
+	//运行一个命令行程序,隐藏窗口,替代系统的system函数,避免弹黑窗
+	static bool RunHidden(const std::wstring& commandLine);
+
+	//显示虚拟键盘,跟系统设置无关
+	static void ShowSystemKeyboard(HWND hwnd);
+
+	//隐藏虚拟键盘,跟系统设置无关
+	static void HideSystemKeyboard();
 };

+ 33 - 23
zhipuzi_pos_windows/page/CAIxuexiPageUI.cpp

@@ -228,38 +228,48 @@ void CAIxuexiPageUI::UpdateFoodtypePos()
 
 void CAIxuexiPageUI::InitFoodShow()
 {
-	bool is_youtu;
-	if (CSetting::GetInstance()->GetParam("setting_xianshi_is_youtu") == "1")
-	{
-		is_youtu = true;
-	}
-	else
-	{
-		is_youtu = false;
-	}
+	std::string setting_xianshi_is_youtu = CSetting::GetInstance()->GetParam("setting_xianshi_is_youtu");
 
 	m_foodLayout = static_cast<CTileLayoutUI*>(this->FindSubControl(_T("aixuexi_page_foodlist")));
 	m_foodLayout->RemoveAll();
 
 	std::wstring xml_name;
 
-	if (is_youtu)
+	if (setting_xianshi_is_youtu == "1")
 	{
 		SIZE itemsize;
 		itemsize.cx = 130;
-		itemsize.cy = 220;
+		itemsize.cy = 200;
 		m_foodLayout->SetItemSize(itemsize);
 
-		xml_name = _T("aixuexi_page_fooditem.xml");
+		xml_name = _T("diandan_fooditem_youtu.xml");
 	}
-	else
+	else if (setting_xianshi_is_youtu == "2")
 	{
 		SIZE itemsize;
-		itemsize.cx = 130;
+		itemsize.cx = 230;
 		itemsize.cy = 90;
 		m_foodLayout->SetItemSize(itemsize);
 
-		xml_name = _T("aixuexi_page_fooditem_wutu.xml");
+		xml_name = _T("diandan_fooditem_youtu_2.xml");
+	}
+	else if (setting_xianshi_is_youtu == "3")
+	{
+		SIZE itemsize;
+		itemsize.cx = 140;
+		itemsize.cy = 120;
+		m_foodLayout->SetItemSize(itemsize);
+
+		xml_name = _T("diandan_fooditem_youtu_3.xml");
+	}
+	else
+	{
+		SIZE itemsize;
+		itemsize.cx = 140;
+		itemsize.cy = 100;
+		m_foodLayout->SetItemSize(itemsize);
+
+		xml_name = _T("diandan_fooditem_wutu.xml");
 	}
 
 	//如果当前一个分类都没有,那么就不处理了
@@ -282,9 +292,9 @@ void CAIxuexiPageUI::InitFoodShow()
 				CDialogBuilder builder;
 				CDialogBuilderCallbackEx cb;
 
-				CAIXuexiPageFoodItemUI* pItem = static_cast<CAIXuexiPageFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
+				CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
 
-				pItem->SetYoutuModel(is_youtu);
+				pItem->SetYoutuModel(setting_xianshi_is_youtu);
 				pItem->SetFoodInfo(food);
 				pItem->UpdateShow();
 
@@ -304,9 +314,9 @@ void CAIxuexiPageUI::InitFoodShow()
 				CDialogBuilder builder;
 				CDialogBuilderCallbackEx cb;
 
-				CAIXuexiPageFoodItemUI* pItem = static_cast<CAIXuexiPageFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
+				CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
 
-				pItem->SetYoutuModel(is_youtu);
+				pItem->SetYoutuModel(setting_xianshi_is_youtu);
 				pItem->SetFoodInfo(food);
 				pItem->UpdateShow();
 
@@ -327,9 +337,9 @@ void CAIxuexiPageUI::InitFoodShow()
 			CDialogBuilder builder;
 			CDialogBuilderCallbackEx cb;
 
-			CAIXuexiPageFoodItemUI* pItem = static_cast<CAIXuexiPageFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
+			CDiandanFoodItemUI* pItem = static_cast<CDiandanFoodItemUI*>(builder.Create(xml_name.c_str(), (UINT)0, &cb, m_pManager));
 
-			pItem->SetYoutuModel(is_youtu);
+			pItem->SetYoutuModel(setting_xianshi_is_youtu);
 			pItem->SetFoodInfo(food);
 			pItem->UpdateShow();
 
@@ -343,9 +353,9 @@ void CAIxuexiPageUI::HandleClickMsg(TNotifyUI& msg)
 {
 	CDuiString name = msg.pSender->GetName();
 
-	if (name == L"aixuexi_page_fooditem")
+	if (name == L"diandan_fooditem")
 	{
-		CAIXuexiPageFoodItemUI* fooditemUI = static_cast<CAIXuexiPageFoodItemUI*>(msg.pSender);
+		CDiandanFoodItemUI* fooditemUI = static_cast<CDiandanFoodItemUI*>(msg.pSender);
 
 		m_cur_click_food_item = fooditemUI;
 

+ 2 - 2
zhipuzi_pos_windows/page/CAIxuexiPageUI.h

@@ -9,7 +9,7 @@
 #include "../zhipuzi/CFoodtype.h"
 #include "../zhipuzi/CFoodpackage.h"
 
-#include "../control/CAIXuexiPageFoodItemUI.h"
+#include "../control/CDiandanFoodItemUI.h"
 
 class CAIxuexiPageUI : public CBasePageUI
 {
@@ -97,7 +97,7 @@ private:
 	std::string m_sousuo_foodname;
 
 	//当前点击的哪个商品
-	CAIXuexiPageFoodItemUI* m_cur_click_food_item;
+	CDiandanFoodItemUI* m_cur_click_food_item;
 
 	//当前控件的实际宽度
 	int m_nPageWidth;

+ 11 - 75
zhipuzi_pos_windows/wnd/CMainWnd.cpp

@@ -11,7 +11,6 @@
 #include <urlmon.h>
 
 #include "../wnd/CToastWnd.h"
-#include "../wnd/CVirtualKeyboardWnd.h"
 
 #include "../worker/CMqttClientWorker.h"
 
@@ -66,7 +65,7 @@ void CMainWnd::Init()
 	std::thread(&CMainWnd::UpdateFoodImage, this).detach();
 
 	//展示虚拟键盘(暂时测试用,不完善)
-	//this->ShowVK(true);
+	CSystem::SetTouchKeyboardAutoInvoke(true);
 }
 
 void CMainWnd::End()
@@ -235,6 +234,9 @@ LRESULT CMainWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
 
 void CMainWnd::Notify(TNotifyUI& msg)
 {
+	CDuiString name = msg.pSender->GetName();
+	std::wstring senderName = name;
+
     if(msg.sType == _T("windowinit"))
     {
         
@@ -265,23 +267,21 @@ void CMainWnd::Notify(TNotifyUI& msg)
 	else if (msg.sType == _T("killfocus"))
 	{
 		//处理快捷键设置的状态问题
-		CDuiString name = msg.pSender->GetName();
-
-		std::wstring ws_name = name;
-
-		if (ws_name.find(L"setting_kuaijiejian_page_btn_") == 0)
+		if (senderName.find(L"setting_kuaijiejian_page_btn_") == 0)
 		{
 			m_IsKuaijiejian = false;
 		}
+
+		if (senderName == L"diandan_food_search_edit")
+		{
+			//CSystem::HideSystemKeyboard();
+		}
 	}
 	else if (msg.sType == _T("setfocus"))
 	{
-		CDuiString name = msg.pSender->GetName();
-		std::wstring senderName = name;
-
 		if (senderName == L"diandan_food_search_edit")
 		{
-			this->ShowSystemKeyboard();
+			//CSystem::ShowSystemKeyboard(m_hWnd);
 		}
 	}
 }
@@ -1117,26 +1117,6 @@ void CMainWnd::ShowToast(std::wstring toast_value)
 	}
 }
 
-void CMainWnd::ShowVK(bool is_show)
-{
-    if (!is_show)
-	{
-		return;
-	}
-
-	CVirtualKeyboardWnd* pVKDlg = new CVirtualKeyboardWnd();
-
-	if (pVKDlg != NULL)
-	{
-       pVKDlg->Create(m_hWnd, _T("虚拟键盘"),
-			WS_POPUP,
-			WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE);
-		pVKDlg->SetIcon(IDI_ICON_DUILIB);
-		pVKDlg->CenterWindow();
-		pVKDlg->ShowWindow(true, false);
-	}
-}
-
 //根据更多里面的设置,刷新左边的功能导航
 void CMainWnd::UpdateGongnengDaohang()
 {
@@ -2023,48 +2003,4 @@ void CMainWnd::UpdateRegisterHotKey()
 	UnregisterHotKey(m_hWnd, WM_MYHOTKEY_SHOUKUAN);
 
 	RegisterHotKey(m_hWnd, WM_MYHOTKEY_SHOUKUAN, shoukuan_mod, shoukuan_vk);
-}
-
-void CMainWnd::ShowSystemKeyboard()
-{
-	const DWORD windowsMajorVersion = CSystem::GetWindowsMajorVersion();
-
-	if (windowsMajorVersion >= 10)
-	{
-		const std::wstring touchKeyboardPath = CSystem::GetTouchKeyboardPath();
-
-		if (!touchKeyboardPath.empty() &&
-			CSystem::IsFileExist(touchKeyboardPath))
-		{
-			const HINSTANCE result = ::ShellExecuteW(
-				m_hWnd,
-				L"open",
-				touchKeyboardPath.c_str(),
-				nullptr,
-				nullptr,
-				SW_SHOWNORMAL);
-
-			if (reinterpret_cast<INT_PTR>(result) > 32)
-			{
-				return;
-			}
-
-			LOG_ERROR("TabTip.exe 启动失败,错误码: "
-				<< reinterpret_cast<INT_PTR>(result));
-		}
-	}
-
-	const HINSTANCE result = ::ShellExecuteW(
-		m_hWnd,
-		L"open",
-		L"C:\\Windows\\System32\\osk.exe",
-		nullptr,
-		nullptr,
-		SW_SHOWNORMAL);
-
-	if (reinterpret_cast<INT_PTR>(result) <= 32)
-	{
-		LOG_ERROR("osk.exe 启动失败,错误码: "
-			<< reinterpret_cast<INT_PTR>(result));
-	}
 }

+ 0 - 3
zhipuzi_pos_windows/wnd/CMainWnd.h

@@ -117,7 +117,6 @@ public:
 
 	//展示toast
 	void ShowToast(std::wstring toast_value);
-	void ShowVK(bool is_show);
 
 	//根据更多里面的设置,刷新左边的功能导航
 	void UpdateGongnengDaohang();
@@ -153,8 +152,6 @@ public:
 	//注册热键
 	void UpdateRegisterHotKey();
 
-	void ShowSystemKeyboard();
-
 private:
 	void UpdateFoodImage();
 

+ 0 - 453
zhipuzi_pos_windows/wnd/CVirtualKeyboardWnd.cpp

@@ -1,453 +0,0 @@
-#include "CVirtualKeyboardWnd.h"
-
-namespace
-{
-	struct KeyButtonDef
-	{
-		LPCTSTR name;
-		TCHAR alphaLower;
-		TCHAR alphaUpper;
-		TCHAR symbol;
-		TCHAR symbolShift;
-	};
-
-	const KeyButtonDef g_keyButtons[] =
-	{
-		{ _T("btn_q"), _T('q'), _T('Q'), _T('1'), _T('[') },
-		{ _T("btn_w"), _T('w'), _T('W'), _T('2'), _T(']') },
-		{ _T("btn_e"), _T('e'), _T('E'), _T('3'), _T('{') },
-		{ _T("btn_r"), _T('r'), _T('R'), _T('4'), _T('}') },
-		{ _T("btn_t"), _T('t'), _T('T'), _T('5'), _T('#') },
-		{ _T("btn_y"), _T('y'), _T('Y'), _T('6'), _T('%') },
-		{ _T("btn_u"), _T('u'), _T('U'), _T('7'), _T('^') },
-		{ _T("btn_i"), _T('i'), _T('I'), _T('8'), _T('*') },
-		{ _T("btn_o"), _T('o'), _T('O'), _T('9'), _T('+') },
-		{ _T("btn_p"), _T('p'), _T('P'), _T('0'), _T('=') },
-		{ _T("btn_a"), _T('a'), _T('A'), _T('-'), _T('_') },
-		{ _T("btn_s"), _T('s'), _T('S'), _T('/'), _T('\\') },
-		{ _T("btn_d"), _T('d'), _T('D'), _T(':'), _T('|') },
-		{ _T("btn_f"), _T('f'), _T('F'), _T(';'), _T('~') },
-		{ _T("btn_g"), _T('g'), _T('G'), _T('('), _T('<') },
-		{ _T("btn_h"), _T('h'), _T('H'), _T(')'), _T('>') },
-		{ _T("btn_j"), _T('j'), _T('J'), _T('$'), _T('$') },
-		{ _T("btn_k"), _T('k'), _T('K'), _T('&'), _T('&') },
-		{ _T("btn_l"), _T('l'), _T('L'), _T('@'), _T('@') },
-		{ _T("btn_apos"), _T('\''), _T('"'), _T('`'), _T('"') },
-		{ _T("btn_z"), _T('z'), _T('Z'), _T('.'), _T('.') },
-		{ _T("btn_x"), _T('x'), _T('X'), _T(','), _T(',') },
-		{ _T("btn_c"), _T('c'), _T('C'), _T('?'), _T('?') },
-		{ _T("btn_v"), _T('v'), _T('V'), _T('!'), _T('!') },
-		{ _T("btn_b"), _T('b'), _T('B'), _T('\''), _T('\'') },
-		{ _T("btn_n"), _T('n'), _T('N'), _T('#'), _T('"') },
-		{ _T("btn_m"), _T('m'), _T('M'), _T('%'), _T(';') },
-		{ _T("btn_comma"), _T(','), _T('<'), _T('+'), _T(':') },
-		{ _T("btn_dot"), _T('.'), _T('>'), _T('='), _T('-') },
-		{ _T("btn_question"), _T('/'), _T('?'), _T('_'), _T('/') },
-	};
-
-	const KeyButtonDef* FindKeyButton(LPCTSTR name)
-	{
-		for (const auto& key : g_keyButtons)
-		{
-			if (_tcscmp(key.name, name) == 0)
-			{
-				return &key;
-			}
-		}
-
-		return nullptr;
-	}
-
-	void SetButtonText(DuiLib::CPaintManagerUI& pm, LPCTSTR name, TCHAR ch)
-	{
-		TCHAR text[2] = { ch, 0 };
-		auto* button = static_cast<DuiLib::CButtonUI*>(pm.FindControl(name));
-		if (button != nullptr)
-		{
-			button->SetText(text);
-		}
-	}
-
-	void SetButtonText(DuiLib::CPaintManagerUI& pm, LPCTSTR name, LPCTSTR text)
-	{
-		auto* button = static_cast<DuiLib::CButtonUI*>(pm.FindControl(name));
-		if (button != nullptr)
-		{
-			button->SetText(text);
-		}
-	}
-}
-
-CVirtualKeyboardWnd::CVirtualKeyboardWnd()
-	: m_bIsShiftDown(false)
-	, m_bIsCtrlDown(false)
-	, m_bIsNumSymbol(false)
-	, m_hTargetWnd(NULL)
-{
-}
-
-CVirtualKeyboardWnd::~CVirtualKeyboardWnd()
-{
-}
-
-void CVirtualKeyboardWnd::InitWindow()
-{
-	m_pm.SetNoActivate(true);
-	UpdateTargetWindow();
-	UpdateLetterButtonsText();
-	UpdateModifierButtonsState();
-
-	SetButtonText(m_pm, _T("btn_num_symbol"), _T("&123"));
-	SetButtonText(m_pm, _T("btn_switch_ime"), _T("中/英"));
-}
-
-void CVirtualKeyboardWnd::Notify(TNotifyUI& msg)
-{
-	if (msg.sType == _T("click"))
-	{
-		UpdateTargetWindow();
-		CDuiString sName = msg.pSender->GetName();
-
-		if (sName == _T("closebtn"))
-		{
-			Close();
-			return;
-		}
-
-		if (sName == _T("btn_shift_l") || sName == _T("btn_shift_r"))
-		{
-			ToggleShift();
-			return;
-		}
-
-		if (sName == _T("btn_ctrl"))
-		{
-			ToggleCtrl();
-			return;
-		}
-
-		if (sName == _T("btn_num_symbol"))
-		{
-			SwitchNumSymbolLayout();
-			return;
-		}
-
-		if (sName == _T("btn_backspace"))
-		{
-			SimulateSpecialKey(VK_BACK);
-			return;
-		}
-
-		if (sName == _T("btn_enter"))
-		{
-			SimulateSpecialKey(VK_RETURN);
-			return;
-		}
-
-		if (sName == _T("btn_space"))
-		{
-			SimulateSpecialKey(VK_SPACE);
-			return;
-		}
-
-		if (sName == _T("btn_left"))
-		{
-			SimulateSpecialKey(VK_LEFT);
-			return;
-		}
-
-		if (sName == _T("btn_right"))
-		{
-			SimulateSpecialKey(VK_RIGHT);
-			return;
-		}
-
-		if (sName == _T("btn_switch_ime"))
-		{
-			ToggleImeLanguageMode();
-			return;
-		}
-
-		if (sName == _T("btn_handwriting"))
-		{
-			OpenHandwritingPanel();
-			return;
-		}
-
-		if (const auto* key = FindKeyButton(sName))
-		{
-			const TCHAR ch = m_bIsNumSymbol
-				? (m_bIsShiftDown ? key->symbolShift : key->symbol)
-				: (m_bIsShiftDown ? key->alphaUpper : key->alphaLower);
-
-			SimulateKeyPress(ch);
-			return;
-		}
-	}
-
-	__super::Notify(msg);
-}
-
-void CVirtualKeyboardWnd::SimulateKeyPress(TCHAR ch)
-{
-	SHORT vkInfo = ::VkKeyScan(ch);
-	if (vkInfo == -1)
-	{
-		return;
-	}
-
-	BYTE vkCode = LOBYTE(vkInfo);
-	BYTE shiftState = HIBYTE(vkInfo);
-	bool useCtrl = m_bIsCtrlDown;
-	bool useShift = (shiftState & 1) != 0;
-
-	if (useCtrl)
-	{
-		::keybd_event(VK_CONTROL, static_cast<BYTE>(::MapVirtualKey(VK_CONTROL, 0)), 0, 0);
-	}
-	if (useShift)
-	{
-		::keybd_event(VK_SHIFT, static_cast<BYTE>(::MapVirtualKey(VK_SHIFT, 0)), 0, 0);
-	}
-
-	::keybd_event(vkCode, static_cast<BYTE>(::MapVirtualKey(vkCode, 0)), 0, 0);
-	::keybd_event(vkCode, static_cast<BYTE>(::MapVirtualKey(vkCode, 0)), KEYEVENTF_KEYUP, 0);
-
-	if (useShift)
-	{
-		::keybd_event(VK_SHIFT, static_cast<BYTE>(::MapVirtualKey(VK_SHIFT, 0)), KEYEVENTF_KEYUP, 0);
-	}
-	if (useCtrl)
-	{
-		::keybd_event(VK_CONTROL, static_cast<BYTE>(::MapVirtualKey(VK_CONTROL, 0)), KEYEVENTF_KEYUP, 0);
-		m_bIsCtrlDown = false;
-	}
-
-	if (m_bIsShiftDown)
-	{
-		m_bIsShiftDown = false;
-	}
-
-	UpdateLetterButtonsText();
-	UpdateModifierButtonsState();
-}
-
-void CVirtualKeyboardWnd::SimulateSpecialKey(int vkCode)
-{
-	if (vkCode == (VK_CONTROL | VK_SHIFT))
-	{
-		::keybd_event(VK_CONTROL, static_cast<BYTE>(::MapVirtualKey(VK_CONTROL, 0)), 0, 0);
-		::keybd_event(VK_SHIFT, static_cast<BYTE>(::MapVirtualKey(VK_SHIFT, 0)), 0, 0);
-		::keybd_event(VK_SHIFT, static_cast<BYTE>(::MapVirtualKey(VK_SHIFT, 0)), KEYEVENTF_KEYUP, 0);
-		::keybd_event(VK_CONTROL, static_cast<BYTE>(::MapVirtualKey(VK_CONTROL, 0)), KEYEVENTF_KEYUP, 0);
-		return;
-	}
-
-	bool useCtrl = m_bIsCtrlDown;
-	bool useShift = m_bIsShiftDown;
-
-	if (useCtrl)
-	{
-		::keybd_event(VK_CONTROL, static_cast<BYTE>(::MapVirtualKey(VK_CONTROL, 0)), 0, 0);
-	}
-	if (useShift)
-	{
-		::keybd_event(VK_SHIFT, static_cast<BYTE>(::MapVirtualKey(VK_SHIFT, 0)), 0, 0);
-	}
-
-	::keybd_event(static_cast<BYTE>(vkCode), static_cast<BYTE>(::MapVirtualKey(vkCode, 0)), 0, 0);
-	::keybd_event(static_cast<BYTE>(vkCode), static_cast<BYTE>(::MapVirtualKey(vkCode, 0)), KEYEVENTF_KEYUP, 0);
-
-	if (useShift)
-	{
-		::keybd_event(VK_SHIFT, static_cast<BYTE>(::MapVirtualKey(VK_SHIFT, 0)), KEYEVENTF_KEYUP, 0);
-		m_bIsShiftDown = false;
-	}
-	if (useCtrl)
-	{
-		::keybd_event(VK_CONTROL, static_cast<BYTE>(::MapVirtualKey(VK_CONTROL, 0)), KEYEVENTF_KEYUP, 0);
-		m_bIsCtrlDown = false;
-	}
-
-	UpdateLetterButtonsText();
-	UpdateModifierButtonsState();
-}
-
-void CVirtualKeyboardWnd::ToggleImeLanguageMode()
-{
-	RestoreTargetWindow();
-
-	HWND hTarget = GetTargetWindow();
-	if (hTarget == NULL)
-	{
-		return;
-	}
-
-	HWND hImeWnd = ::ImmGetDefaultIMEWnd(hTarget);
-	if (hImeWnd != NULL)
-	{
-      HIMC hImc = ::ImmGetContext(hTarget);
-		if (hImc != NULL)
-		{
-			BOOL isOpen = ::ImmGetOpenStatus(hImc);
-			::ImmSetOpenStatus(hImc, isOpen ? FALSE : TRUE);
-
-			if (!isOpen)
-			{
-				DWORD conversion = 0;
-				DWORD sentence = 0;
-				if (::ImmGetConversionStatus(hImc, &conversion, &sentence))
-				{
-					::ImmSetConversionStatus(hImc, conversion | IME_CMODE_NATIVE, sentence);
-				}
-			}
-
-			::ImmReleaseContext(hTarget, hImc);
-		}
-
-		RestoreTargetWindow();
-		return;
-	}
-
-	DWORD dwThreadId = ::GetWindowThreadProcessId(hTarget, NULL);
-	HKL hkl = ::GetKeyboardLayout(dwThreadId);
-	if (!::ImmIsIME(hkl))
-	{
-		RestoreTargetWindow();
-		return;
-	}
-
-	HIMC hImc = ::ImmGetContext(hTarget);
-	if (hImc == NULL)
-	{
-		::ImmSimulateHotKey(hTarget, IME_CHOTKEY_IME_NONIME_TOGGLE);
-		RestoreTargetWindow();
-		return;
-	}
-
-	BOOL isOpen = ::ImmGetOpenStatus(hImc);
-	::ImmSetOpenStatus(hImc, isOpen ? FALSE : TRUE);
-	if (!isOpen)
-	{
-		DWORD conversion = 0;
-		DWORD sentence = 0;
-		if (::ImmGetConversionStatus(hImc, &conversion, &sentence))
-		{
-			::ImmSetConversionStatus(hImc, conversion | IME_CMODE_NATIVE, sentence);
-		}
-	}
-	::ImmReleaseContext(hTarget, hImc);
-
-	RestoreTargetWindow();
-}
-
-void CVirtualKeyboardWnd::SimulateShiftPress(bool bPress)
-{
-	m_bIsShiftDown = bPress;
-	UpdateLetterButtonsText();
-	UpdateModifierButtonsState();
-}
-
-void CVirtualKeyboardWnd::ToggleShift()
-{
-	SimulateShiftPress(!m_bIsShiftDown);
-}
-
-void CVirtualKeyboardWnd::ToggleCtrl()
-{
-	m_bIsCtrlDown = !m_bIsCtrlDown;
-	UpdateModifierButtonsState();
-}
-
-void CVirtualKeyboardWnd::SwitchNumSymbolLayout()
-{
-	m_bIsNumSymbol = !m_bIsNumSymbol;
-	m_bIsShiftDown = false;
-	UpdateLetterButtonsText();
-	UpdateModifierButtonsState();
-}
-
-void CVirtualKeyboardWnd::UpdateLetterButtonsText()
-{
-	for (const auto& key : g_keyButtons)
-	{
-		const TCHAR ch = m_bIsNumSymbol
-			? (m_bIsShiftDown ? key.symbolShift : key.symbol)
-			: (m_bIsShiftDown ? key.alphaUpper : key.alphaLower);
-		SetButtonText(m_pm, key.name, ch);
-	}
-
-	SetButtonText(m_pm, _T("btn_num_symbol"), m_bIsNumSymbol ? _T("ABC") : _T("&123"));
-}
-
-void CVirtualKeyboardWnd::UpdateModifierButtonsState()
-{
-	const DWORD normalColor = 0xFF302F37;
-	const DWORD activeColor = 0xFF555555;
-
-	auto* leftShift = static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_shift_l")));
-	if (leftShift != nullptr)
-	{
-		leftShift->SetBkColor(m_bIsShiftDown ? activeColor : normalColor);
-	}
-
-	auto* rightShift = static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_shift_r")));
-	if (rightShift != nullptr)
-	{
-		rightShift->SetBkColor(m_bIsShiftDown ? activeColor : normalColor);
-	}
-
-	auto* ctrl = static_cast<CButtonUI*>(m_pm.FindControl(_T("btn_ctrl")));
-	if (ctrl != nullptr)
-	{
-		ctrl->SetBkColor(m_bIsCtrlDown ? activeColor : normalColor);
-	}
-}
-
-void CVirtualKeyboardWnd::UpdateTargetWindow()
-{
-	HWND hFocus = ::GetFocus();
-	if (hFocus != NULL && hFocus != m_hWnd && !::IsChild(m_hWnd, hFocus))
-	{
-		m_hTargetWnd = hFocus;
-	}
-}
-
-HWND CVirtualKeyboardWnd::GetTargetWindow()
-{
-	UpdateTargetWindow();
-	if (m_hTargetWnd != NULL && ::IsWindow(m_hTargetWnd))
-	{
-		return m_hTargetWnd;
-	}
-
-	return NULL;
-}
-
-void CVirtualKeyboardWnd::RestoreTargetWindow()
-{
-	HWND hTarget = GetTargetWindow();
-	if (hTarget != NULL && ::GetFocus() != hTarget)
-	{
-		::SetFocus(hTarget);
-	}
-}
-
-void CVirtualKeyboardWnd::OpenHandwritingPanel()
-{
-	if ((INT_PTR)::ShellExecute(m_hWnd, _T("open"), _T("TabTip.exe"), NULL, NULL, SW_SHOWNORMAL) <= 32)
-	{
-		::ShellExecute(m_hWnd, _T("open"), _T("InputPanel.exe"), NULL, NULL, SW_SHOWNORMAL);
-	}
-	RestoreTargetWindow();
-}
-
-HWND CreateVirtualKeyboard()
-{
-	CVirtualKeyboardWnd* pKeyboard = new CVirtualKeyboardWnd();
-	if (pKeyboard)
-	{
-		return pKeyboard->Create(nullptr, _T("虚拟键盘"), WS_POPUP, WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE);
-	}
-	return nullptr;
-}

+ 0 - 77
zhipuzi_pos_windows/wnd/CVirtualKeyboardWnd.h

@@ -1,77 +0,0 @@
-#pragma once
-
-#include "../pch/pch.h"
-#include "CMainWnd.h"
-
-class CVirtualKeyboardWnd : public WindowImplBase
-{
-public:
-	CVirtualKeyboardWnd();
-	~CVirtualKeyboardWnd() override;
-
-	// 基类虚函数
-	virtual LPCTSTR GetWindowClassName() const override
-	{
-		return _T("VirtualKeyboardWnd");
-	}
-	virtual UINT GetClassStyle() const override
-	{
-		return CS_DBLCLKS;
-	}
-	virtual void OnFinalMessage(HWND hWnd) override
-	{
-		delete this;
-	}
-	virtual LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) override
-	{
-		if (uMsg == WM_MOUSEACTIVATE)
-		{
-			// 鼠标点击键盘时不激活窗口,返回 MA_NOACTIVATE
-			return MA_NOACTIVATE;
-		}
-		if (uMsg == WM_ACTIVATE)
-		{
-			// 拦截激活消息,不执行默认逻辑
-			return 0;
-		}
-		return __super::HandleMessage(uMsg, wParam, lParam);
-	}
-	virtual CDuiString GetSkinFile() override
-	{
-		return _T("virtual_keyboard.xml");
-	}
-	CDuiString GetSkinFolder()
-	{
-		return _T("");
-	}
-
-	virtual void InitWindow() override;
-	virtual void Notify(TNotifyUI& msg) override;
-
-private:
-	// 核心:模拟键盘按键
-	void SimulateKeyPress(TCHAR ch);
-	void SimulateSpecialKey(int vkCode);
-	void SimulateShiftPress(bool bPress);
-	void ToggleImeLanguageMode();
-
-	// 辅助功能
-	void ToggleShift();
-	void ToggleCtrl();
-	void SwitchNumSymbolLayout();
-	void UpdateLetterButtonsText();
-	void UpdateModifierButtonsState();
-	void UpdateTargetWindow();
-	HWND GetTargetWindow();
-	void RestoreTargetWindow();
-	void OpenHandwritingPanel();
-
-private:
-	bool m_bIsShiftDown;       // Shift是否按下
-	bool m_bIsCtrlDown;        // Ctrl是否按下
-	bool m_bIsNumSymbol;       // 数字/符号布局状态
-	HWND m_hTargetWnd;         // 当前输入目标
-};
-
-// 外部创建接口
-HWND CreateVirtualKeyboard();

+ 0 - 4
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj

@@ -244,9 +244,7 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     <ClInclude Include="ai\SQLiteVecManager.h" />
     <ClInclude Include="ai\YoloClassName.h" />
     <ClInclude Include="ai\YoloFeatureManager.h" />
-    <ClInclude Include="control\CAIXuexiPageFoodItemUI.h" />
     <ClInclude Include="control\CFoodXuexiImageItemUI.h" />
-    <ClInclude Include="wnd\CVirtualKeyboardWnd.h" />
     <ClInclude Include="page\CAIxuexiPageUI.h" />
     <ClInclude Include="ui\TouchWindowBase.h" />
     <ClInclude Include="worker\CDiandanAIShibieWorker.h" />
@@ -375,10 +373,8 @@ copy $(ProjectDir)conf\ $(SolutionDir)bin\$(Platform)\$(Configuration)\conf\</Co
     <ClCompile Include="ai\ImageProcessor.cpp" />
     <ClCompile Include="ai\SQLiteVecManager.cpp" />
     <ClCompile Include="ai\YoloFeatureManager.cpp" />
-    <ClCompile Include="control\CAIXuexiPageFoodItemUI.cpp" />
     <ClCompile Include="control\CFoodXuexiImageItemUI.cpp" />
     <ClCompile Include="sqlite3\shell.c" />
-    <ClCompile Include="wnd\CVirtualKeyboardWnd.cpp" />
     <ClCompile Include="page\CAIxuexiPageUI.cpp" />
     <ClCompile Include="ui\TouchWindowBase.cpp" />
     <ClCompile Include="worker\CDiandanAIShibieWorker.cpp" />

+ 0 - 12
zhipuzi_pos_windows/zhipuzi_pos_windows.vcxproj.filters

@@ -396,15 +396,9 @@
     <ClInclude Include="ui\TouchWindowBase.h">
       <Filter>头文件</Filter>
     </ClInclude>
-    <ClInclude Include="wnd\CVirtualKeyboardWnd.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
     <ClInclude Include="control\CFoodXuexiImageItemUI.h">
       <Filter>头文件</Filter>
     </ClInclude>
-    <ClInclude Include="control\CAIXuexiPageFoodItemUI.h">
-      <Filter>头文件</Filter>
-    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="pch\pch.cpp">
@@ -755,15 +749,9 @@
     <ClCompile Include="ui\TouchWindowBase.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
-    <ClCompile Include="wnd\CVirtualKeyboardWnd.cpp">
-      <Filter>源文件</Filter>
-    </ClCompile>
     <ClCompile Include="control\CFoodXuexiImageItemUI.cpp">
       <Filter>源文件</Filter>
     </ClCompile>
-    <ClCompile Include="control\CAIXuexiPageFoodItemUI.cpp">
-      <Filter>源文件</Filter>
-    </ClCompile>
     <ClCompile Include="sqlite3\shell.c">
       <Filter>源文件</Filter>
     </ClCompile>