https://git.reactos.org/?p=reactos.git;a=commitdiff;h=89d8b472af5b5c3960cbe…
commit 89d8b472af5b5c3960cbe92f9521b9d866398798
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Jan 17 12:42:54 2024 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Jan 17 12:42:54 2024 +0900
[MSUTB] Add CTrayIconItem (#6371)
Supporting Language Bar...
JIRA issue: CORE-19363
- Implement CTrayIconItem class.
- Add delay link to shell32.dll.
---
dll/win32/msutb/CMakeLists.txt | 2 +-
dll/win32/msutb/msutb.cpp | 107 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 108 insertions(+), 1 deletion(-)
diff --git a/dll/win32/msutb/CMakeLists.txt b/dll/win32/msutb/CMakeLists.txt
index d4259dc7cda..dd79a30d8c5 100644
--- a/dll/win32/msutb/CMakeLists.txt
+++ b/dll/win32/msutb/CMakeLists.txt
@@ -15,5 +15,5 @@ set_module_type(msutb win32dll)
add_dependencies(msutb msctf psdk)
target_link_libraries(msutb wine uuid atl_classes)
add_importlibs(msutb user32 gdi32 advapi32 msvcrt kernel32 ntdll)
-add_delay_importlibs(msutb comctl32 msctf ole32 oleaut32)
+add_delay_importlibs(msutb comctl32 msctf ole32 oleaut32 shell32)
add_cd_file(TARGET msutb DESTINATION reactos/system32 FOR all)
diff --git a/dll/win32/msutb/msutb.cpp b/dll/win32/msutb/msutb.cpp
index 4ba8f878913..ec7e1ea24cb 100644
--- a/dll/win32/msutb/msutb.cpp
+++ b/dll/win32/msutb/msutb.cpp
@@ -30,6 +30,113 @@ END_OBJECT_MAP()
CMsUtbModule gModule;
+/***********************************************************************/
+
+class CTrayIconWnd
+{
+public:
+ //FIXME
+ HWND GetNotifyWnd() { return NULL; };
+};
+
+/***********************************************************************/
+
+class CTrayIconItem
+{
+protected:
+ HWND m_hWnd;
+ UINT m_uCallbackMessage;
+ UINT m_uNotifyIconID;
+ DWORD m_dwIconAddOrModify;
+ BOOL m_bIconAdded;
+ CTrayIconWnd *m_pTrayIconWnd;
+ DWORD m_dw;
+ GUID m_guid;
+ RECT m_rcMenu;
+ POINT m_ptCursor;
+
+ CTrayIconItem(CTrayIconWnd *pTrayIconWnd);
+
+ BOOL _Init(HWND hWnd, UINT uCallbackMessage, UINT uNotifyIconID, const GUID&
rguid);
+ BOOL UpdateMenuRectPoint();
+ BOOL RemoveIcon();
+
+ STDMETHOD_(BOOL, SetIcon)(HICON hIcon, LPCTSTR pszTip);
+ STDMETHOD_(LRESULT, OnMsg)(WPARAM wParam, LPARAM lParam) { return 0; };
+ STDMETHOD_(LRESULT, OnDelayMsg)(LPARAM lParam) { return 0; };
+};
+
+/***********************************************************************
+ * CTrayIconItem
+ */
+
+CTrayIconItem::CTrayIconItem(CTrayIconWnd *pTrayIconWnd)
+{
+ m_dwIconAddOrModify = NIM_ADD;
+ m_pTrayIconWnd = pTrayIconWnd;
+}
+
+BOOL
+CTrayIconItem::_Init(
+ HWND hWnd,
+ UINT uCallbackMessage,
+ UINT uNotifyIconID,
+ const GUID& rguid)
+{
+ m_hWnd = hWnd;
+ m_uCallbackMessage = uCallbackMessage;
+ m_uNotifyIconID = uNotifyIconID;
+ m_guid = rguid;
+ return TRUE;
+}
+
+BOOL CTrayIconItem::RemoveIcon()
+{
+ if (m_dwIconAddOrModify == NIM_MODIFY)
+ {
+ NOTIFYICONDATA NotifyIcon = { sizeof(NotifyIcon), m_hWnd, m_uNotifyIconID };
+ NotifyIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
+ NotifyIcon.uCallbackMessage = m_uCallbackMessage;
+ ::Shell_NotifyIcon(NIM_DELETE, &NotifyIcon);
+ }
+
+ m_dwIconAddOrModify = NIM_ADD;
+ m_bIconAdded = TRUE;
+ return TRUE;
+}
+
+BOOL CTrayIconItem::SetIcon(HICON hIcon, LPCTSTR pszTip)
+{
+ if (!hIcon)
+ return FALSE;
+
+ NOTIFYICONDATA NotifyIcon = { sizeof(NotifyIcon), m_hWnd, m_uNotifyIconID };
+ NotifyIcon.uFlags = NIF_ICON | NIF_MESSAGE;
+ NotifyIcon.uCallbackMessage = m_uCallbackMessage;
+ NotifyIcon.hIcon = hIcon;
+ if (pszTip)
+ {
+ NotifyIcon.uFlags |= NIF_TIP;
+ StringCchCopy(NotifyIcon.szTip, _countof(NotifyIcon.szTip), pszTip);
+ }
+
+ ::Shell_NotifyIcon(m_dwIconAddOrModify, &NotifyIcon);
+
+ m_dwIconAddOrModify = NIM_MODIFY;
+ m_bIconAdded = NIM_MODIFY;
+ return TRUE;
+}
+
+BOOL CTrayIconItem::UpdateMenuRectPoint()
+{
+ HWND hNotifyWnd = m_pTrayIconWnd->GetNotifyWnd();
+ ::GetClientRect(hNotifyWnd, &m_rcMenu);
+ ::ClientToScreen(hNotifyWnd, (LPPOINT)&m_rcMenu);
+ ::ClientToScreen(hNotifyWnd, (LPPOINT)&m_rcMenu.right);
+ ::GetCursorPos(&m_ptCursor);
+ return TRUE;
+}
+
/***********************************************************************
* GetLibTls (MSUTB.@)
*