Feature: add tooltips to the password input dialog

The passcode input dialog now explains every control the operator can
use on hover, using the same MFC built-in tooltip mechanism as the
generate-passcode dialog (EnableToolTips + OnToolHitTest + TTN_NEEDTEXT,
with the max tip width applied when the tip is requested).

The passcode tip carries the main point: the value must match the
current serial and binding mode, and a passcode that was tampered with,
cracked or forged is invalid. The OK tip says the authorization check
verifies the passcode after saving rather than claiming the dialog
checks it. The checksum tip reflects that V2 verifies the passcode
signature while V1 checks the passcode itself, and the root-credential
tip notes that clearing the box does not delete the stored credential.

While here, the TTN_NEEDTEXT handlers keep idFrom in UINT_PTR: on x64
the old UINT intermediate could truncate a control HWND. The same fix
is applied to the generate-passcode dialog.

All 6 texts are translated in the en_US, de_DE and zh_TW packs.

Co-Authored-By: deepseek-flash
This commit is contained in:
yuanyuanxianganddeepseek-flash committed 2026-12-06 22:39:08 +01:00
1 parent f22bd574ea
commit 2b26f22d27
5 files changed
+119 -3

No files matched your search

+89 -3
View File
@@ -599,6 +599,7 @@ void CPasswordDlg::DoDataExchange(CDataExchange* pDX)
BEGIN_MESSAGE_MAP(CPasswordDlg, CDialogEx) BEGIN_MESSAGE_MAP(CPasswordDlg, CDialogEx)
ON_CBN_SELCHANGE(IDC_COMBO_BIND, &CPasswordDlg::OnCbnSelchangeComboBind) ON_CBN_SELCHANGE(IDC_COMBO_BIND, &CPasswordDlg::OnCbnSelchangeComboBind)
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &CPasswordDlg::OnToolTipNotify)
END_MESSAGE_MAP() END_MESSAGE_MAP()
@@ -632,10 +633,94 @@ BOOL CPasswordDlg::OnInitDialog()
m_EditRootCert.SetWindowText(m_sRootCert); m_EditRootCert.SetWindowText(m_sRootCert);
} }
// 各操作控件的悬浮提示。重点:口令必须由管理员合法签发,
// 自行篡改、破解或伪造的口令一律无效。
m_tips.clear();
m_tips[IDC_COMBO_BIND] = _TR(
"选择授权绑定的对象:\n"
"选硬件方式时绑定本机硬件;\n"
"选主控地址方式时绑定当前公网地址。\n"
"切换后序列号会自动重算,与新序列号不匹配的旧口令随之失效。");
m_tips[IDC_EDIT_DEVICEID] = _TR(
"按「授权方式」自动计算的设备序列号(只读)。\n"
"口令只对这个序列号有效;序列号与授权方式不一致时\n"
"无法通过校验。");
m_tips[IDC_EDIT_DEVICEPWD] = _TR(
"粘贴管理员签发的授权口令(必填)。\n"
"【重点】口令必须与当前序列号、授权方式匹配;\n"
"自行篡改、破解或伪造的口令均无效,\n"
"校验不通过将无法通过授权检查。");
m_tips[IDC_EDIT_PASSCODE_HMAC] = _TR(
"口令对应的验证码/签名(V2 模式下必填,以 v2: 开头)。\n"
"V2 用它校验口令签名,必须与口令、序列号一起由管理员签发;\n"
"V1 模式下由口令本身完成校验。");
m_tips[IDC_EDIT_ROOT_CERT] = _TR(
"可选的上级授权凭证,用于多层授权。\n"
"由上级管理员提供;普通单层授权可留空。\n"
"填写错误不影响本机口令校验,但下发给下级的授权会无效;\n"
"清空输入框不会删除已保存的凭证。");
m_tips[IDOK] = _TR(
"保存序列号、授权口令和验证码。\n"
"【重点】保存后由授权检查验证口令,\n"
"篡改、破解或伪造的口令一律无效;\n"
"请勿手工拼接口令。");
EnableToolTips(TRUE);
return TRUE; // return TRUE unless you set the focus to a control return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE // 异常: OCX 属性页应返回 FALSE
} }
INT_PTR CPasswordDlg::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
// point 是对话框客户区坐标。逐个登记过提示的可见控件做矩形命中,
// 不依赖鼠标消息落在哪个窗口:combo 的内部编辑框、禁用控件都能命中;隐藏控件跳过。
for (const auto& kv : m_tips) {
CWnd* w = GetDlgItem(kv.first);
if (w == nullptr || !w->IsWindowVisible())
continue;
CRect rc;
w->GetWindowRect(&rc);
ScreenToClient(&rc);
if (!rc.PtInRect(point))
continue;
if (pTI != nullptr) {
pTI->hwnd = m_hWnd;
pTI->uId = (UINT_PTR)w->GetSafeHwnd();
pTI->uFlags |= TTF_IDISHWND;
// 与 MFC 默认实现一致:非按钮控件让提示居中。
if (!(::SendMessage(w->GetSafeHwnd(), WM_GETDLGCODE, 0, 0) & DLGC_BUTTON))
pTI->uFlags |= TTF_NOTBUTTON | TTF_CENTERTIP;
pTI->lpszText = LPSTR_TEXTCALLBACK;
}
return (INT_PTR)kv.first;
}
return -1; // 其余控件(标签等)不加提示
}
BOOL CPasswordDlg::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
{
// 内建工具提示默认单行绘制(未设 TTM_SETMAXTIPWIDTH 时 \n 不生效)。
// 在提示即将显示时设置,避免每次鼠标移动都向共享的 tooltip 发消息。
AFX_MODULE_THREAD_STATE* ts = AfxGetModuleThreadState();
if (ts != nullptr && ts->m_pToolTip != nullptr && ts->m_pToolTip->GetSafeHwnd() != nullptr)
ts->m_pToolTip->SetMaxTipWidth(600);
TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
UINT_PTR idFrom = pNMHDR->idFrom;
UINT nID = (UINT)idFrom;
if (pTTT->uFlags & TTF_IDISHWND) {
// idFrom 是工具窗口句柄,换成控件 ID(保留完整宽度,避免 x64 截断)
nID = (UINT)::GetDlgCtrlID((HWND)idFrom);
}
auto it = m_tips.find(nID);
if (it == m_tips.end())
return FALSE;
// 指向成员里的 CString:生命周期覆盖提示显示期间,也避开 szText 的 80 字符限制。
pTTT->lpszText = const_cast<LPTSTR>((LPCTSTR)it->second);
if (pResult) *pResult = 0;
return TRUE;
}
void CPasswordDlg::OnCbnSelchangeComboBind() void CPasswordDlg::OnCbnSelchangeComboBind()
{ {
m_nBindType = m_ComboBinding.GetCurSel(); m_nBindType = m_ComboBinding.GetCurSel();
@@ -1115,10 +1200,11 @@ BOOL CPwdGenDlg::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
ts->m_pToolTip->SetMaxTipWidth(600); ts->m_pToolTip->SetMaxTipWidth(600);
TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR; TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR;
UINT nID = (UINT)pNMHDR->idFrom; UINT_PTR idFrom = pNMHDR->idFrom;
UINT nID = (UINT)idFrom;
if (pTTT->uFlags & TTF_IDISHWND) { if (pTTT->uFlags & TTF_IDISHWND) {
// idFrom 是工具窗口句柄,换成控件 ID // idFrom 是工具窗口句柄,换成控件 ID(保留完整宽度,避免 x64 截断)
nID = (UINT)::GetDlgCtrlID((HWND)nID); nID = (UINT)::GetDlgCtrlID((HWND)idFrom);
} }
auto it = m_tips.find(nID); auto it = m_tips.find(nID);
if (it == m_tips.end()) if (it == m_tips.end())
+6
View File
@@ -60,6 +60,12 @@ public:
protected: protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 控件悬浮提示(MFC 内建工具提示):OnToolHitTest 按控件矩形命中,
// TTN_NEEDTEXT 按控件 ID 取多行文本。隐藏控件的提示自动跳过。
virtual INT_PTR OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult);
std::map<UINT, CString> m_tips; // 控件 ID -> 提示文本
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
public: public:
HICON m_hIcon; HICON m_hIcon;
+8
View File
@@ -2401,3 +2401,11 @@ MCP
自动查找并填入下一个可用的 FRP 远程端口。\n保存授权时才会真正记录端口占用。=Naechsten freien FRP-Remote-Port suchen und eintragen.\nDie Portbelegung wird erst beim Speichern der Lizenz erfasst. 自动查找并填入下一个可用的 FRP 远程端口。\n保存授权时才会真正记录端口占用。=Naechsten freien FRP-Remote-Port suchen und eintragen.\nDie Portbelegung wird erst beim Speichern der Lizenz erfasst.
按当前参数生成口令。\n【重点】必须满足 V1 密码正确或 V2 私钥合法,\n否则生成的口令无效;篡改密码、伪造私钥或\n手工拼接得到的结果,客户端验证都会失败。=Passcode aus den aktuellen Einstellungen erzeugen.\n[WICHTIG] V1 erfordert das richtige Passwort, V2 einen gueltigen Privatsschluessel;\nsonst ist der erzeugte Passcode ungueltig. Manipulierte Passwoerter, gefaelschte Schluessel oder\nmanuell zusammengesetzte Werte bestehen die Client-Pruefung nie. 按当前参数生成口令。\n【重点】必须满足 V1 密码正确或 V2 私钥合法,\n否则生成的口令无效;篡改密码、伪造私钥或\n手工拼接得到的结果,客户端验证都会失败。=Passcode aus den aktuellen Einstellungen erzeugen.\n[WICHTIG] V1 erfordert das richtige Passwort, V2 einen gueltigen Privatsschluessel;\nsonst ist der erzeugte Passcode ungueltig. Manipulierte Passwoerter, gefaelschte Schluessel oder\nmanuell zusammengesetzte Werte bestehen die Client-Pruefung nie.
把生成的口令/HMAC/根凭证保存到 licenses.ini,\n并可导出 .lic 文件。只有成功生成口令后才可用;\n本机给自己授权时会自动保存。=Erzeugten Passcode/HMAC/Root-Nachweis in licenses.ini speichern\nund optional eine .lic-Datei exportieren. Erst nach dem Erzeugen eines Passcodes verfuegbar;\nbei der Lizenzierung dieses Rechners selbst wird automatisch gespeichert. 把生成的口令/HMAC/根凭证保存到 licenses.ini,\n并可导出 .lic 文件。只有成功生成口令后才可用;\n本机给自己授权时会自动保存。=Erzeugten Passcode/HMAC/Root-Nachweis in licenses.ini speichern\nund optional eine .lic-Datei exportieren. Erst nach dem Erzeugen eines Passcodes verfuegbar;\nbei der Lizenzierung dieses Rechners selbst wird automatisch gespeichert.
; Password input dialog tooltips (CPasswordDlg)
选择授权绑定的对象:\n选硬件方式时绑定本机硬件;\n选主控地址方式时绑定当前公网地址。\n切换后序列号会自动重算,与新序列号不匹配的旧口令随之失效。=Waehlen Sie, woran die Lizenz gebunden ist:\nDer Hardware-Modus bindet die Hardware dieses Rechners;\nder Master-Adress-Modus bindet die aktuelle oeffentliche Adresse.\nBeim Wechsel wird die Seriennummer neu berechnet; ein alter Passcode fuer die vorherige Seriennummer verliert seine Gueltigkeit.
按「授权方式」自动计算的设备序列号(只读)。\n口令只对这个序列号有效;序列号与授权方式不一致时\n无法通过校验。=Aus dem Bindungsmodus automatisch berechnete Geraete-Seriennummer (schreibgeschuetzt).\nEin Passcode gilt nur fuer diese Seriennummer; stimmen Seriennummer und Bindungsmodus nicht ueberein,\nschlaegt die Pruefung fehl.
粘贴管理员签发的授权口令(必填)。\n【重点】口令必须与当前序列号、授权方式匹配;\n自行篡改、破解或伪造的口令均无效,\n校验不通过将无法通过授权检查。=Den vom Administrator ausgestellten Lizenz-Passcode einfuegen (Pflichtfeld).\n[WICHTIG] Der Passcode muss zur aktuellen Seriennummer und zum Bindungsmodus passen;\nein manipulierter, geknackter oder gefaelschter Passcode ist ungueltig und besteht die Pruefung nicht,\nwodurch die Autorisierungspruefung fehlschlaegt.
口令对应的验证码/签名(V2 模式下必填,以 v2: 开头)。\nV2 用它校验口令签名,必须与口令、序列号一起由管理员签发;\nV1 模式下由口令本身完成校验。=Pruefsumme/Signatur zum Passcode (in V2 erforderlich; beginnt mit v2:).\nV2 prueft damit die Passcode-Signatur; sie muss zusammen mit Passcode und Seriennummer vom Administrator ausgestellt werden.\nIm V1-Modus wird der Passcode selbst geprueft.
可选的上级授权凭证,用于多层授权。\n由上级管理员提供;普通单层授权可留空。\n填写错误不影响本机口令校验,但下发给下级的授权会无效;\n清空输入框不会删除已保存的凭证。=Optionaler uebergeordneter Autorisierungsnachweis fuer mehrstufige Lizenzierung.\nWird vom uebergeordneten Administrator bereitgestellt; bei einer normalen einstufigen Lizenz leer lassen.\nEin falscher Wert beeintraechtigt die Passcode-Pruefung dieses Rechners nicht, macht aber an Unterebenen ausgestellte Lizenzen ungueltig;\nLeeren des Feldes loescht den gespeicherten Nachweis nicht.
保存序列号、授权口令和验证码。\n【重点】保存后由授权检查验证口令,\n篡改、破解或伪造的口令一律无效;\n请勿手工拼接口令。=Seriennummer, Lizenz-Passcode und Pruefsumme speichern.\n[WICHTIG] Die Autorisierungspruefung verifiziert den Passcode nach dem Speichern;\nmanipulierte, geknackte oder gefaelschte Passcodes sind immer ungueltig.\nPasscodes nicht manuell zusammensetzen.
+8
View File
@@ -2412,3 +2412,11 @@ MCP
自动查找并填入下一个可用的 FRP 远程端口。\n保存授权时才会真正记录端口占用。=Find and fill in the next available FRP remote port.\nThe port is only recorded when the license is saved. 自动查找并填入下一个可用的 FRP 远程端口。\n保存授权时才会真正记录端口占用。=Find and fill in the next available FRP remote port.\nThe port is only recorded when the license is saved.
按当前参数生成口令。\n【重点】必须满足 V1 密码正确或 V2 私钥合法,\n否则生成的口令无效;篡改密码、伪造私钥或\n手工拼接得到的结果,客户端验证都会失败。=Generate a passcode from the current settings.\n[IMPORTANT] V1 requires the correct password and V2 requires a valid private key;\notherwise the generated passcode is invalid. Tampered passwords, forged keys or\nhand-assembled values will always fail client verification. 按当前参数生成口令。\n【重点】必须满足 V1 密码正确或 V2 私钥合法,\n否则生成的口令无效;篡改密码、伪造私钥或\n手工拼接得到的结果,客户端验证都会失败。=Generate a passcode from the current settings.\n[IMPORTANT] V1 requires the correct password and V2 requires a valid private key;\notherwise the generated passcode is invalid. Tampered passwords, forged keys or\nhand-assembled values will always fail client verification.
把生成的口令/HMAC/根凭证保存到 licenses.ini,\n并可导出 .lic 文件。只有成功生成口令后才可用;\n本机给自己授权时会自动保存。=Save the generated passcode/HMAC/root credential to licenses.ini,\nand optionally export a .lic file. Available only after a passcode is generated;\nwhen authorizing this machine itself, it is saved automatically. 把生成的口令/HMAC/根凭证保存到 licenses.ini,\n并可导出 .lic 文件。只有成功生成口令后才可用;\n本机给自己授权时会自动保存。=Save the generated passcode/HMAC/root credential to licenses.ini,\nand optionally export a .lic file. Available only after a passcode is generated;\nwhen authorizing this machine itself, it is saved automatically.
; Password input dialog tooltips (CPasswordDlg)
选择授权绑定的对象:\n选硬件方式时绑定本机硬件;\n选主控地址方式时绑定当前公网地址。\n切换后序列号会自动重算,与新序列号不匹配的旧口令随之失效。=Choose what the license is bound to:\nHardware mode binds this machine's hardware;\nmaster-address mode binds the current public address.\nSwitching recomputes the serial, so an old passcode for the previous serial no longer works.
按「授权方式」自动计算的设备序列号(只读)。\n口令只对这个序列号有效;序列号与授权方式不一致时\n无法通过校验。=Device serial computed automatically from the binding mode (read-only).\nA passcode is only valid for this serial; if the serial and binding mode disagree,\nverification fails.
粘贴管理员签发的授权口令(必填)。\n【重点】口令必须与当前序列号、授权方式匹配;\n自行篡改、破解或伪造的口令均无效,\n校验不通过将无法通过授权检查。=Paste the license passcode issued by the administrator (required).\n[IMPORTANT] The passcode must match the current serial and binding mode;\na tampered, cracked or forged passcode is invalid and will fail verification,\nblocking the authorization check.
口令对应的验证码/签名(V2 模式下必填,以 v2: 开头)。\nV2 用它校验口令签名,必须与口令、序列号一起由管理员签发;\nV1 模式下由口令本身完成校验。=Checksum/signature for the passcode (required in V2 mode; starts with v2:).\nV2 uses it to verify the passcode signature; it must be issued by the administrator together with the passcode and serial.\nIn V1 mode the passcode itself is verified.
可选的上级授权凭证,用于多层授权。\n由上级管理员提供;普通单层授权可留空。\n填写错误不影响本机口令校验,但下发给下级的授权会无效;\n清空输入框不会删除已保存的凭证。=Optional parent authorization credential for multi-level licensing.\nProvided by the parent administrator; leave empty for an ordinary single-level license.\nA wrong value does not affect this machine's passcode check, but licenses issued to sub-levels will be invalid;\nclearing the box does not delete the saved credential.
保存序列号、授权口令和验证码。\n【重点】保存后由授权检查验证口令,\n篡改、破解或伪造的口令一律无效;\n请勿手工拼接口令。=Save the serial, license passcode and checksum.\n[IMPORTANT] The authorization check verifies the passcode after saving;\ntampered, cracked or forged passcodes are always invalid.\nDo not hand-assemble a passcode.
+8
View File
@@ -2405,3 +2405,11 @@ MCP
自动查找并填入下一个可用的 FRP 远程端口。\n保存授权时才会真正记录端口占用。=自動尋找並填入下一個可用的 FRP 遠端連接埠。\n儲存授權時才會真正記錄連接埠佔用。 自动查找并填入下一个可用的 FRP 远程端口。\n保存授权时才会真正记录端口占用。=自動尋找並填入下一個可用的 FRP 遠端連接埠。\n儲存授權時才會真正記錄連接埠佔用。
按当前参数生成口令。\n【重点】必须满足 V1 密码正确或 V2 私钥合法,\n否则生成的口令无效;篡改密码、伪造私钥或\n手工拼接得到的结果,客户端验证都会失败。=按目前參數產生口令。\n【重點】必須滿足 V1 密碼正確或 V2 私鑰合法,\n否則產生的口令無效;竄改密碼、偽造私鑰或\n手動拼接得到的結果,用戶端驗證都會失敗。 按当前参数生成口令。\n【重点】必须满足 V1 密码正确或 V2 私钥合法,\n否则生成的口令无效;篡改密码、伪造私钥或\n手工拼接得到的结果,客户端验证都会失败。=按目前參數產生口令。\n【重點】必須滿足 V1 密碼正確或 V2 私鑰合法,\n否則產生的口令無效;竄改密碼、偽造私鑰或\n手動拼接得到的結果,用戶端驗證都會失敗。
把生成的口令/HMAC/根凭证保存到 licenses.ini,\n并可导出 .lic 文件。只有成功生成口令后才可用;\n本机给自己授权时会自动保存。=將產生的口令/HMAC/根憑證儲存到 licenses.ini,\n並可匯出 .lic 檔案。只有成功產生口令後才可用;\n本機給自己授權時會自動儲存。 把生成的口令/HMAC/根凭证保存到 licenses.ini,\n并可导出 .lic 文件。只有成功生成口令后才可用;\n本机给自己授权时会自动保存。=將產生的口令/HMAC/根憑證儲存到 licenses.ini,\n並可匯出 .lic 檔案。只有成功產生口令後才可用;\n本機給自己授權時會自動儲存。
; Password input dialog tooltips (CPasswordDlg)
选择授权绑定的对象:\n选硬件方式时绑定本机硬件;\n选主控地址方式时绑定当前公网地址。\n切换后序列号会自动重算,与新序列号不匹配的旧口令随之失效。=選擇授權綁定的對象:\n選硬體方式時綁定本機硬體;\n選主控位址方式時綁定目前公網位址。\n切換後序號會自動重算,與新序號不符的舊口令將隨之失效。
按「授权方式」自动计算的设备序列号(只读)。\n口令只对这个序列号有效;序列号与授权方式不一致时\n无法通过校验。=依「授權方式」自動計算的裝置序號(唯讀)。\n口令只對這個序號有效;序號與授權方式不一致時\n無法通過校驗。
粘贴管理员签发的授权口令(必填)。\n【重点】口令必须与当前序列号、授权方式匹配;\n自行篡改、破解或伪造的口令均无效,\n校验不通过将无法通过授权检查。=貼上管理員簽發的授權口令(必填)。\n【重點】口令必須與目前序號、授權方式相符;\n自行竄改、破解或偽造的口令均無效,\n校驗不通過將無法通過授權檢查。
口令对应的验证码/签名(V2 模式下必填,以 v2: 开头)。\nV2 用它校验口令签名,必须与口令、序列号一起由管理员签发;\nV1 模式下由口令本身完成校验。=口令對應的驗證碼/簽名(V2 模式必填,以 v2: 開頭)。\nV2 用它校驗口令簽名,必須與口令、序號一起由管理員簽發;\nV1 模式下由口令本身完成校驗。
可选的上级授权凭证,用于多层授权。\n由上级管理员提供;普通单层授权可留空。\n填写错误不影响本机口令校验,但下发给下级的授权会无效;\n清空输入框不会删除已保存的凭证。=可選的上級授權憑證,用於多層授權。\n由上級管理員提供;一般單層授權可留空。\n填寫錯誤不影響本機口令校驗,但下發給下級的授權會無效;\n清空輸入框不會刪除已儲存的憑證。
保存序列号、授权口令和验证码。\n【重点】保存后由授权检查验证口令,\n篡改、破解或伪造的口令一律无效;\n请勿手工拼接口令。=儲存序號、授權口令和驗證碼。\n【重點】儲存後由授權檢查驗證口令,\n竄改、破解或偽造的口令一律無效;\n請勿手動拼接口令。