https://git.reactos.org/?p=reactos.git;a=commitdiff;h=934cd46df59bdc2bbd0b4…
commit 934cd46df59bdc2bbd0b4e52282b498b56310a50
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Tue Jan 30 15:38:53 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Tue Jan 30 15:38:53 2024 +0900
[MSUTB][SDK] Add Language Bar dialogs (#6422)
Supporting Language Bar...
JIRA issue: CORE-19363
- Add IDD_CLOSELANGBAR and
IDD_MINIMIZELANGBAR
resource dialogs.
- Implement CUTBLangBarDlg class.
- Implement CUTBCloseLangBarDlg
and CUTBMinimizeLangBarDlg
classes.
---
dll/win32/msutb/lang/en-US.rc | 21 +++
dll/win32/msutb/msutb.cpp | 277 ++++++++++++++++++++++++++++++++++++
dll/win32/msutb/precomp.h | 1 +
dll/win32/msutb/resource.h | 6 +
sdk/include/reactos/cicero/cicuif.h | 2 +-
5 files changed, 306 insertions(+), 1 deletion(-)
diff --git a/dll/win32/msutb/lang/en-US.rc b/dll/win32/msutb/lang/en-US.rc
index c45c6e28438..98a9ea10f96 100644
--- a/dll/win32/msutb/lang/en-US.rc
+++ b/dll/win32/msutb/lang/en-US.rc
@@ -19,3 +19,24 @@ BEGIN
IDS_MENUWND "Menu Window"
IDS_LEFTCLICK "Left Click"
END
+
+IDD_CLOSELANGBAR DIALOGEX 0, 0, 200, 105
+CAPTION "Language Bar"
+STYLE WS_POPUPWINDOW | WS_CAPTION | DS_MODALFRAME
+FONT 8, "MS Shell Dlg"
+{
+ LTEXT "You have closed Language Bar.\r\n\r\nTo use Language Bar later, check
""Show Language Bar on the desktop"" in Language Bar Settings dialog,
which you can find within Regional and Language Options control panel.", -1, 5, 5,
190, 60
+ AUTOCHECKBOX "&Don't show me this message again",
IDC_CLOSELANGBAR_CHECK, 5, 70, 145, 10
+ DEFPUSHBUTTON "OK", IDOK, 80, 85, 55, 15
+ PUSHBUTTON "Cancel", IDCANCEL, 140, 85, 55, 15
+}
+
+IDD_MINIMIZELANGBAR DIALOGEX 0, 0, 205, 84
+CAPTION "Language Bar"
+STYLE WS_POPUPWINDOW | WS_CAPTION | DS_MODALFRAME
+FONT 8, "MS Shell Dlg"
+{
+ LTEXT "You have minimized Language Bar. To restore it, just click Language Bar
icon (near the clock) and choose ""Restore Language Bar"" from the
pop-up menu.", -1, 5, 5, 190, 50
+ AUTOCHECKBOX "Don't show me this message again",
IDC_MINIMIZELANGBAR_CHECK, 5, 65, 125, 10
+ DEFPUSHBUTTON "OK", IDOK, 140, 65, 60, 15
+}
diff --git a/dll/win32/msutb/msutb.cpp b/dll/win32/msutb/msutb.cpp
index 615e7c47450..d6344a59a0c 100644
--- a/dll/win32/msutb/msutb.cpp
+++ b/dll/win32/msutb/msutb.cpp
@@ -37,6 +37,68 @@ class CUTBMenuItem;
/***********************************************************************/
+class CUTBLangBarDlg
+{
+protected:
+ LPTSTR m_pszDialogName;
+ LONG m_cRefs;
+
+public:
+ CUTBLangBarDlg() { }
+ virtual ~CUTBLangBarDlg() { }
+
+ static CUTBLangBarDlg *GetThis(HWND hDlg);
+ static void SetThis(HWND hDlg, CUTBLangBarDlg *pThis);
+ static DWORD WINAPI s_ThreadProc(LPVOID pParam);
+ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+
+ BOOL StartThread();
+ LONG _Release();
+
+ STDMETHOD_(BOOL, DoModal)(HWND hDlg) = 0;
+ STDMETHOD_(BOOL, OnCommand)(HWND hDlg, WPARAM wParam, LPARAM lParam) = 0;
+ STDMETHOD_(BOOL, IsDlgShown)() = 0;
+ STDMETHOD_(void, SetDlgShown)(BOOL bShown) = 0;
+ STDMETHOD_(BOOL, ThreadProc)();
+};
+
+/***********************************************************************/
+
+class CUTBCloseLangBarDlg : public CUTBLangBarDlg
+{
+public:
+ CUTBCloseLangBarDlg();
+
+ static BOOL s_bIsDlgShown;
+
+ STDMETHOD_(BOOL, DoModal)(HWND hDlg) override;
+ STDMETHOD_(BOOL, OnCommand)(HWND hDlg, WPARAM wParam, LPARAM lParam) override;
+ STDMETHOD_(BOOL, IsDlgShown)() override;
+ STDMETHOD_(void, SetDlgShown)(BOOL bShown) override;
+};
+
+BOOL CUTBCloseLangBarDlg::s_bIsDlgShown = FALSE;
+
+/***********************************************************************/
+
+class CUTBMinimizeLangBarDlg : public CUTBLangBarDlg
+{
+public:
+ CUTBMinimizeLangBarDlg();
+
+ static BOOL s_bIsDlgShown;
+
+ STDMETHOD_(BOOL, DoModal)(HWND hDlg) override;
+ STDMETHOD_(BOOL, OnCommand)(HWND hDlg, WPARAM wParam, LPARAM lParam) override;
+ STDMETHOD_(BOOL, IsDlgShown)() override;
+ STDMETHOD_(void, SetDlgShown)(BOOL bShown) override;
+ STDMETHOD_(BOOL, ThreadProc)() override;
+};
+
+BOOL CUTBMinimizeLangBarDlg::s_bIsDlgShown = FALSE;
+
+/***********************************************************************/
+
class CCicLibMenu : public ITfMenu
{
protected:
@@ -344,6 +406,221 @@ protected:
STDMETHOD_(LRESULT, OnDelayMsg)(LPARAM lParam) { return 0; };
};
+/***********************************************************************
+ * CUTBLangBarDlg
+ */
+
+CUTBLangBarDlg *CUTBLangBarDlg::GetThis(HWND hDlg)
+{
+ return (CUTBLangBarDlg*)::GetWindowLongPtr(hDlg, DWLP_USER);
+}
+
+void CUTBLangBarDlg::SetThis(HWND hDlg, CUTBLangBarDlg *pThis)
+{
+ ::SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pThis);
+}
+
+DWORD WINAPI CUTBLangBarDlg::s_ThreadProc(LPVOID pParam)
+{
+ return ((CUTBLangBarDlg *)pParam)->ThreadProc();
+}
+
+BOOL CUTBLangBarDlg::StartThread()
+{
+ if (IsDlgShown())
+ return FALSE;
+
+ SetDlgShown(TRUE);
+
+ DWORD dwThreadId;
+ HANDLE hThread = ::CreateThread(NULL, 0, s_ThreadProc, this, 0, &dwThreadId);
+ if (!hThread)
+ {
+ SetDlgShown(FALSE);
+ return TRUE;
+ }
+
+ ++m_cRefs;
+ ::CloseHandle(hThread);
+ return TRUE;
+}
+
+LONG CUTBLangBarDlg::_Release()
+{
+ if (--m_cRefs == 0)
+ {
+ delete this;
+ return 0;
+ }
+ return m_cRefs;
+}
+
+STDMETHODIMP_(BOOL) CUTBLangBarDlg::ThreadProc()
+{
+ extern HINSTANCE g_hInst;
+ ::DialogBoxParam(g_hInst, m_pszDialogName, NULL, DlgProc, (LPARAM)this);
+ SetDlgShown(FALSE);
+ _Release();
+ return TRUE;
+}
+
+INT_PTR CALLBACK
+CUTBLangBarDlg::DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ if (uMsg == WM_INITDIALOG)
+ {
+ SetThis(hDlg, (CUTBLangBarDlg *)lParam);
+ ::ShowWindow(hDlg, SW_RESTORE);
+ ::UpdateWindow(hDlg);
+ return TRUE;
+ }
+
+ if (uMsg == WM_COMMAND)
+ {
+ CUTBLangBarDlg *pThis = CUTBLangBarDlg::GetThis(hDlg);
+ pThis->OnCommand(hDlg, wParam, lParam);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/***********************************************************************
+ * CUTBCloseLangBarDlg
+ */
+
+CUTBCloseLangBarDlg::CUTBCloseLangBarDlg()
+{
+ m_cRefs = 1;
+ m_pszDialogName = MAKEINTRESOURCE(IDD_CLOSELANGBAR);
+}
+
+STDMETHODIMP_(BOOL) CUTBCloseLangBarDlg::DoModal(HWND hDlg)
+{
+ CicRegKey regKey;
+ LSTATUS error;
+ DWORD dwValue = FALSE;
+ error = regKey.Open(HKEY_CURRENT_USER,
TEXT("SOFTWARE\\Microsoft\\CTF\\MSUTB\\"));
+ if (error == ERROR_SUCCESS)
+ regKey.QueryDword(TEXT("DontShowCloseLangBarDlg"), &dwValue);
+
+ if (dwValue)
+ return FALSE;
+
+ StartThread();
+ return TRUE;
+}
+
+/// @unimplemented
+void DoCloseLangbar(void)
+{
+ //FIXME
+}
+
+STDMETHODIMP_(BOOL) CUTBCloseLangBarDlg::OnCommand(HWND hDlg, WPARAM wParam, LPARAM
lParam)
+{
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ DoCloseLangbar();
+ if (::IsDlgButtonChecked(hDlg, IDC_CLOSELANGBAR_CHECK))
+ {
+ CicRegKey regKey;
+ LSTATUS error;
+ error = regKey.Create(HKEY_CURRENT_USER,
TEXT("SOFTWARE\\Microsoft\\CTF\\MSUTB\\"));
+ if (error == ERROR_SUCCESS)
+ regKey.SetDword(TEXT("DontShowCloseLangBarDlg"), TRUE);
+ }
+ ::EndDialog(hDlg, TRUE);
+ break;
+
+ case IDCANCEL:
+ ::EndDialog(hDlg, FALSE);
+ break;
+
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+STDMETHODIMP_(BOOL) CUTBCloseLangBarDlg::IsDlgShown()
+{
+ return s_bIsDlgShown;
+}
+
+STDMETHODIMP_(void) CUTBCloseLangBarDlg::SetDlgShown(BOOL bShown)
+{
+ s_bIsDlgShown = bShown;
+}
+
+/***********************************************************************
+ * CUTBMinimizeLangBarDlg
+ */
+
+CUTBMinimizeLangBarDlg::CUTBMinimizeLangBarDlg()
+{
+ m_cRefs = 1;
+ m_pszDialogName = MAKEINTRESOURCE(IDD_MINIMIZELANGBAR);
+}
+
+STDMETHODIMP_(BOOL) CUTBMinimizeLangBarDlg::DoModal(HWND hDlg)
+{
+ CicRegKey regKey;
+ LSTATUS error;
+
+ DWORD dwValue = FALSE;
+ error = regKey.Open(HKEY_CURRENT_USER,
TEXT("SOFTWARE\\Microsoft\\CTF\\MSUTB\\"));
+ if (error == ERROR_SUCCESS)
+ regKey.QueryDword(TEXT("DontShowMinimizeLangBarDlg"), &dwValue);
+
+ if (dwValue)
+ return FALSE;
+
+ StartThread();
+ return TRUE;
+}
+
+STDMETHODIMP_(BOOL) CUTBMinimizeLangBarDlg::OnCommand(HWND hDlg, WPARAM wParam, LPARAM
lParam)
+{
+ switch (LOWORD(wParam))
+ {
+ case IDOK:
+ if (::IsDlgButtonChecked(hDlg, IDC_MINIMIZELANGBAR_CHECK))
+ {
+ LSTATUS error;
+ CicRegKey regKey;
+ error = regKey.Create(HKEY_CURRENT_USER,
TEXT("SOFTWARE\\Microsoft\\CTF\\MSUTB\\"));
+ if (error == ERROR_SUCCESS)
+ regKey.SetDword(TEXT("DontShowMinimizeLangBarDlg"), TRUE);
+ }
+ ::EndDialog(hDlg, TRUE);
+ break;
+ case IDCANCEL:
+ ::EndDialog(hDlg, FALSE);
+ break;
+ default:
+ return FALSE;
+ }
+ return TRUE;
+}
+
+STDMETHODIMP_(BOOL) CUTBMinimizeLangBarDlg::IsDlgShown()
+{
+ return s_bIsDlgShown;
+}
+
+STDMETHODIMP_(void) CUTBMinimizeLangBarDlg::SetDlgShown(BOOL bShown)
+{
+ s_bIsDlgShown = bShown;
+}
+
+STDMETHODIMP_(BOOL) CUTBMinimizeLangBarDlg::ThreadProc()
+{
+ ::Sleep(700);
+ return CUTBLangBarDlg::ThreadProc();
+}
+
/***********************************************************************
* CCicLibMenu
*/
diff --git a/dll/win32/msutb/precomp.h b/dll/win32/msutb/precomp.h
index 2f3ca726f7b..8bc4c4140a9 100644
--- a/dll/win32/msutb/precomp.h
+++ b/dll/win32/msutb/precomp.h
@@ -27,6 +27,7 @@
#undef STATUS_NO_MEMORY
#include "resource.h"
+#include <cicero/cicreg.h>
#include <cicero/cicuif.h>
#include <wine/debug.h>
diff --git a/dll/win32/msutb/resource.h b/dll/win32/msutb/resource.h
index 65532689e47..6808bd02597 100644
--- a/dll/win32/msutb/resource.h
+++ b/dll/win32/msutb/resource.h
@@ -9,3 +9,9 @@
#define IDS_NO 106
#define IDS_MENUWND 322
#define IDS_LEFTCLICK 323
+
+#define IDD_CLOSELANGBAR 1001
+#define IDD_MINIMIZELANGBAR 1004
+
+#define IDC_CLOSELANGBAR_CHECK 1002
+#define IDC_MINIMIZELANGBAR_CHECK 1002
diff --git a/sdk/include/reactos/cicero/cicuif.h b/sdk/include/reactos/cicero/cicuif.h
index 218587d3296..996f48230c6 100644
--- a/sdk/include/reactos/cicero/cicuif.h
+++ b/sdk/include/reactos/cicero/cicuif.h
@@ -5180,7 +5180,7 @@ CUIFBalloonWindow::AddButton(UINT nCommandId)
#ifdef IDS_OK
extern HINSTANCE g_hInst;
WCHAR szText[64];
- ::LoadStringW(g_hInst, IDS_OK + nCommandId, szText, _countof(szText));
+ ::LoadStringW(g_hInst, IDS_OK + (nCommandId - IDOK), szText, _countof(szText));
pszText = szText;
#else
switch (nCommandId)