diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 451c9e2ef..11e7bf0dd 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -2434,10 +2434,9 @@ int Notepad_plus::findMachedBracePos(size_t startPos, size_t endPos, char target if (startPos == endPos) return -1; - int balance = 0; - if (startPos > endPos) // backward { + int balance = 0; for (int i = int(startPos); i >= int(endPos); --i) { char aChar = (char)_pEditView->execute(SCI_GETCHARAT, i); @@ -4985,7 +4984,6 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam NppParameters *nppParams = NppParameters::getInstance(); FileNameStringSplitter fnss(commandLine); - const TCHAR *pFn = NULL; // loading file as session file is allowed only when there is only one file if (pCmdParams->_isSessionFile && fnss.size() == 1) @@ -5008,7 +5006,7 @@ void Notepad_plus::loadCommandlineParams(const TCHAR * commandLine, CmdLineParam BufferID lastOpened = BUFFER_INVALID; for (int i = 0, len = fnss.size(); i < len ; ++i) { - pFn = fnss.getFileName(i); + const TCHAR *pFn = fnss.getFileName(i); if (!pFn) return; BufferID bufID = doOpen(pFn, recursive, readOnly); diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index 616c9d78c..4f9f86c49 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2874,10 +2874,9 @@ void NppParameters::insertScintKey(TiXmlNode *scintKeyRoot, const ScintillaKeyMa size_t size = scintKeyMap.getSize(); if (size > 1) { - TiXmlNode * keyNext; for (size_t i = 1; i < size; ++i) { - keyNext = keyRoot->InsertEndChild(TiXmlElement(TEXT("NextKey"))); + TiXmlNode *keyNext = keyRoot->InsertEndChild(TiXmlElement(TEXT("NextKey"))); key = scintKeyMap.getKeyComboByIndex(i); keyNext->ToElement()->SetAttribute(TEXT("Ctrl"), key._isCtrl?TEXT("yes"):TEXT("no")); keyNext->ToElement()->SetAttribute(TEXT("Alt"), key._isAlt?TEXT("yes"):TEXT("no")); @@ -3112,11 +3111,10 @@ void NppParameters::feedUserKeywordList(TiXmlNode *node) childNode = childNode->NextSibling(TEXT("Keywords"))) { const TCHAR * keywordsName = (childNode->ToElement())->Attribute(TEXT("name")); - TCHAR *kwl = nullptr; - TiXmlNode *valueNode = childNode->FirstChild(); if (valueNode) { + TCHAR *kwl = nullptr; if (!lstrcmp(udlVersion, TEXT("")) && !lstrcmp(keywordsName, TEXT("Delimiters"))) // support for old style (pre 2.0) { basic_string temp; @@ -4235,7 +4233,6 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) int g5 = 0; // up to 48 int g6 = 0; // up to 56 int g7 = 0; // up to 64 - const int nbMax = 64; // TODO some refactoring needed here.... { @@ -4282,10 +4279,6 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) } } - bool langArray[nbMax]; - for (int i = 0 ; i < nbMax ; ++i) - langArray[i] = false; - UCHAR mask = 1; for (int i = 0 ; i < 8 ; ++i) { @@ -4566,7 +4559,6 @@ void NppParameters::feedGUIParameters(TiXmlNode *node) if (n) { const TCHAR* val = n->Value(); - val = n->Value(); if (val) _nppGUI._definedWorkspaceExt = val; } diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp index bd6e18ec2..c1d790929 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp @@ -71,7 +71,7 @@ INT_PTR CALLBACK ColourPopup::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LP { ColourPopup *pColourPopup = reinterpret_cast(lParam); pColourPopup->_hSelf = hwnd; - ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); + ::SetWindowLongPtr(hwnd, GWLP_USERDATA, static_cast(lParam)); pColourPopup->run_dlgProc(message, wParam, lParam); return TRUE; } diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index 2810d77fa..da766a6fe 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp @@ -29,26 +29,22 @@ #include #include "StaticDialog.h" - - StaticDialog::~StaticDialog() { if (isCreated()) { // Prevent run_dlgProc from doing anything, since its virtual - ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, (LONG_PTR) NULL); + ::SetWindowLongPtr(_hSelf, GWLP_USERDATA, NULL); destroy(); } } - void StaticDialog::destroy() { - ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, (WPARAM)_hSelf); + ::SendMessage(_hParent, NPPM_MODELESSDIALOG, MODELESSDIALOGREMOVE, reinterpret_cast(_hSelf)); ::DestroyWindow(_hSelf); } - POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const { RECT rc; @@ -65,7 +61,6 @@ POINT StaticDialog::getTopPoint(HWND hwnd, bool isLeft) const return p; } - void StaticDialog::goToCenter() { RECT rc; @@ -81,7 +76,6 @@ void StaticDialog::goToCenter() ::SetWindowPos(_hSelf, HWND_TOP, x, y, _rc.right - _rc.left, _rc.bottom - _rc.top, SWP_SHOWWINDOW); } - void StaticDialog::display(bool toShow) const { if (toShow) @@ -113,7 +107,6 @@ void StaticDialog::display(bool toShow) const Window::display(toShow); } - HGLOBAL StaticDialog::makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate) { // Get Dlg Template resource @@ -151,11 +144,11 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent) { DLGTEMPLATE *pMyDlgTemplate = NULL; HGLOBAL hMyDlgTemplate = makeRTLResource(dialogID, &pMyDlgTemplate); - _hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, (LPARAM)this); + _hSelf = ::CreateDialogIndirectParam(_hInst, pMyDlgTemplate, _hParent, dlgProc, reinterpret_cast(this)); ::GlobalFree(hMyDlgTemplate); } else - _hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, dlgProc, (LPARAM)this); + _hSelf = ::CreateDialogParam(_hInst, MAKEINTRESOURCE(dialogID), _hParent, dlgProc, reinterpret_cast(this)); if (!_hSelf) { @@ -167,10 +160,9 @@ void StaticDialog::create(int dialogID, bool isRTL, bool msgDestParent) } // if the destination of message NPPM_MODELESSDIALOG is not its parent, then it's the grand-parent - ::SendMessage(msgDestParent?_hParent:(::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, (WPARAM)_hSelf); + ::SendMessage(msgDestParent ? _hParent : (::GetParent(_hParent)), NPPM_MODELESSDIALOG, MODELESSDIALOGADD, reinterpret_cast(_hSelf)); } - INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) @@ -179,7 +171,7 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L { StaticDialog *pStaticDlg = reinterpret_cast(lParam); pStaticDlg->_hSelf = hwnd; - ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); + ::SetWindowLongPtr(hwnd, GWLP_USERDATA, static_cast(lParam)); ::GetWindowRect(hwnd, &(pStaticDlg->_rc)); pStaticDlg->run_dlgProc(message, wParam, lParam); diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h index 90982c9f9..7e912f0b3 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.h @@ -28,12 +28,10 @@ #include "Notepad_plus_msgs.h" #include "Window.h" - typedef HRESULT (WINAPI * ETDTProc) (HWND, DWORD); enum class PosAlign { left, right, top, bottom }; - struct DLGTEMPLATEEX { WORD dlgVer; @@ -49,8 +47,6 @@ struct DLGTEMPLATEEX // The structure has more fields but are variable length }; - - class StaticDialog : public Window { public : @@ -58,8 +54,7 @@ public : virtual void create(int dialogID, bool isRTL = false, bool msgDestParent = true); - virtual bool isCreated() const - { + virtual bool isCreated() const { return (_hSelf != NULL); } @@ -76,7 +71,6 @@ public : virtual void destroy() override; - protected: RECT _rc; static INT_PTR CALLBACK dlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); @@ -84,4 +78,4 @@ protected: void alignWith(HWND handle, HWND handle2Align, PosAlign pos, POINT & point); HGLOBAL makeRTLResource(int dialogID, DLGTEMPLATE **ppMyDlgTemplate); -}; \ No newline at end of file +}; diff --git a/PowerEditor/src/lesDlgs.h b/PowerEditor/src/lesDlgs.h index ec589cbc7..08415207e 100644 --- a/PowerEditor/src/lesDlgs.h +++ b/PowerEditor/src/lesDlgs.h @@ -36,7 +36,7 @@ const int DEFAULT_NB_NUMBER = 2; class ValueDlg : public StaticDialog { public : - ValueDlg() : StaticDialog(), _nbNumber(DEFAULT_NB_NUMBER) {}; + ValueDlg() : StaticDialog() {}; void init(HINSTANCE hInst, HWND parent, int valueToSet, const TCHAR *text); int doDialog(POINT p, bool isRTL = false); void setNBNumber(int nbNumber) { @@ -50,8 +50,8 @@ protected : INT_PTR CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM); private : - int _nbNumber; - int _defaultValue; + int _nbNumber = DEFAULT_NB_NUMBER; + int _defaultValue = 0; generic_string _name; POINT _p; };