mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-21 12:54:42 +02:00
Fix wrong plugin toolbar icon display if the ICO format is absent
An empty icon will be displayed after this fix.
This commit is contained in:
parent
f7a04caca7
commit
46b3e3c7b2
@ -90,6 +90,8 @@ void Notepad_plus_Window::init(HINSTANCE hInst, HWND parent, const TCHAR *cmdLin
|
|||||||
|
|
||||||
nppGUI._isCmdlineNosessionActivated = cmdLineParams->_isNoSession;
|
nppGUI._isCmdlineNosessionActivated = cmdLineParams->_isNoSession;
|
||||||
|
|
||||||
|
_hIconAbsent = ::LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICONABSENT));
|
||||||
|
|
||||||
_hSelf = ::CreateWindowEx(
|
_hSelf = ::CreateWindowEx(
|
||||||
WS_EX_ACCEPTFILES | (_notepad_plus_plus_core._nativeLangSpeaker.isRTL()?WS_EX_LAYOUTRTL:0),
|
WS_EX_ACCEPTFILES | (_notepad_plus_plus_core._nativeLangSpeaker.isRTL()?WS_EX_LAYOUTRTL:0),
|
||||||
_className,
|
_className,
|
||||||
|
@ -16,8 +16,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Notepad_plus.h"
|
#include "Notepad_plus.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
|
const TCHAR COMMAND_ARG_HELP[] = TEXT("Usage :\r\
|
||||||
\r\
|
\r\
|
||||||
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-pPosition] [-xLeftPos] [-yTopPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [-alwaysOnTop] [-openSession] [-r] [-qn=\"Easter egg name\" | -qt=\"a text to display.\" | -qf=\"D:\\my quote.txt\"] [-qSpeed1|2|3] [-quickPrint] [-settingsDir=\"d:\\your settings dir\\\"] [-openFoldersAsWorkspace] [-titleAdd=\"additional title bar text\"][filePath]\r\
|
notepad++ [--help] [-multiInst] [-noPlugin] [-lLanguage] [-LlangCode] [-nLineNumber] [-cColumnNumber] [-pPosition] [-xLeftPos] [-yTopPos] [-nosession] [-notabbar] [-ro] [-systemtray] [-loadingTime] [-alwaysOnTop] [-openSession] [-r] [-qn=\"Easter egg name\" | -qt=\"a text to display.\" | -qf=\"D:\\my quote.txt\"] [-qSpeed1|2|3] [-quickPrint] [-settingsDir=\"d:\\your settings dir\\\"] [-openFoldersAsWorkspace] [-titleAdd=\"additional title bar text\"][filePath]\r\
|
||||||
@ -53,9 +51,6 @@ filePath : file or folder name to open (absolute or relative path name)\r\
|
|||||||
");
|
");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Notepad_plus_Window : public Window
|
class Notepad_plus_Window : public Window
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -63,40 +58,39 @@ public:
|
|||||||
|
|
||||||
bool isDlgsMsg(MSG *msg) const;
|
bool isDlgsMsg(MSG *msg) const;
|
||||||
|
|
||||||
HACCEL getAccTable() const
|
HACCEL getAccTable() const {
|
||||||
{
|
|
||||||
return _notepad_plus_plus_core.getAccTable();
|
return _notepad_plus_plus_core.getAccTable();
|
||||||
}
|
};
|
||||||
|
|
||||||
bool emergency(const generic_string& emergencySavedDir)
|
bool emergency(const generic_string& emergencySavedDir) {
|
||||||
{
|
|
||||||
return _notepad_plus_plus_core.emergency(emergencySavedDir);
|
return _notepad_plus_plus_core.emergency(emergencySavedDir);
|
||||||
}
|
};
|
||||||
|
|
||||||
bool isPrelaunch() const
|
bool isPrelaunch() const {
|
||||||
{
|
|
||||||
return _isPrelaunch;
|
return _isPrelaunch;
|
||||||
}
|
};
|
||||||
|
|
||||||
void setIsPrelaunch(bool val)
|
void setIsPrelaunch(bool val) {
|
||||||
{
|
|
||||||
_isPrelaunch = val;
|
_isPrelaunch = val;
|
||||||
}
|
};
|
||||||
|
|
||||||
generic_string getPluginListVerStr() const
|
generic_string getPluginListVerStr() const {
|
||||||
{
|
|
||||||
return _notepad_plus_plus_core.getPluginListVerStr();
|
return _notepad_plus_plus_core.getPluginListVerStr();
|
||||||
}
|
};
|
||||||
|
|
||||||
virtual void destroy()
|
virtual void destroy() {
|
||||||
{
|
if (_hIconAbsent)
|
||||||
|
::DestroyIcon(_hIconAbsent);
|
||||||
::DestroyWindow(_hSelf);
|
::DestroyWindow(_hSelf);
|
||||||
}
|
};
|
||||||
|
|
||||||
static const TCHAR * getClassName()
|
static const TCHAR * getClassName() {
|
||||||
{
|
|
||||||
return _className;
|
return _className;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
HICON getAbsentIcoHandle() {
|
||||||
|
return _hIconAbsent;
|
||||||
|
};
|
||||||
|
|
||||||
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
|
static HWND gNppHWND; //static handle to Notepad++ window, NULL if non-existant
|
||||||
|
|
||||||
@ -112,4 +106,6 @@ private:
|
|||||||
|
|
||||||
QuoteParams _quoteParams; // keep the availability of quote parameters for thread using
|
QuoteParams _quoteParams; // keep the availability of quote parameters for thread using
|
||||||
std::wstring _userQuote; // keep the availability of this string for thread using
|
std::wstring _userQuote; // keep the availability of this string for thread using
|
||||||
|
|
||||||
|
HICON _hIconAbsent = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -2157,7 +2157,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
|||||||
|
|
||||||
case NPPM_ADDTOOLBARICON:
|
case NPPM_ADDTOOLBARICON:
|
||||||
{
|
{
|
||||||
_toolBar.registerDynBtn(static_cast<UINT>(wParam), reinterpret_cast<toolbarIcons*>(lParam));
|
_toolBar.registerDynBtn(static_cast<UINT>(wParam), reinterpret_cast<toolbarIcons*>(lParam), _pPublicInterface->getAbsentIcoHandle());
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,11 +551,11 @@ void Gripper::drawRectangle(const POINT* pPt)
|
|||||||
// finally ::LockWindowUpdate(NULL) will be called, to enable drawing for others again.
|
// finally ::LockWindowUpdate(NULL) will be called, to enable drawing for others again.
|
||||||
if (!_hdc)
|
if (!_hdc)
|
||||||
{
|
{
|
||||||
HWND hWnd= ::GetDesktopWindow();
|
HWND hWnd = ::GetDesktopWindow();
|
||||||
#if defined (USE_LOCKWINDOWUPDATE)
|
#if defined (USE_LOCKWINDOWUPDATE)
|
||||||
_hdc= ::GetDCEx(hWnd, NULL, ::LockWindowUpdate(hWnd) ? DCX_WINDOW|DCX_CACHE|DCX_LOCKWINDOWUPDATE : DCX_WINDOW|DCX_CACHE);
|
_hdc = ::GetDCEx(hWnd, NULL, ::LockWindowUpdate(hWnd) ? DCX_WINDOW|DCX_CACHE|DCX_LOCKWINDOWUPDATE : DCX_WINDOW|DCX_CACHE);
|
||||||
#else
|
#else
|
||||||
_hdc= ::GetDCEx(hWnd, NULL, DCX_WINDOW|DCX_CACHE);
|
_hdc = ::GetDCEx(hWnd, NULL, DCX_WINDOW|DCX_CACHE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -598,25 +598,25 @@ void Gripper::drawRectangle(const POINT* pPt)
|
|||||||
rc.right -= rc.left;
|
rc.right -= rc.left;
|
||||||
rc.bottom-= rc.top;
|
rc.bottom-= rc.top;
|
||||||
}
|
}
|
||||||
else rc= rcNew; // only new rect will be drawn
|
else rc = rcNew; // only new rect will be drawn
|
||||||
}
|
}
|
||||||
else rc= rcOld; // only old rect will be drawn - to erase it
|
else rc = rcOld; // only old rect will be drawn - to erase it
|
||||||
|
|
||||||
// now rc contains the rectangle wich encloses all needed, new and/or previous rectangle
|
// now rc contains the rectangle wich encloses all needed, new and/or previous rectangle
|
||||||
// because in the following we drive within a memory device context wich is limited to rc,
|
// because in the following we drive within a memory device context wich is limited to rc,
|
||||||
// we have to localize rcNew and rcOld within rc...
|
// we have to localize rcNew and rcOld within rc...
|
||||||
//
|
//
|
||||||
rcOld.left= rcOld.left - rc.left;
|
rcOld.left = rcOld.left - rc.left;
|
||||||
rcOld.top = rcOld.top - rc.top;
|
rcOld.top = rcOld.top - rc.top;
|
||||||
rcNew.left= rcNew.left - rc.left;
|
rcNew.left = rcNew.left - rc.left;
|
||||||
rcNew.top = rcNew.top - rc.top;
|
rcNew.top = rcNew.top - rc.top;
|
||||||
|
|
||||||
HDC hdcMem= ::CreateCompatibleDC(_hdc);
|
HDC hdcMem = ::CreateCompatibleDC(_hdc);
|
||||||
HBITMAP hBm= ::CreateCompatibleBitmap(_hdc, rc.right, rc.bottom);
|
HBITMAP hBm = ::CreateCompatibleBitmap(_hdc, rc.right, rc.bottom);
|
||||||
hbrushOrig= (HBRUSH)::SelectObject(hdcMem, hBm);
|
hbrushOrig = (HBRUSH)::SelectObject(hdcMem, hBm);
|
||||||
|
|
||||||
::SetBrushOrgEx(hdcMem, rc.left%8, rc.top%8, 0);
|
::SetBrushOrgEx(hdcMem, rc.left%8, rc.top%8, 0);
|
||||||
hbmOrig= (HBITMAP)::SelectObject(hdcMem, _hbrush);
|
hbmOrig = (HBITMAP)::SelectObject(hdcMem, _hbrush);
|
||||||
|
|
||||||
::BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, _hdc, rc.left, rc.top, SRCCOPY);
|
::BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, _hdc, rc.left, rc.top, SRCCOPY);
|
||||||
if (_bPtOldValid)
|
if (_bPtOldValid)
|
||||||
@ -641,14 +641,15 @@ void Gripper::drawRectangle(const POINT* pPt)
|
|||||||
#if defined(USE_LOCKWINDOWUPDATE)
|
#if defined(USE_LOCKWINDOWUPDATE)
|
||||||
::LockWindowUpdate(NULL);
|
::LockWindowUpdate(NULL);
|
||||||
#endif
|
#endif
|
||||||
_bPtOldValid= FALSE;
|
_bPtOldValid = FALSE;
|
||||||
if (_hdc)
|
if (_hdc)
|
||||||
{
|
{
|
||||||
::ReleaseDC(0, _hdc);
|
::ReleaseDC(0, _hdc);
|
||||||
_hdc= NULL;
|
_hdc = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else _bPtOldValid= TRUE;
|
else
|
||||||
|
_bPtOldValid = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,16 +25,6 @@
|
|||||||
|
|
||||||
const int WS_TOOLBARSTYLE = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER;
|
const int WS_TOOLBARSTYLE = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | TBSTYLE_TOOLTIPS |TBSTYLE_FLAT | CCS_TOP | BTNS_AUTOSIZE | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_NODIVIDER;
|
||||||
|
|
||||||
ToolBar::ToolBar()
|
|
||||||
{
|
|
||||||
_hIconAbsent = (HICON)::LoadImage(_hInst, MAKEINTRESOURCE(IDI_ICONABSENT), IMAGE_ICON, 16, 16, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
ToolBar::~ToolBar()
|
|
||||||
{
|
|
||||||
::DestroyIcon(_hIconAbsent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
|
void ToolBar::initTheme(TiXmlDocument *toolIconsDocRoot)
|
||||||
{
|
{
|
||||||
_toolIcons = toolIconsDocRoot->FirstChild(TEXT("NotepadPlus"));
|
_toolIcons = toolIconsDocRoot->FirstChild(TEXT("NotepadPlus"));
|
||||||
@ -382,7 +372,7 @@ void ToolBar::reset(bool create)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* tIcon)
|
void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* tIcon, HICON absentIco)
|
||||||
{
|
{
|
||||||
// Note: Register of buttons only possible before init!
|
// Note: Register of buttons only possible before init!
|
||||||
if ((_hSelf == NULL) && (messageID != 0) && (tIcon->hToolbarBmp != NULL))
|
if ((_hSelf == NULL) && (messageID != 0) && (tIcon->hToolbarBmp != NULL))
|
||||||
@ -390,7 +380,7 @@ void ToolBar::registerDynBtn(UINT messageID, toolbarIcons* tIcon)
|
|||||||
DynamicCmdIcoBmp dynList;
|
DynamicCmdIcoBmp dynList;
|
||||||
dynList._message = messageID;
|
dynList._message = messageID;
|
||||||
dynList._hBmp = tIcon->hToolbarBmp;
|
dynList._hBmp = tIcon->hToolbarBmp;
|
||||||
dynList._hIcon = tIcon->hToolbarIcon ? tIcon->hToolbarIcon : _hIconAbsent;
|
dynList._hIcon = tIcon->hToolbarIcon ? tIcon->hToolbarIcon : absentIco;
|
||||||
_vDynBtnReg.push_back(dynList);
|
_vDynBtnReg.push_back(dynList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ class TiXmlNode;
|
|||||||
class ToolBar : public Window
|
class ToolBar : public Window
|
||||||
{
|
{
|
||||||
public :
|
public :
|
||||||
ToolBar();
|
ToolBar() = default;
|
||||||
~ToolBar();
|
~ToolBar() = default;
|
||||||
|
|
||||||
void initTheme(TiXmlDocument *toolIconsDocRoot);
|
void initTheme(TiXmlDocument *toolIconsDocRoot);
|
||||||
virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
virtual bool init(HINSTANCE hInst, HWND hPere, toolBarStatusType type,
|
||||||
@ -94,7 +94,7 @@ public :
|
|||||||
return _toolBarIcons.replaceIcon(whichLst, iconIndex, iconLocation);
|
return _toolBarIcons.replaceIcon(whichLst, iconIndex, iconLocation);
|
||||||
};
|
};
|
||||||
|
|
||||||
void registerDynBtn(UINT message, toolbarIcons* hBmp);
|
void registerDynBtn(UINT message, toolbarIcons* hBmp, HICON absentIco);
|
||||||
|
|
||||||
void doPopop(POINT chevPoint); //show the popup if buttons are hidden
|
void doPopop(POINT chevPoint); //show the popup if buttons are hidden
|
||||||
|
|
||||||
@ -113,7 +113,6 @@ private :
|
|||||||
REBARBANDINFO _rbBand;
|
REBARBANDINFO _rbBand;
|
||||||
std::vector<iconLocator> _customIconVect;
|
std::vector<iconLocator> _customIconVect;
|
||||||
TiXmlNode *_toolIcons = nullptr;
|
TiXmlNode *_toolIcons = nullptr;
|
||||||
HICON _hIconAbsent = nullptr;
|
|
||||||
|
|
||||||
void setDefaultImageList() {
|
void setDefaultImageList() {
|
||||||
::SendMessage(_hSelf, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_toolBarIcons.getDefaultLst()));
|
::SendMessage(_hSelf, TB_SETIMAGELIST, 0, reinterpret_cast<LPARAM>(_toolBarIcons.getDefaultLst()));
|
||||||
|
@ -33,13 +33,13 @@
|
|||||||
#define IDC_STATIC -1
|
#define IDC_STATIC -1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define IDI_M30ICON 100
|
#define IDI_M30ICON 100
|
||||||
#define IDI_CHAMELEON 101
|
#define IDI_CHAMELEON 101
|
||||||
//#define IDI_JESUISCHARLIE 102
|
//#define IDI_JESUISCHARLIE 102
|
||||||
//#define IDI_GILETJAUNE 102
|
//#define IDI_GILETJAUNE 102
|
||||||
//#define IDI_SAMESEXMARRIAGE 102
|
//#define IDI_SAMESEXMARRIAGE 102
|
||||||
#define IDR_RT_MANIFEST 103
|
#define IDR_RT_MANIFEST 103
|
||||||
#define IDI_ICONABSENT 104
|
#define IDI_ICONABSENT 104
|
||||||
|
|
||||||
//
|
//
|
||||||
// TOOLBAR ICO - set 1
|
// TOOLBAR ICO - set 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user