diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 116230f550..11b9783e27 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -770,7 +770,7 @@ EXPORT_C GSconfigure() if(!GSUtil::CheckSSE()) return; #ifdef _WINDOWS - + GSDialog::InitCommonControls(); if(GSSettingsDlg().DoModal() == IDOK) { if(s_gs != NULL && s_gs->m_wnd->IsManaged()) diff --git a/plugins/GSdx/GSDialog.cpp b/plugins/GSdx/GSDialog.cpp index ea4c75191c..25d059b931 100644 --- a/plugins/GSdx/GSDialog.cpp +++ b/plugins/GSdx/GSDialog.cpp @@ -20,6 +20,8 @@ */ #include "StdAfx.h" +#include +#include #include "GSdx.h" #include "GSDialog.h" #include "GSVector.h" @@ -64,9 +66,48 @@ INT_PTR CALLBACK GSDialog::DialogProc(HWND hWnd, UINT message, WPARAM wParam, LP dlg = (GSDialog*)GetWindowLongPtr(hWnd, GWLP_USERDATA); + if (message == WM_NOTIFY) + { + if (((LPNMHDR)lParam)->code == TTN_GETDISPINFO) + { + LPNMTTDISPINFO pInfo = (LPNMTTDISPINFO)lParam; + UINT id = GetWindowLongPtr((HWND)pInfo->hdr.idFrom, GWL_ID); + + // lpszText is used only if hinst is NULL. Seems to be NULL already, + // but it can't hurt to explicitly set it. + pInfo->hinst = NULL; + pInfo->lpszText = (LPTSTR)dialog_message(id); + SendMessage(pInfo->hdr.hwndFrom, TTM_SETMAXTIPWIDTH, 0, 500); + return true; + } + } + return dlg != NULL ? dlg->OnMessage(message, wParam, lParam) : FALSE; } +// Tooltips will only show if the TOOLINFO cbSize <= the struct size. If it's +// smaller some functionality might be disabled. So let's try and use the +// correct size. +UINT GSDialog::GetTooltipStructSize() +{ + DLLGETVERSIONPROC dllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(GetModuleHandle("ComCtl32.dll"), "DllGetVersion"); + if (dllGetVersion) { + DLLVERSIONINFO2 dllversion = { 0 }; + dllversion.info1.cbSize = sizeof(DLLVERSIONINFO2); + + if (dllGetVersion((DLLVERSIONINFO*)&dllversion) == S_OK) { + // Minor, then major version. + DWORD version = MAKELONG(dllversion.info1.dwMinorVersion, dllversion.info1.dwMajorVersion); + DWORD tooltip_v3 = MAKELONG(0, 6); + if (version >= tooltip_v3) + return TTTOOLINFOA_V3_SIZE; + } + } + // Should be fine for XP and onwards, comctl versions >= 4.7 should at least + // be this size. + return TTTOOLINFOA_V2_SIZE; +} + bool GSDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam) { return message == WM_COMMAND ? OnCommand((HWND)lParam, LOWORD(wParam), HIWORD(wParam)) : false; @@ -226,3 +267,45 @@ void GSDialog::ComboBoxFixDroppedWidth(UINT id) } } } + +void GSDialog::AddTooltip(UINT id) +{ + static UINT tooltipStructSize = GetTooltipStructSize(); + bool hasTooltip; + + dialog_message(id, &hasTooltip); + if (!hasTooltip) + return; + + HWND hWnd = GetDlgItem(m_hWnd, id); + if (hWnd == NULL) + return; + + // TTS_NOPREFIX allows tabs and '&' to be used. + HWND hwndTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL, + TTS_ALWAYSTIP | TTS_NOPREFIX, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + m_hWnd, NULL, theApp.GetModuleHandle(), NULL); + if (hwndTip == NULL) + return; + + TOOLINFO toolInfo = { 0 }; + toolInfo.cbSize = tooltipStructSize; + toolInfo.hwnd = m_hWnd; + toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; + toolInfo.uId = (UINT_PTR)hWnd; + // Can't directly add the tooltip string - it doesn't work for long messages + toolInfo.lpszText = LPSTR_TEXTCALLBACK; + SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo); + // 32.767s is the max show time. + SendMessage(hwndTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, 32767); +} + +void GSDialog::InitCommonControls() +{ + INITCOMMONCONTROLSEX icex; + icex.dwSize = sizeof(INITCOMMONCONTROLSEX); + icex.dwICC = ICC_TAB_CLASSES; + + InitCommonControlsEx(&icex); +} diff --git a/plugins/GSdx/GSDialog.h b/plugins/GSdx/GSDialog.h index 2e5ff499ab..8f2bd86db6 100644 --- a/plugins/GSdx/GSDialog.h +++ b/plugins/GSdx/GSDialog.h @@ -28,6 +28,7 @@ class GSDialog int m_id; static INT_PTR CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); + static UINT GetTooltipStructSize(); protected: HWND m_hWnd; @@ -54,4 +55,8 @@ public: int ComboBoxAppend(UINT id, const char* str, LPARAM data = 0, bool select = false); bool ComboBoxGetSelData(UINT id, INT_PTR& data); void ComboBoxFixDroppedWidth(UINT id); + + void AddTooltip(UINT id); + + static void InitCommonControls(); }; diff --git a/plugins/GSdx/vsprops/common.props b/plugins/GSdx/vsprops/common.props index 388a3c5879..bd7c502a80 100644 --- a/plugins/GSdx/vsprops/common.props +++ b/plugins/GSdx/vsprops/common.props @@ -8,7 +8,7 @@ true - _WINDOWS;_WIN32_WINNT=0x500;%(PreprocessorDefinitions) + _WINDOWS;_WIN32_WINNT=0x501;%(PreprocessorDefinitions) Fast false Level4 @@ -18,7 +18,7 @@ true - d3d11.lib;d3dx11.lib;d3d10_1.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;dxgi.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;opengl32.lib;opencl.lib;comsuppw.lib;%(AdditionalDependencies) + d3d11.lib;d3dx11.lib;d3d10_1.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;dxgi.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;opengl32.lib;opencl.lib;comsuppw.lib;comctl32.lib;%(AdditionalDependencies) d3d9.dll;d3dx9_43.dll;d3d11.dll;d3dx11_43.dll;dxgi.dll;opengl32.dll;%(DelayLoadDLLs) true Windows