aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/General/gen_ml/skinnedmenu.cpp
diff options
context:
space:
mode:
authorJean-Francois Mauguit <jfmauguit@mac.com>2024-09-24 09:03:25 -0400
committerGitHub <noreply@github.com>2024-09-24 09:03:25 -0400
commitbab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/General/gen_ml/skinnedmenu.cpp
parent4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff)
parent20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff)
downloadwinamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Plugins/General/gen_ml/skinnedmenu.cpp')
-rw-r--r--Src/Plugins/General/gen_ml/skinnedmenu.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/Src/Plugins/General/gen_ml/skinnedmenu.cpp b/Src/Plugins/General/gen_ml/skinnedmenu.cpp
new file mode 100644
index 00000000..f583dd49
--- /dev/null
+++ b/Src/Plugins/General/gen_ml/skinnedmenu.cpp
@@ -0,0 +1,81 @@
+#include "main.h"
+#include "./skinnedmenu.h"
+#include "./skinnedmenuwnd.h"
+
+
+SkinnedMenu::SkinnedMenu()
+{
+ hwndOwner = NULL;
+ skinStyle = SMS_NORMAL;
+ hmlil = NULL;
+ width = 0;
+
+ if (FAILED(SkinnedMenuThreadInfo::GetInstance(TRUE, &threadInfo)))
+ threadInfo = NULL;
+}
+
+SkinnedMenu::~SkinnedMenu(void)
+{
+ if (NULL != threadInfo)
+ {
+ threadInfo->RemoveAttachHook(this);
+ threadInfo->Release();
+ }
+}
+
+HWND SkinnedMenu::WindowFromHandle(HMENU menu)
+{
+ HWND hwnd;
+ SkinnedMenuThreadInfo *threadInfo;
+
+ if (S_OK != SkinnedMenuThreadInfo::GetInstance(FALSE, &threadInfo))
+ return NULL;
+
+ hwnd = threadInfo->FindMenuWindow(menu);
+
+ threadInfo->Release();
+
+ return hwnd;
+}
+
+BOOL SkinnedMenu::InitializeHook(HWND hwndOwner, UINT skinStyle, HMLIMGLST hmlil, INT width, MENUCUSTOMIZEPROC _customProc, ULONG_PTR customParam)
+{
+ if (NULL == threadInfo)
+ return FALSE;
+
+ if (FALSE != threadInfo->IsAttachHookActive())
+ return FALSE;
+
+ this->hwndOwner = hwndOwner;
+ this->hmlil = hmlil;
+ this->width = width;
+ this->skinStyle = skinStyle;
+ this->customProc = _customProc;
+ this->customParam = customParam;
+
+ return threadInfo->SetAttachHook(this);
+}
+
+BOOL SkinnedMenu::TrackMenuPopupEx(HMENU hmenu, UINT fuFlags, INT x, INT y, HWND hwnd, LPTPMPARAMS lptpm, UINT skinStyle,
+ HMLIMGLST hmlil, INT width, MENUCUSTOMIZEPROC customProc, ULONG_PTR customParam)
+{
+ if (NULL == hwnd ||
+ !InitializeHook(hwnd, skinStyle, hmlil, width, customProc, customParam))
+ {
+ return FALSE;
+ }
+
+ return TrackPopupMenuEx(hmenu, fuFlags, x, y, hwnd, lptpm);
+}
+
+BOOL SkinnedMenu::AttachToHwnd(HWND hwndMenu)
+{
+ SkinnedMenuWnd *psw = new SkinnedMenuWnd(skinStyle, hmlil, width, customProc, customParam);
+ if (!psw || !psw->Attach(hwndMenu, hwndOwner))
+ {
+ delete(psw);
+ return FALSE;
+ }
+
+ return TRUE;
+}