https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c9c5b3d3ae4e849f81d3f…
commit c9c5b3d3ae4e849f81d3f0cdab72a2134cb62853
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Feb 7 14:11:21 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Feb 7 14:11:21 2024 +0900
[MSUTB][SDK] Add CModalMenu (#6451)
Supporting Language Bar...
JIRA issue: CORE-19363
- Fix the return value type of
CUIFObject::Initialize method.
- Implement CModalMenu class.
---
dll/win32/msutb/msutb.cpp | 77 +++++++++++++++++++++++++++++++------
sdk/include/reactos/cicero/cicuif.h | 18 +++++----
2 files changed, 75 insertions(+), 20 deletions(-)
diff --git a/dll/win32/msutb/msutb.cpp b/dll/win32/msutb/msutb.cpp
index 37b5176bb1e..ba2b71e43ca 100644
--- a/dll/win32/msutb/msutb.cpp
+++ b/dll/win32/msutb/msutb.cpp
@@ -769,7 +769,7 @@ public:
STDMETHOD_(BSTR, GetAccName)() override;
STDMETHOD_(INT, GetAccRole)() override;
- STDMETHOD_(void, Initialize)() override;
+ STDMETHOD_(BOOL, Initialize)() override;
STDMETHOD_(void, OnCreate)(HWND hWnd) override;
STDMETHOD_(void, OnDestroy)(HWND hWnd) override;
STDMETHOD_(HRESULT, OnGetObject)(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
override;
@@ -782,11 +782,11 @@ public:
class CUTBMenuItem : public CTipbarAccItem, public CUIFMenuItem
{
protected:
- CUTBMenuWnd *m_pMenuWnd;
+ CUTBMenuWnd *m_pMenuUI;
friend class CUTBMenuWnd;
public:
- CUTBMenuItem(CUTBMenuWnd *pMenuWnd);
+ CUTBMenuItem(CUTBMenuWnd *pMenuUI);
~CUTBMenuItem() override;
CUIFMenuItem* GetMenuItem()
@@ -804,6 +804,23 @@ public:
/***********************************************************************/
+class CModalMenu
+{
+public:
+ DWORD m_dwUnknown26;
+ CUTBMenuWnd *m_pMenuUI;
+
+public:
+ CModalMenu() { }
+ virtual ~CModalMenu() { }
+
+ CUTBMenuItem *InsertItem(CUTBMenuWnd *pMenuUI, SIZE_T uBytes, INT nStringID);
+ void PostKey(BOOL bUp, WPARAM wParam, LPARAM lParam);
+ void CancelMenu();
+};
+
+/***********************************************************************/
+
class CUTBLBarMenuItem;
class CUTBLBarMenu : public CCicLibMenu
@@ -1994,7 +2011,7 @@ STDMETHODIMP_(INT) CUTBMenuWnd::GetAccRole()
return 9;
}
-STDMETHODIMP_(void) CUTBMenuWnd::Initialize()
+STDMETHODIMP_(BOOL) CUTBMenuWnd::Initialize()
{
CTipbarAccessible *pAccessible = new(cicNoThrow) CTipbarAccessible(GetAccItem());
if (pAccessible)
@@ -2086,10 +2103,10 @@ STDMETHODIMP_(void) CUTBMenuWnd::OnTimer(WPARAM wParam)
* CUTBMenuItem
*/
-CUTBMenuItem::CUTBMenuItem(CUTBMenuWnd *pMenuWnd)
- : CUIFMenuItem(pMenuWnd ? pMenuWnd->GetMenu() : NULL)
+CUTBMenuItem::CUTBMenuItem(CUTBMenuWnd *pMenuUI)
+ : CUIFMenuItem(pMenuUI ? pMenuUI->GetMenu() : NULL)
{
- m_pMenuWnd = pMenuWnd;
+ m_pMenuUI = pMenuUI;
}
CUTBMenuItem::~CUTBMenuItem()
@@ -2108,10 +2125,10 @@ CUTBMenuItem::~CUTBMenuItem()
STDMETHODIMP_(BOOL) CUTBMenuItem::DoAccDefaultAction()
{
- if (!m_pMenuWnd)
+ if (!m_pMenuUI)
return FALSE;
- m_pMenuWnd->StartDoAccDefaultActionTimer(this);
+ m_pMenuUI->StartDoAccDefaultActionTimer(this);
return TRUE;
}
@@ -2134,8 +2151,8 @@ STDMETHODIMP_(BSTR) CUTBMenuItem::GetAccDefaultAction()
STDMETHODIMP_(void) CUTBMenuItem::GetAccLocation(LPRECT lprc)
{
GetRect(lprc);
- ::ClientToScreen(m_pMenuWnd->m_hWnd, (LPPOINT)lprc);
- ::ClientToScreen(m_pMenuWnd->m_hWnd, (LPPOINT)&lprc->right);
+ ::ClientToScreen(m_pMenuUI->m_hWnd, (LPPOINT)lprc);
+ ::ClientToScreen(m_pMenuUI->m_hWnd, (LPPOINT)&lprc->right);
}
STDMETHODIMP_(BSTR) CUTBMenuItem::GetAccName()
@@ -2151,6 +2168,42 @@ STDMETHODIMP_(INT) CUTBMenuItem::GetAccRole()
return 12;
}
+/***********************************************************************
+ * CModalMenu
+ */
+
+CUTBMenuItem *
+CModalMenu::InsertItem(CUTBMenuWnd *pMenuUI, SIZE_T uBytes, INT nStringID)
+{
+ CUTBMenuItem *pMenuItem = new(cicNoThrow) CUTBMenuItem(pMenuUI);
+ if (!pMenuItem)
+ return NULL;
+
+ WCHAR szText[256];
+ ::LoadStringW(g_hInst, nStringID, szText, _countof(szText));
+
+ if (pMenuItem->Initialize() &&
+ pMenuItem->Init(uBytes, szText) &&
+ pMenuUI->InsertItem(pMenuItem))
+ {
+ return pMenuItem;
+ }
+
+ delete pMenuItem;
+ return NULL;
+}
+
+void CModalMenu::PostKey(BOOL bUp, WPARAM wParam, LPARAM lParam)
+{
+ m_pMenuUI->PostKey(bUp, wParam, lParam);
+}
+
+void CModalMenu::CancelMenu()
+{
+ if (m_pMenuUI)
+ m_pMenuUI->CancelMenu();
+}
+
/***********************************************************************
* CTrayIconItem
*/
@@ -2976,7 +3029,7 @@ STDMETHODIMP CLBarInatItem::OnMenuSelect(INT nCommandId)
#if 0 // FIXME: g_pTipbarWnd
g_pTipbarWnd->RestoreLastFocus(0, (g_pTipbarWnd->m_dwTipbarWndFlags &
2) != 0);
#endif
- HWND hwndFore = GetForegroundWindow();
+ HWND hwndFore = ::GetForegroundWindow();
if (m_dwThreadId == ::GetWindowThreadProcessId(hwndFore, NULL))
{
BOOL FontSig = GetFontSig(hwndFore, hKL);
diff --git a/sdk/include/reactos/cicero/cicuif.h b/sdk/include/reactos/cicero/cicuif.h
index 996f48230c6..ba9e9d8ab42 100644
--- a/sdk/include/reactos/cicero/cicuif.h
+++ b/sdk/include/reactos/cicero/cicuif.h
@@ -236,7 +236,7 @@ public:
void StartTimer(WPARAM wParam);
void EndTimer();
- STDMETHOD_(void, Initialize)() { }
+ STDMETHOD_(BOOL, Initialize)() { return TRUE; }
STDMETHOD_(void, OnPaint)(HDC hDC);
STDMETHOD_(void, OnTimer)() { }
STDMETHOD_(void, OnLButtonDown)(LONG x, LONG y) { }
@@ -568,7 +568,7 @@ public:
static CUIFWindow* GetThis(HWND hWnd);
static void SetThis(HWND hWnd, LONG_PTR dwNewLong);
- STDMETHOD_(void, Initialize)() override;
+ STDMETHOD_(BOOL, Initialize)() override;
STDMETHOD_(void, Show)(BOOL bVisible) override;
STDMETHOD_(void, SetRect)(LPCRECT prc) override;
STDMETHOD_(void, PaintObject)(HDC hDC, LPCRECT prc) override;
@@ -697,7 +697,7 @@ public:
void AdjustWindowPos();
void OnOwnerWndMoved(BOOL bDoSize);
- STDMETHOD_(void, Initialize)() override;
+ STDMETHOD_(BOOL, Initialize)() override;
STDMETHOD_(DWORD, GetWndStyleEx)() override;
STDMETHOD_(void, OnPaint)(HDC hDC) override;
STDMETHOD_(LRESULT, OnWindowPosChanging)(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM
lParam) override;
@@ -1064,7 +1064,7 @@ public:
CUIFBalloonWindow(HINSTANCE hInst, DWORD style);
~CUIFBalloonWindow() override;
- STDMETHOD_(void, Initialize)() override;
+ STDMETHOD_(BOOL, Initialize)() override;
STDMETHOD_(LPCTSTR, GetClassName)() override { return
TEXT("MSIME_PopupMessage"); }
STDMETHOD_(LPCTSTR, GetWndTitle)() override { return
TEXT("MSIME_PopupMessage"); }
STDMETHOD_(void, OnCreate)(HWND hWnd) override;
@@ -2561,7 +2561,7 @@ inline CUIFWindow::~CUIFWindow()
}
}
-inline STDMETHODIMP_(void)
+inline STDMETHODIMP_(BOOL)
CUIFWindow::Initialize()
{
LPCTSTR pszClass = GetClassName();
@@ -3366,11 +3366,11 @@ inline void CUIFShadow::OnOwnerWndMoved(BOOL bDoSize)
}
}
-inline STDMETHODIMP_(void)
+inline STDMETHODIMP_(BOOL)
CUIFShadow::Initialize()
{
InitSettings();
- CUIFWindow::Initialize();
+ return CUIFWindow::Initialize();
}
inline STDMETHODIMP_(DWORD)
@@ -5060,7 +5060,7 @@ CUIFBalloonWindow::~CUIFBalloonWindow()
}
}
-inline STDMETHODIMP_(void)
+inline STDMETHODIMP_(BOOL)
CUIFBalloonWindow::Initialize()
{
CUIFWindow::Initialize();
@@ -5074,6 +5074,8 @@ CUIFBalloonWindow::Initialize()
AddButton(IDYES);
AddButton(IDNO);
}
+
+ return TRUE;
}
inline STDMETHODIMP_(void)