1
0

skinHelper.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. #include "main.h"
  2. #ifndef WA_DLG_IMPLEMENT
  3. #define WA_DLG_IMPLEMENT
  4. #endif // WA_DLG_IMPLEMENT
  5. #include "../winamp/wa_dlg.h"
  6. #undef WA_DLG_IMPLEMENT
  7. #include "./skinHelper.h"
  8. #include "./ratingMenuCustomizer.h"
  9. #include "./ifc_menucustomizer.h"
  10. #include <windows.h>
  11. #include <shlwapi.h>
  12. #include <strsafe.h>
  13. #define ENSURE_FUNCTION_LOADED(__function) {\
  14. HRESULT hr;\
  15. if (NULL == (__function)) {\
  16. hr = LoadMediaLibraryModule();\
  17. if (SUCCEEDED(hr) && NULL == (__function)) hr = E_UNEXPECTED;\
  18. if (FAILED(hr)) return hr; }}
  19. #define BOOL2HRESULT(__result) ((FALSE != (__result)) ? S_OK : E_FAIL)
  20. SkinHelper::SkinHelper(HWND hwndWa)
  21. : ref(1), hwndWinamp(hwndWa), mlModule(NULL), mlLoadResult(S_FALSE),
  22. playlistFont(NULL), initializeColors(TRUE), cchHostCss(0),
  23. mlSkinWindowEx(NULL), mlUnskinWindow(NULL), mlTrackSkinnedPopupMenuEx(NULL),
  24. mlIsSkinnedPopupEnabled(NULL), mlInitSkinnedPopupHook(NULL),
  25. mlRemoveSkinnedPopupHook(NULL), mlGetSkinColor(NULL), mlResetSkinColor(NULL),
  26. mlRatingDraw(NULL), mlRatingHitTest(NULL), mlRatingCalcMinRect(NULL)
  27. {
  28. ZeroMemory(szBrushes, sizeof(HBRUSH) * ARRAYSIZE(szBrushes));
  29. ZeroMemory(szHostCss, sizeof(szHostCss));
  30. }
  31. SkinHelper::~SkinHelper()
  32. {
  33. if (NULL != playlistFont)
  34. DeleteObject(playlistFont);
  35. for (int i = 0; i < ARRAYSIZE(szBrushes); i++)
  36. {
  37. if (NULL != szBrushes[i]) DeleteObject(szBrushes[i]);
  38. }
  39. if (NULL != mlModule)
  40. FreeLibrary(mlModule);
  41. }
  42. HRESULT SkinHelper::CreateInstance(HWND hwndWinamp, SkinHelper **instance)
  43. {
  44. if (NULL == instance) return E_POINTER;
  45. *instance = NULL;
  46. if (NULL == hwndWinamp || FALSE == IsWindow(hwndWinamp))
  47. return E_INVALIDARG;
  48. *instance = new SkinHelper(hwndWinamp);
  49. if (NULL == *instance) return E_OUTOFMEMORY;
  50. return S_OK;
  51. }
  52. size_t SkinHelper::AddRef()
  53. {
  54. return InterlockedIncrement((LONG*)&ref);
  55. }
  56. size_t SkinHelper::Release()
  57. {
  58. if (0 == ref)
  59. return ref;
  60. LONG r = InterlockedDecrement((LONG*)&ref);
  61. if (0 == r)
  62. delete(this);
  63. return r;
  64. }
  65. int SkinHelper::QueryInterface(GUID interface_guid, void **object)
  66. {
  67. if (NULL == object) return E_POINTER;
  68. if (IsEqualIID(interface_guid, IFC_SkinHelper))
  69. *object = static_cast<ifc_skinhelper*>(this);
  70. else if (IsEqualIID(interface_guid, IFC_SkinnedMenu))
  71. *object = static_cast<ifc_skinnedmenu*>(this);
  72. else if (IsEqualIID(interface_guid, IFC_SkinnedRating))
  73. *object = static_cast<ifc_skinnedrating*>(this);
  74. else if (IsEqualIID(interface_guid, IFC_SkinnedBrowser))
  75. *object = static_cast<ifc_skinnedbrowser*>(this);
  76. else
  77. {
  78. *object = NULL;
  79. return E_NOINTERFACE;
  80. }
  81. if (NULL == *object)
  82. return E_UNEXPECTED;
  83. AddRef();
  84. return S_OK;
  85. }
  86. HRESULT SkinHelper::GetColor(UINT colorIndex, COLORREF *pColor)
  87. {
  88. if (NULL == pColor) return E_POINTER;
  89. if (colorIndex >= WADLG_NUM_COLORS)
  90. return E_INVALIDARG;
  91. if (FALSE != initializeColors)
  92. {
  93. HRESULT hr = InitializeColorData();
  94. if (FAILED(hr)) return hr;
  95. }
  96. *pColor = WADlg_getColor(colorIndex);
  97. return S_OK;
  98. }
  99. HRESULT SkinHelper::GetColorEx(UINT uObject, UINT uPart, UINT uState, COLORREF *pColor)
  100. {
  101. if (NULL == pColor) return E_POINTER;
  102. ENSURE_FUNCTION_LOADED(mlGetSkinColor);
  103. BOOL result = mlGetSkinColor(uObject, uPart, uState, pColor);
  104. return BOOL2HRESULT(result);
  105. }
  106. HRESULT SkinHelper::GetBrush(UINT colorIndex, HBRUSH *pBrush)
  107. {
  108. if (NULL == pBrush) return E_POINTER;
  109. if (FALSE != initializeColors)
  110. InitializeColorData();
  111. if (colorIndex < WADLG_NUM_COLORS)
  112. {
  113. *pBrush = szBrushes[colorIndex];
  114. if (NULL == *pBrush)
  115. {
  116. COLORREF color = WADlg_getColor(colorIndex);
  117. *pBrush = CreateSolidBrush(color);
  118. szBrushes[colorIndex] = *pBrush;
  119. }
  120. return S_OK;
  121. }
  122. return E_INVALIDARG;
  123. }
  124. HFONT SkinHelper::GetFont()
  125. {
  126. if (NULL == playlistFont)
  127. playlistFont = CreateSkinFont();
  128. return playlistFont;
  129. }
  130. HRESULT SkinHelper::SkinWindow(HWND hwnd, const GUID *windowGuid, UINT flagsEx, FFCALLBACK callbackFF)
  131. {
  132. SKINWINDOWPARAM swp;
  133. swp.cbSize = sizeof(SKINWINDOWPARAM);
  134. swp.hwndToSkin = hwnd;
  135. swp.windowGuid = *windowGuid;
  136. swp.flagsEx = flagsEx;
  137. swp.callbackFF = callbackFF;
  138. BOOL result = (BOOL)SENDWAIPC(hwndWinamp, IPC_SKINWINDOW, (WPARAM)&swp);
  139. return BOOL2HRESULT(result);
  140. }
  141. HRESULT SkinHelper::SkinControl(HWND hwnd, UINT type, UINT style)
  142. {
  143. ENSURE_FUNCTION_LOADED(mlSkinWindowEx);
  144. BOOL result = mlSkinWindowEx(hwnd, type, style);
  145. return BOOL2HRESULT(result);
  146. }
  147. HRESULT SkinHelper::UnskinWindow(HWND hwnd)
  148. {
  149. ENSURE_FUNCTION_LOADED(mlUnskinWindow);
  150. BOOL result = mlUnskinWindow(hwnd);
  151. return BOOL2HRESULT(result);
  152. }
  153. static INT CALLBACK SkinHelper_CustomMenuProc(INT action, HMENU hMenu, HDC hdc, LPARAM param, ULONG_PTR user)
  154. {
  155. ifc_menucustomizer *customizer = (ifc_menucustomizer*)user;
  156. if (NULL != customizer)
  157. {
  158. return customizer->CustomDraw(hMenu, action, hdc, param);
  159. }
  160. return FALSE;
  161. }
  162. BOOL SkinHelper::TrackPopup(HMENU hMenu, UINT fuFlags, INT x, INT y, HWND hwnd, LPTPMPARAMS lptpm, ifc_menucustomizer *customizer)
  163. {
  164. if (ForceNoSkinnedMenu != customizer && S_OK == IsPopupEnabled())
  165. {
  166. BOOL result;
  167. HMLIMGLST hmlil = NULL;
  168. INT width = 0;
  169. UINT skinStyle = SMS_USESKINFONT;
  170. MENUCUSTOMIZEPROC customProc = NULL;
  171. ULONG_PTR customParam = 0;
  172. if (NULL != customizer)
  173. {
  174. hmlil = customizer->GetImageList();
  175. skinStyle = customizer->GetSkinStyle();
  176. if (FAILED(customizer->GetWidth(&width)))
  177. width = 0;
  178. customProc = SkinHelper_CustomMenuProc;
  179. customParam = (ULONG_PTR)customizer;
  180. }
  181. HRESULT hr = MlTrackSkinnedPopupMenuEx(hMenu, fuFlags, x, y, hwnd, lptpm,
  182. hmlil, width, skinStyle, customProc, customParam, &result);
  183. if (SUCCEEDED(hr))
  184. return result;
  185. }
  186. return TrackPopupMenuEx(hMenu, fuFlags, x, y, hwnd, lptpm);
  187. }
  188. HRESULT SkinHelper::IsPopupEnabled()
  189. {
  190. ENSURE_FUNCTION_LOADED(mlIsSkinnedPopupEnabled);
  191. return (FALSE != mlIsSkinnedPopupEnabled()) ? S_OK : S_FALSE;
  192. }
  193. HANDLE SkinHelper::InitPopupHook(HWND hwnd, ifc_menucustomizer *customizer)
  194. {
  195. if (ForceNoSkinnedMenu != customizer && S_OK == IsPopupEnabled())
  196. {
  197. HMLIMGLST hmlil = NULL;
  198. INT width = 0;
  199. UINT skinStyle = SMS_USESKINFONT;
  200. MENUCUSTOMIZEPROC customProc = NULL;
  201. ULONG_PTR customParam = 0;
  202. if (NULL != customizer)
  203. {
  204. hmlil = customizer->GetImageList();
  205. skinStyle = customizer->GetSkinStyle();
  206. if (FAILED(customizer->GetWidth(&width)))
  207. width = 0;
  208. customProc = SkinHelper_CustomMenuProc;
  209. customParam = (ULONG_PTR)customizer;
  210. }
  211. HANDLE hook;
  212. HRESULT hr = MlInitSkinnedPopupHook(hwnd, hmlil, width, skinStyle, customProc, customParam, &hook);
  213. if (FAILED(hr))
  214. hook = NULL;
  215. return hook;
  216. }
  217. return NULL;
  218. }
  219. HRESULT SkinHelper::RemovePopupHook(HANDLE hPopupHook)
  220. {
  221. ENSURE_FUNCTION_LOADED(mlRemoveSkinnedPopupHook);
  222. mlRemoveSkinnedPopupHook(hPopupHook);
  223. return S_OK;
  224. }
  225. HRESULT SkinHelper::MlTrackSkinnedPopupMenuEx(HMENU hmenu, UINT fuFlags, INT x, INT y, HWND hwnd, LPTPMPARAMS lptpm, HMLIMGLST hmlil, INT width, UINT skinStyle, MENUCUSTOMIZEPROC customProc, ULONG_PTR customParam, INT *resultOut)
  226. {
  227. if (NULL != resultOut)
  228. *resultOut = 0;
  229. ENSURE_FUNCTION_LOADED(mlTrackSkinnedPopupMenuEx);
  230. INT result = mlTrackSkinnedPopupMenuEx(hmenu, fuFlags, x, y, hwnd, lptpm, hmlil, width, skinStyle, customProc, customParam);
  231. if (NULL != resultOut)
  232. *resultOut = result;
  233. return S_OK;
  234. }
  235. HRESULT SkinHelper::MlInitSkinnedPopupHook(HWND hwnd, HMLIMGLST hmlil, INT width, UINT skinStyle, MENUCUSTOMIZEPROC customProc, ULONG_PTR customParam, HANDLE *hookOut)
  236. {
  237. if (NULL == hookOut) return E_POINTER;
  238. *hookOut = NULL;
  239. ENSURE_FUNCTION_LOADED(mlInitSkinnedPopupHook);
  240. *hookOut = mlInitSkinnedPopupHook(hwnd, hmlil, width, skinStyle, customProc, customParam);
  241. if (NULL == *hookOut)
  242. return E_FAIL;
  243. return S_OK;
  244. }
  245. HRESULT SkinHelper::RatingDraw(HDC hdc, INT maxValue, INT value, INT trackingVal, RECT *prc, UINT fStyle)
  246. {
  247. ENSURE_FUNCTION_LOADED(mlRatingDraw);
  248. BOOL result = mlRatingDraw(hdc, maxValue, value, trackingVal, NULL, 0, prc, fStyle);
  249. return BOOL2HRESULT(result);
  250. }
  251. HRESULT SkinHelper::RatingHitTest(POINT pt, INT maxValue, RECT *prc, UINT fStyle, LONG *result)
  252. {
  253. if (NULL == result) return E_POINTER;
  254. ENSURE_FUNCTION_LOADED(mlRatingHitTest);
  255. *result = mlRatingHitTest(pt, maxValue, NULL, prc, fStyle);
  256. return S_OK;
  257. }
  258. HRESULT SkinHelper::RatingCalcMinRect(INT maxValue, RECT *prc)
  259. {
  260. ENSURE_FUNCTION_LOADED(mlRatingCalcMinRect);
  261. BOOL result = mlRatingCalcMinRect(maxValue, NULL, prc);
  262. return BOOL2HRESULT(result);
  263. }
  264. HRESULT SkinHelper::RatingCreateMenuCustomizer(HMENU hMenu, ifc_menucustomizer **customizer)
  265. {
  266. return RatingMenuCustomizer::CreateInstance(hMenu, this, (RatingMenuCustomizer**)customizer);
  267. }
  268. HRESULT SkinHelper::LoadMediaLibraryModule()
  269. {
  270. if (S_FALSE != mlLoadResult)
  271. return mlLoadResult;
  272. WCHAR szPath[MAX_PATH*2] = {0};
  273. PathCombine(szPath, (LPCWSTR)SENDWAIPC(hwndWinamp, IPC_GETPLUGINDIRECTORYW, 0), L"gen_ml.dll");
  274. mlModule = LoadLibrary(szPath);
  275. if (NULL == mlModule)
  276. mlLoadResult = HRESULT_FROM_WIN32(GetLastError());
  277. if (SUCCEEDED(mlLoadResult))
  278. {
  279. mlSkinWindowEx = (MLSKINWINDOWEX)GetProcAddress(mlModule, "MlSkinWindowEx");
  280. mlUnskinWindow = (MLUNSKINWINDOW)GetProcAddress(mlModule, "MlUnskinWindow");
  281. mlTrackSkinnedPopupMenuEx = (MLTRACKSKINNEDPOPUPMENUEX)GetProcAddress(mlModule, "MlTrackSkinnedPopupMenuEx");
  282. mlIsSkinnedPopupEnabled = (MLISSKINNEDPOPUPENABLED)GetProcAddress(mlModule, "MlIsSkinnedPopupEnabled");
  283. mlGetSkinColor = (MLGETSKINCOLOR)GetProcAddress(mlModule, "MlGetSkinColor");
  284. mlResetSkinColor = (MLRESETSKINCOLOR)GetProcAddress(mlModule, "MlResetSkinColor");
  285. mlInitSkinnedPopupHook = (MLINITSKINNEDPOPUPHOOK)GetProcAddress(mlModule, "MlInitSkinnedPopupHook");
  286. mlRemoveSkinnedPopupHook = (MLREMOVESKINNEDPOPUPHOOK)GetProcAddress(mlModule, "MlRemoveSkinnedPopupHook");
  287. mlRatingDraw = (MLRATINGDRAW)GetProcAddress(mlModule, "MlRatingDraw");
  288. mlRatingHitTest = (MLRATINGHITTEST)GetProcAddress(mlModule, "MlRatingHitTest");
  289. mlRatingCalcMinRect = (MLRATINGCALCMINRECT)GetProcAddress(mlModule, "MlRatingCalcMinRect");
  290. }
  291. return mlLoadResult;
  292. }
  293. HRESULT SkinHelper::InitializeColorData()
  294. {
  295. if (NULL == hwndWinamp || !IsWindow(hwndWinamp))
  296. return E_UNEXPECTED;
  297. for (int i = 0; i < ARRAYSIZE(szBrushes); i++)
  298. {
  299. if (NULL != szBrushes[i])
  300. {
  301. DeleteObject(szBrushes[i]);
  302. szBrushes[i] = NULL;
  303. }
  304. }
  305. cchHostCss = 0;
  306. WADlg_init(hwndWinamp);
  307. initializeColors = FALSE;
  308. return S_OK;
  309. }
  310. HFONT SkinHelper::CreateSkinFont()
  311. {
  312. if (NULL == hwndWinamp || !IsWindow(hwndWinamp))
  313. return NULL;
  314. LOGFONT lf =
  315. {
  316. 0, /* lfHeight */
  317. 0, /* lfWidth */
  318. 0, /* lfEscapement */
  319. 0, /* lfOrientation */
  320. FW_NORMAL, /* lfWeight */
  321. FALSE, /* lfItalic */
  322. FALSE, /* lfUnderline */
  323. FALSE, /* lfStrikeOut */
  324. DEFAULT_CHARSET, /* lfCharSet */
  325. OUT_DEFAULT_PRECIS, /* lfOutPrecision */
  326. CLIP_DEFAULT_PRECIS, /* lfClipPrecision */
  327. DEFAULT_QUALITY, /* lfQuality */
  328. DEFAULT_PITCH | FF_DONTCARE, /* lfPitchAndFamily */
  329. TEXT(""), /* lfFaceName */
  330. };
  331. lf.lfHeight = -(INT)SENDWAIPC(hwndWinamp, IPC_GET_GENSKINBITMAP, 3);
  332. lf.lfCharSet = (BYTE)SENDWAIPC(hwndWinamp, IPC_GET_GENSKINBITMAP, 2);
  333. LPCSTR faceNameAnsi = (LPCSTR)SENDWAIPC(hwndWinamp,IPC_GET_GENSKINBITMAP, 1);
  334. if (NULL != faceNameAnsi/* && '\0' != faceNameAnsi*/)
  335. {
  336. INT count = MultiByteToWideChar(CP_ACP, 0, faceNameAnsi, -1, lf.lfFaceName, ARRAYSIZE(lf.lfFaceName));
  337. if (count > 0) count--;
  338. lf.lfFaceName[count] = L'\0';
  339. }
  340. return CreateFontIndirect(&lf);
  341. }
  342. void SkinHelper::ResetColorCache()
  343. {
  344. initializeColors = TRUE;
  345. if (NULL != mlResetSkinColor)
  346. mlResetSkinColor();
  347. }
  348. void SkinHelper::ResetFontCache()
  349. {
  350. if (NULL != playlistFont)
  351. {
  352. DeleteObject(playlistFont);
  353. playlistFont = NULL;
  354. }
  355. }
  356. #define RGBTOHTML(__rgbColor) (((__rgbColor)>>16) & 0xFF | ((__rgbColor)&0xFF00) | (((__rgbColor)<<16)&0xFF0000))
  357. HRESULT SkinHelper::Browser_GetHostCss(wchar_t **ppchHostCss)
  358. {
  359. if (NULL == ppchHostCss) return E_POINTER;
  360. *ppchHostCss = NULL;
  361. if (FALSE != initializeColors)
  362. {
  363. HRESULT hr = InitializeColorData();
  364. if (FAILED(hr)) return hr;
  365. }
  366. if (0 == cchHostCss)
  367. {
  368. size_t remaining;
  369. COLORREF szColors[] =
  370. {
  371. Browser_GetBackColor(),
  372. Browser_GetTextColor(),
  373. (COLORREF)WADlg_getColor(WADLG_LISTHEADER_BGCOLOR),
  374. (COLORREF)WADlg_getColor(WADLG_SCROLLBAR_BGCOLOR),
  375. (COLORREF)WADlg_getColor(WADLG_LISTHEADER_FRAME_TOPCOLOR),
  376. (COLORREF)WADlg_getColor(WADLG_LISTHEADER_BGCOLOR),
  377. (COLORREF)WADlg_getColor(WADLG_LISTHEADER_FRAME_BOTTOMCOLOR),
  378. (COLORREF)WADlg_getColor(WADLG_LISTHEADER_BGCOLOR),
  379. (COLORREF)WADlg_getColor(WADLG_BUTTONFG),
  380. Browser_GetLinkColor(),
  381. Browser_GetActiveLinkColor(),
  382. Browser_GetVisitedLinkColor(),
  383. Browser_GetHoveredLinkColor(),
  384. };
  385. for (INT i = 0; i < ARRAYSIZE(szColors); i++)
  386. {
  387. COLORREF c = szColors[i];
  388. szColors[i] = RGBTOHTML(c);
  389. }
  390. HRESULT hr = StringCchPrintfEx(szHostCss, ARRAYSIZE(szHostCss), NULL, &remaining,
  391. STRSAFE_IGNORE_NULLS | STRSAFE_NULL_ON_FAILURE | STRSAFE_NO_TRUNCATION,
  392. L"body { "
  393. L"background-color: #%06X;"
  394. L"color: #%06X;"
  395. L"scrollbar-face-color: #%06X;"
  396. L"scrollbar-track-color: #%06X;"
  397. L"scrollbar-3dlight-color: #%06X;"
  398. L"scrollbar-shadow-color: #%06X;"
  399. L"scrollbar-darkshadow-color: #%06X;"
  400. L"scrollbar-highlight-color: #%06X;"
  401. L"scrollbar-arrow-color: #%06X;"
  402. L"}"
  403. L"a:link {color: #%06X;}"
  404. L"a:active {color: #%06X;}"
  405. L"a:visited {color: #%06X;}"
  406. L"a:hover {color: #%06X;}",
  407. szColors[0], szColors[1], szColors[2], szColors[3], szColors[4], szColors[5], szColors[6],
  408. szColors[7], szColors[8], szColors[9], szColors[10], szColors[11], szColors[12]
  409. );
  410. if (FAILED(hr))
  411. return E_UNEXPECTED;
  412. cchHostCss = ARRAYSIZE(szHostCss) - remaining;
  413. }
  414. LPWSTR buffer = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR) * (cchHostCss + 1));
  415. if (NULL == buffer) return E_OUTOFMEMORY;
  416. if (FAILED(StringCchCopy(buffer, cchHostCss + 1, szHostCss)))
  417. return E_UNEXPECTED;
  418. *ppchHostCss = buffer;
  419. return S_OK;
  420. }
  421. COLORREF SkinHelper::Browser_GetBackColor(void)
  422. {
  423. COLORREF rgb;
  424. if (FAILED(GetColorEx(MLSO_OMBROWSER, BP_BACKGROUND, 0, &rgb)))
  425. rgb = GetSysColor(COLOR_WINDOW);
  426. return rgb;
  427. }
  428. COLORREF SkinHelper::Browser_GetTextColor(void)
  429. {
  430. COLORREF rgb;
  431. if (FAILED(GetColorEx(MLSO_OMBROWSER, BP_TEXT, BTS_NORMAL, &rgb)))
  432. rgb = GetSysColor(COLOR_WINDOWTEXT);
  433. return rgb;
  434. }
  435. COLORREF SkinHelper::Browser_GetLinkColor(void)
  436. {
  437. COLORREF rgb;
  438. if (FAILED(GetColorEx(MLSO_OMBROWSER, BP_LINK, BLS_NORMAL, &rgb)))
  439. rgb = GetSysColor(COLOR_HOTLIGHT);
  440. return rgb;
  441. }
  442. COLORREF SkinHelper::Browser_GetActiveLinkColor(void)
  443. {
  444. COLORREF rgb;
  445. if (FAILED(GetColorEx(MLSO_OMBROWSER, BP_LINK, BLS_ACTIVE, &rgb)))
  446. rgb = GetSysColor(COLOR_HOTLIGHT);
  447. return rgb;
  448. }
  449. COLORREF SkinHelper::Browser_GetVisitedLinkColor(void)
  450. {
  451. COLORREF rgb;
  452. if (FAILED(GetColorEx(MLSO_OMBROWSER, BP_LINK, BLS_VISITED, &rgb)))
  453. rgb = GetSysColor(COLOR_WINDOWTEXT);
  454. return rgb;
  455. }
  456. COLORREF SkinHelper::Browser_GetHoveredLinkColor(void)
  457. {
  458. COLORREF rgb;
  459. if (FAILED(GetColorEx(MLSO_OMBROWSER, BP_LINK, BLS_HOVER, &rgb)))
  460. rgb = GetSysColor(COLOR_HOTLIGHT);
  461. return rgb;
  462. }
  463. #define CBCLASS SkinHelper
  464. START_MULTIPATCH;
  465. START_PATCH(MPIID_SKINHELPER)
  466. M_CB(MPIID_SKINHELPER, ifc_skinhelper, ADDREF, AddRef);
  467. M_CB(MPIID_SKINHELPER, ifc_skinhelper, RELEASE, Release);
  468. M_CB(MPIID_SKINHELPER, ifc_skinhelper, QUERYINTERFACE, QueryInterface);
  469. M_CB(MPIID_SKINHELPER, ifc_skinhelper, API_GETCOLOR, GetColor);
  470. M_CB(MPIID_SKINHELPER, ifc_skinhelper, API_GETCOLOREX, GetColorEx);
  471. M_CB(MPIID_SKINHELPER, ifc_skinhelper, API_GETBRUSH, GetBrush);
  472. M_CB(MPIID_SKINHELPER, ifc_skinhelper, API_GETFONT, GetFont);
  473. M_CB(MPIID_SKINHELPER, ifc_skinhelper, API_SKINWINDOW, SkinWindow);
  474. M_CB(MPIID_SKINHELPER, ifc_skinhelper, API_SKINCONTROL, SkinControl);
  475. M_CB(MPIID_SKINHELPER, ifc_skinhelper, API_UNSKINWINDOW, UnskinWindow);
  476. NEXT_PATCH(MPIID_SKINNEDMENU)
  477. M_CB(MPIID_SKINNEDMENU, ifc_skinnedmenu, ADDREF, AddRef);
  478. M_CB(MPIID_SKINNEDMENU, ifc_skinnedmenu, RELEASE, Release);
  479. M_CB(MPIID_SKINNEDMENU, ifc_skinnedmenu, QUERYINTERFACE, QueryInterface);
  480. M_CB(MPIID_SKINNEDMENU, ifc_skinnedmenu, API_TRACKPOPUP, TrackPopup);
  481. M_CB(MPIID_SKINNEDMENU, ifc_skinnedmenu, API_ISENABLED, IsPopupEnabled);
  482. M_CB(MPIID_SKINNEDMENU, ifc_skinnedmenu, API_INITPOPUPHOOK, InitPopupHook);
  483. M_CB(MPIID_SKINNEDMENU, ifc_skinnedmenu, API_REMOVEPOPUPHOOK, RemovePopupHook);
  484. NEXT_PATCH(MPIID_SKINNEDRATING)
  485. M_CB(MPIID_SKINNEDRATING, ifc_skinnedrating, ADDREF, AddRef);
  486. M_CB(MPIID_SKINNEDRATING, ifc_skinnedrating, RELEASE, Release);
  487. M_CB(MPIID_SKINNEDRATING, ifc_skinnedrating, QUERYINTERFACE, QueryInterface);
  488. M_CB(MPIID_SKINNEDRATING, ifc_skinnedrating, API_DRAW, RatingDraw);
  489. M_CB(MPIID_SKINNEDRATING, ifc_skinnedrating, API_HITTEST, RatingHitTest);
  490. M_CB(MPIID_SKINNEDRATING, ifc_skinnedrating, API_CALCMINRECT, RatingCalcMinRect);
  491. M_CB(MPIID_SKINNEDRATING, ifc_skinnedrating, API_CREATEMENUCUSTOMIZER, RatingCreateMenuCustomizer);
  492. NEXT_PATCH(MPIID_SKINNEDBROWSER)
  493. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, ADDREF, AddRef);
  494. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, RELEASE, Release);
  495. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, QUERYINTERFACE, QueryInterface);
  496. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, API_GETHOSTCSS, Browser_GetHostCss);
  497. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, API_GETBACKCOLOR, Browser_GetBackColor);
  498. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, API_GETTEXTCOLOR, Browser_GetTextColor);
  499. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, API_GETLINKCOLOR, Browser_GetLinkColor);
  500. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, API_GETACTIVELINKCOLOR, Browser_GetActiveLinkColor);
  501. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, API_GETVISITEDLINKCOLOR, Browser_GetVisitedLinkColor);
  502. M_CB(MPIID_SKINNEDBROWSER, ifc_skinnedbrowser, API_GETHOVEREDLINKCOLOR, Browser_GetHoveredLinkColor);
  503. END_PATCH
  504. END_MULTIPATCH;
  505. #undef CBCLASS