Code enhancement: Replace undocumented functions
Fix #12721, close #12722
This commit is contained in:
parent
6a8a446eb6
commit
50e95d2267
|
@ -167,8 +167,8 @@ enum Platform { PF_UNKNOWN, PF_X86, PF_X64, PF_IA64, PF_ARM64 };
|
|||
#define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44)
|
||||
//BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0)
|
||||
|
||||
#define NPPM_GETENABLETHEMETEXTUREFUNC (NPPMSG + 45)
|
||||
//BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0)
|
||||
#define NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED (NPPMSG + 45)
|
||||
//BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) -- DEPRECATED : use EnableThemeDialogTexture from uxtheme.h instead
|
||||
|
||||
#define NPPM_GETPLUGINSCONFIGDIR (NPPMSG + 46)
|
||||
//INT NPPM_GETPLUGINSCONFIGDIR(int strLen, TCHAR *str)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <shlwapi.h>
|
||||
#include <uxtheme.h> // for EnableThemeDialogTexture
|
||||
#include "Notepad_plus_Window.h"
|
||||
#include "TaskListDlg.h"
|
||||
#include "ImageListSet.h"
|
||||
|
@ -2658,9 +2659,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
case NPPM_GETENABLETHEMETEXTUREFUNC:
|
||||
case NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED:
|
||||
{
|
||||
return (LRESULT)nppParam.getEnableThemeDlgTexture();
|
||||
return reinterpret_cast<LRESULT>(&EnableThemeDialogTexture);
|
||||
}
|
||||
|
||||
case NPPM_GETPLUGINSCONFIGDIR:
|
||||
|
|
|
@ -991,8 +991,6 @@ NppParameters::~NppParameters()
|
|||
delete _LRFileList[i];
|
||||
for (int i = 0 ; i < _nbUserLang ; ++i)
|
||||
delete _userLangArray[i];
|
||||
if (_hUXTheme)
|
||||
FreeLibrary(_hUXTheme);
|
||||
|
||||
for (std::vector<TiXmlDocument *>::iterator it = _pXmlExternalLexerDoc.begin(), end = _pXmlExternalLexerDoc.end(); it != end; ++it )
|
||||
delete (*it);
|
||||
|
@ -1221,20 +1219,6 @@ bool NppParameters::load()
|
|||
}
|
||||
}
|
||||
|
||||
//-------------------------------------//
|
||||
// Transparent function for w2k and xp //
|
||||
//-------------------------------------//
|
||||
HMODULE hUser32 = ::GetModuleHandle(TEXT("User32"));
|
||||
if (hUser32)
|
||||
_transparentFuncAddr = (WNDPROC)::GetProcAddress(hUser32, "SetLayeredWindowAttributes");
|
||||
|
||||
//---------------------------------------------//
|
||||
// Dlg theme texture function for xp and vista //
|
||||
//---------------------------------------------//
|
||||
_hUXTheme = ::LoadLibraryEx(TEXT("uxtheme.dll"), nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
if (_hUXTheme)
|
||||
_enableThemeDialogTextureFuncAddr = (WNDPROC)::GetProcAddress(_hUXTheme, "EnableThemeDialogTexture");
|
||||
|
||||
//--------------------------//
|
||||
// langs.xml : for per user //
|
||||
//--------------------------//
|
||||
|
@ -1619,7 +1603,7 @@ void NppParameters::destroyInstance()
|
|||
delete _pXmlUserStylerDoc;
|
||||
|
||||
//delete _pXmlUserLangDoc; will be deleted in the vector
|
||||
for (auto l : _pXmlUserLangsDoc)
|
||||
for (auto& l : _pXmlUserLangsDoc)
|
||||
{
|
||||
delete l._udlXmlDoc;
|
||||
}
|
||||
|
@ -1651,22 +1635,19 @@ void NppParameters::setWorkSpaceFilePath(int i, const TCHAR* wsFile)
|
|||
|
||||
void NppParameters::removeTransparent(HWND hwnd)
|
||||
{
|
||||
if (hwnd != NULL)
|
||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) & ~0x00080000);
|
||||
if (hwnd != nullptr)
|
||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED);
|
||||
}
|
||||
|
||||
|
||||
void NppParameters::SetTransparent(HWND hwnd, int percent)
|
||||
{
|
||||
if (nullptr != _transparentFuncAddr)
|
||||
{
|
||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) | 0x00080000);
|
||||
if (percent > 255)
|
||||
percent = 255;
|
||||
if (percent < 0)
|
||||
percent = 0;
|
||||
_transparentFuncAddr(hwnd, 0, percent, 0x00000002);
|
||||
}
|
||||
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
|
||||
if (percent > 255)
|
||||
percent = 255;
|
||||
else if (percent < 0)
|
||||
percent = 0;
|
||||
::SetLayeredWindowAttributes(hwnd, 0, static_cast<BYTE>(percent), LWA_ALPHA);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1272,7 +1272,7 @@ public:
|
|||
bool themeNameExists(const TCHAR *themeName) {
|
||||
for (size_t i = 0; i < _themeList.size(); ++i )
|
||||
{
|
||||
auto themeNameOnList = getElementFromIndex(i).first;
|
||||
auto& themeNameOnList = getElementFromIndex(i).first;
|
||||
if (lstrcmp(themeName, themeNameOnList.c_str()) == 0)
|
||||
return true;
|
||||
}
|
||||
|
@ -1545,7 +1545,7 @@ public:
|
|||
TiXmlDocument * getCustomizedToolIcons() const {return _pXmlToolIconsDoc;};
|
||||
|
||||
bool isTransparentAvailable() const {
|
||||
return (_transparentFuncAddr != NULL);
|
||||
return (_winVersion >= WV_VISTA);
|
||||
}
|
||||
|
||||
// 0 <= percent < 256
|
||||
|
@ -1645,7 +1645,6 @@ public:
|
|||
};
|
||||
|
||||
int langTypeToCommandID(LangType lt) const;
|
||||
WNDPROC getEnableThemeDlgTexture() const {return _enableThemeDialogTextureFuncAddr;};
|
||||
|
||||
struct FindDlgTabTitiles final {
|
||||
generic_string _find;
|
||||
|
@ -1829,10 +1828,6 @@ private:
|
|||
std::vector<generic_string> _fontlist;
|
||||
std::vector<generic_string> _blacklist;
|
||||
|
||||
HMODULE _hUXTheme = nullptr;
|
||||
|
||||
WNDPROC _transparentFuncAddr = nullptr;
|
||||
WNDPROC _enableThemeDialogTextureFuncAddr = nullptr;
|
||||
bool _isLocal = false;
|
||||
bool _isx64 = false; // by default 32-bit
|
||||
bool _isCloud = false;
|
||||
|
|
Loading…
Reference in New Issue