Code enhancement: Replace undocumented functions

Fix #12721, close #12722
pull/12733/head
ozone10 2 years ago committed by Don Ho
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) #define NPPM_MAKECURRENTBUFFERDIRTY (NPPMSG + 44)
//BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0) //BOOL NPPM_MAKECURRENTBUFFERDIRTY(0, 0)
#define NPPM_GETENABLETHEMETEXTUREFUNC (NPPMSG + 45) #define NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED (NPPMSG + 45)
//BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) //BOOL NPPM_GETENABLETHEMETEXTUREFUNC(0, 0) -- DEPRECATED : use EnableThemeDialogTexture from uxtheme.h instead
#define NPPM_GETPLUGINSCONFIGDIR (NPPMSG + 46) #define NPPM_GETPLUGINSCONFIGDIR (NPPMSG + 46)
//INT NPPM_GETPLUGINSCONFIGDIR(int strLen, TCHAR *str) //INT NPPM_GETPLUGINSCONFIGDIR(int strLen, TCHAR *str)

@ -17,6 +17,7 @@
#include <algorithm> #include <algorithm>
#include <shlwapi.h> #include <shlwapi.h>
#include <uxtheme.h> // for EnableThemeDialogTexture
#include "Notepad_plus_Window.h" #include "Notepad_plus_Window.h"
#include "TaskListDlg.h" #include "TaskListDlg.h"
#include "ImageListSet.h" #include "ImageListSet.h"
@ -2658,9 +2659,9 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return TRUE; return TRUE;
} }
case NPPM_GETENABLETHEMETEXTUREFUNC: case NPPM_GETENABLETHEMETEXTUREFUNC_DEPRECATED:
{ {
return (LRESULT)nppParam.getEnableThemeDlgTexture(); return reinterpret_cast<LRESULT>(&EnableThemeDialogTexture);
} }
case NPPM_GETPLUGINSCONFIGDIR: case NPPM_GETPLUGINSCONFIGDIR:

@ -991,8 +991,6 @@ NppParameters::~NppParameters()
delete _LRFileList[i]; delete _LRFileList[i];
for (int i = 0 ; i < _nbUserLang ; ++i) for (int i = 0 ; i < _nbUserLang ; ++i)
delete _userLangArray[i]; delete _userLangArray[i];
if (_hUXTheme)
FreeLibrary(_hUXTheme);
for (std::vector<TiXmlDocument *>::iterator it = _pXmlExternalLexerDoc.begin(), end = _pXmlExternalLexerDoc.end(); it != end; ++it ) for (std::vector<TiXmlDocument *>::iterator it = _pXmlExternalLexerDoc.begin(), end = _pXmlExternalLexerDoc.end(); it != end; ++it )
delete (*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 // // langs.xml : for per user //
//--------------------------// //--------------------------//
@ -1619,7 +1603,7 @@ void NppParameters::destroyInstance()
delete _pXmlUserStylerDoc; delete _pXmlUserStylerDoc;
//delete _pXmlUserLangDoc; will be deleted in the vector //delete _pXmlUserLangDoc; will be deleted in the vector
for (auto l : _pXmlUserLangsDoc) for (auto& l : _pXmlUserLangsDoc)
{ {
delete l._udlXmlDoc; delete l._udlXmlDoc;
} }
@ -1651,22 +1635,19 @@ void NppParameters::setWorkSpaceFilePath(int i, const TCHAR* wsFile)
void NppParameters::removeTransparent(HWND hwnd) void NppParameters::removeTransparent(HWND hwnd)
{ {
if (hwnd != NULL) if (hwnd != nullptr)
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) & ~0x00080000); ::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) & ~WS_EX_LAYERED);
} }
void NppParameters::SetTransparent(HWND hwnd, int percent) void NppParameters::SetTransparent(HWND hwnd, int percent)
{ {
if (nullptr != _transparentFuncAddr) ::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
{
::SetWindowLongPtr(hwnd, GWL_EXSTYLE, ::GetWindowLongPtr(hwnd, GWL_EXSTYLE) | 0x00080000);
if (percent > 255) if (percent > 255)
percent = 255; percent = 255;
if (percent < 0) else if (percent < 0)
percent = 0; percent = 0;
_transparentFuncAddr(hwnd, 0, percent, 0x00000002); ::SetLayeredWindowAttributes(hwnd, 0, static_cast<BYTE>(percent), LWA_ALPHA);
}
} }

@ -1272,7 +1272,7 @@ public:
bool themeNameExists(const TCHAR *themeName) { bool themeNameExists(const TCHAR *themeName) {
for (size_t i = 0; i < _themeList.size(); ++i ) 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) if (lstrcmp(themeName, themeNameOnList.c_str()) == 0)
return true; return true;
} }
@ -1545,7 +1545,7 @@ public:
TiXmlDocument * getCustomizedToolIcons() const {return _pXmlToolIconsDoc;}; TiXmlDocument * getCustomizedToolIcons() const {return _pXmlToolIconsDoc;};
bool isTransparentAvailable() const { bool isTransparentAvailable() const {
return (_transparentFuncAddr != NULL); return (_winVersion >= WV_VISTA);
} }
// 0 <= percent < 256 // 0 <= percent < 256
@ -1645,7 +1645,6 @@ public:
}; };
int langTypeToCommandID(LangType lt) const; int langTypeToCommandID(LangType lt) const;
WNDPROC getEnableThemeDlgTexture() const {return _enableThemeDialogTextureFuncAddr;};
struct FindDlgTabTitiles final { struct FindDlgTabTitiles final {
generic_string _find; generic_string _find;
@ -1829,10 +1828,6 @@ private:
std::vector<generic_string> _fontlist; std::vector<generic_string> _fontlist;
std::vector<generic_string> _blacklist; std::vector<generic_string> _blacklist;
HMODULE _hUXTheme = nullptr;
WNDPROC _transparentFuncAddr = nullptr;
WNDPROC _enableThemeDialogTextureFuncAddr = nullptr;
bool _isLocal = false; bool _isLocal = false;
bool _isx64 = false; // by default 32-bit bool _isx64 = false; // by default 32-bit
bool _isCloud = false; bool _isCloud = false;

Loading…
Cancel
Save