mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-27 07:44:24 +02:00
[BUG_FIXED] (Author: Jocelyn Legault) Fix a heap corruption of ColourPicker.
git-svn-id: svn://svn.tuxfamily.org/svnroot/notepadplus/repository/trunk@681 f5eea248-9336-0410-98b8-ebc06183d4e3
This commit is contained in:
parent
7107532531
commit
c8f5903ce5
@ -348,7 +348,7 @@ void RegExtDlg::writeNppPath()
|
|||||||
TCHAR nppPath[MAX_PATH];
|
TCHAR nppPath[MAX_PATH];
|
||||||
::GetModuleFileName(_hInst, nppPath, MAX_PATH);
|
::GetModuleFileName(_hInst, nppPath, MAX_PATH);
|
||||||
|
|
||||||
TCHAR nppPathParam[256] = TEXT("\"");
|
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
|
||||||
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\""));
|
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\" \"%1\""));
|
||||||
|
|
||||||
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
|
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
|
||||||
@ -377,7 +377,7 @@ void RegExtDlg::writeNppPath()
|
|||||||
TCHAR nppPath[MAX_PATH];
|
TCHAR nppPath[MAX_PATH];
|
||||||
::GetModuleFileName(_hInst, nppPath, MAX_PATH);
|
::GetModuleFileName(_hInst, nppPath, MAX_PATH);
|
||||||
|
|
||||||
TCHAR nppPathParam[256] = TEXT("\"");
|
TCHAR nppPathParam[MAX_PATH] = TEXT("\"");
|
||||||
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0"));
|
lstrcat(lstrcat(nppPathParam, nppPath), TEXT("\",0"));
|
||||||
|
|
||||||
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
|
::RegSetValueEx(hKey, NULL, 0, REG_SZ, (LPBYTE)nppPathParam, (lstrlen(nppPathParam)+1)*sizeof(TCHAR));
|
||||||
|
@ -1232,7 +1232,7 @@ bool FindReplaceDlg::processFindNext(const TCHAR *txt2find, const FindOption *op
|
|||||||
int flags = Searching::buildSearchFlags(pOptions);
|
int flags = Searching::buildSearchFlags(pOptions);
|
||||||
|
|
||||||
(*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
(*_ppEditView)->execute(SCI_SETSEARCHFLAGS, flags);
|
||||||
//::SendMessageA(_hParent, WM_SETTEXT, 0, (LPARAM)pText);
|
|
||||||
int posFind = (*_ppEditView)->searchInTarget(pText, stringSizeFind, startPosition, endPosition);
|
int posFind = (*_ppEditView)->searchInTarget(pText, stringSizeFind, startPosition, endPosition);
|
||||||
if (posFind == -1) //no match found in target, check if a new target should be used
|
if (posFind == -1) //no match found in target, check if a new target should be used
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,16 @@ void ColourPicker::init(HINSTANCE hInst, HWND parent)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ColourPicker::destroy()
|
||||||
|
{
|
||||||
|
if (_pColourPopup)
|
||||||
|
{
|
||||||
|
delete _pColourPopup;
|
||||||
|
_pColourPopup = NULL;
|
||||||
|
}
|
||||||
|
::DestroyWindow(_hSelf);
|
||||||
|
}
|
||||||
|
|
||||||
void ColourPicker::drawBackground(HDC hDC)
|
void ColourPicker::drawBackground(HDC hDC)
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
@ -94,21 +104,25 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
case WM_LBUTTONDBLCLK :
|
case WM_LBUTTONDBLCLK :
|
||||||
case WM_LBUTTONDOWN :
|
case WM_LBUTTONDOWN :
|
||||||
{
|
{
|
||||||
|
RECT rc;
|
||||||
|
POINT p;
|
||||||
|
Window::getClientRect(rc);
|
||||||
|
::InflateRect(&rc, -2, -2);
|
||||||
|
p.x = rc.left;
|
||||||
|
p.y = rc.top + rc.bottom;
|
||||||
|
::ClientToScreen(_hSelf, &p);
|
||||||
|
|
||||||
if (!_pColourPopup)
|
if (!_pColourPopup)
|
||||||
{
|
{
|
||||||
RECT rc;
|
|
||||||
POINT p;
|
|
||||||
|
|
||||||
Window::getClientRect(rc);
|
|
||||||
::InflateRect(&rc, -2, -2);
|
|
||||||
p.x = rc.left;
|
|
||||||
p.y = rc.top + rc.bottom;
|
|
||||||
|
|
||||||
::ClientToScreen(_hSelf, &p);
|
|
||||||
_pColourPopup = new ColourPopup(_currentColour);
|
_pColourPopup = new ColourPopup(_currentColour);
|
||||||
_pColourPopup->init(_hInst, _hSelf);
|
_pColourPopup->init(_hInst, _hSelf);
|
||||||
_pColourPopup->doDialog(p);
|
_pColourPopup->doDialog(p);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_pColourPopup->doDialog(p);
|
||||||
|
_pColourPopup->display(true);
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN:
|
||||||
@ -141,9 +155,7 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
_currentColour = (COLORREF)wParam;
|
_currentColour = (COLORREF)wParam;
|
||||||
redraw();
|
redraw();
|
||||||
|
|
||||||
_pColourPopup->destroy();
|
_pColourPopup->display(false);
|
||||||
delete _pColourPopup;
|
|
||||||
_pColourPopup = NULL;
|
|
||||||
::SendMessage(_hParent, WM_COMMAND, MAKELONG(0, CPN_COLOURPICKED), (LPARAM)_hSelf);
|
::SendMessage(_hParent, WM_COMMAND, MAKELONG(0, CPN_COLOURPICKED), (LPARAM)_hSelf);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -159,18 +171,8 @@ LRESULT ColourPicker::runProc(UINT Message, WPARAM wParam, LPARAM lParam)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case WM_PICKUP_CANCEL :
|
case WM_PICKUP_CANCEL :
|
||||||
case WM_DESTROY :
|
_pColourPopup->display(false);
|
||||||
{
|
return TRUE;
|
||||||
if (_pColourPopup)
|
|
||||||
{
|
|
||||||
_pColourPopup->destroy();
|
|
||||||
delete _pColourPopup;
|
|
||||||
_pColourPopup = NULL;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default :
|
default :
|
||||||
return ::CallWindowProc(_buttonDefaultProc, _hSelf, Message, wParam, lParam);
|
return ::CallWindowProc(_buttonDefaultProc, _hSelf, Message, wParam, lParam);
|
||||||
|
@ -22,7 +22,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|||||||
|
|
||||||
class ColourPopup;
|
class ColourPopup;
|
||||||
|
|
||||||
//#define CP_CLASS_NAME "colourPickerButton"
|
|
||||||
#define CPN_COLOURPICKED (BN_CLICKED)
|
#define CPN_COLOURPICKED (BN_CLICKED)
|
||||||
|
|
||||||
class ColourPicker : public Window
|
class ColourPicker : public Window
|
||||||
@ -31,16 +30,12 @@ public :
|
|||||||
ColourPicker() : Window(), _currentColour(RGB(0xFF, 0x00, 0x00)), _pColourPopup(NULL), _isEnabled(true) {};
|
ColourPicker() : Window(), _currentColour(RGB(0xFF, 0x00, 0x00)), _pColourPopup(NULL), _isEnabled(true) {};
|
||||||
~ColourPicker(){};
|
~ColourPicker(){};
|
||||||
virtual void init(HINSTANCE hInst, HWND parent);
|
virtual void init(HINSTANCE hInst, HWND parent);
|
||||||
virtual void destroy() {
|
virtual void destroy();
|
||||||
DestroyWindow(_hSelf);
|
|
||||||
};
|
|
||||||
void setColour(COLORREF c) {
|
void setColour(COLORREF c) {
|
||||||
_currentColour = c;
|
_currentColour = c;
|
||||||
//drawSelf();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
COLORREF getColour() const {return _currentColour;};
|
COLORREF getColour() const {return _currentColour;};
|
||||||
|
|
||||||
bool isEnabled() {return _isEnabled;};
|
bool isEnabled() {return _isEnabled;};
|
||||||
void setEnabled(bool enabled) {_isEnabled = enabled;};
|
void setEnabled(bool enabled) {_isEnabled = enabled;};
|
||||||
|
|
||||||
|
@ -87,10 +87,7 @@ BOOL CALLBACK ColourPopup::run_dlgProc(UINT message, WPARAM wParam, LPARAM lPara
|
|||||||
{
|
{
|
||||||
::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_ADDSTRING, nColor, (LPARAM) "");
|
::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_ADDSTRING, nColor, (LPARAM) "");
|
||||||
::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETITEMDATA , nColor, (LPARAM) colourItems[nColor]);
|
::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETITEMDATA , nColor, (LPARAM) colourItems[nColor]);
|
||||||
//if (g_bgColor == colourItems[nColor])
|
|
||||||
//::SendDlgItemMessage(_hSelf, IDC_COLOUR_LIST, LB_SETCURSEL, nColor, 0);
|
|
||||||
}
|
}
|
||||||
//::SetCapture(_hSelf);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user