From 1e38c628bcf8da1c9bd9e3c135a0ce8903aeecd2 Mon Sep 17 00:00:00 2001 From: Don HO Date: Sun, 10 Jul 2016 02:21:15 +0200 Subject: [PATCH] Use C++ type conversion instead of C-Style conversion --- .../Process/ProcessAvecThread/Process.cpp | 13 +++++----- .../MISC/Process/ProcessAvecThread/Process.h | 4 ++-- PowerEditor/src/Notepad_plus.cpp | 24 ++++++++++--------- PowerEditor/src/NppBigSwitch.cpp | 4 ++-- PowerEditor/src/NppIO.cpp | 2 +- PowerEditor/src/Parameters.cpp | 9 +++---- PowerEditor/src/Parameters.h | 4 ++-- PowerEditor/src/ScitillaComponent/Buffer.cpp | 6 ++--- PowerEditor/src/ScitillaComponent/Buffer.h | 2 +- .../src/ScitillaComponent/DocTabView.cpp | 8 +++---- PowerEditor/src/ScitillaComponent/Printer.cpp | 11 ++++----- .../WinControls/ColourPicker/ColourPopup.cpp | 2 +- .../WinControls/ColourPicker/WordStyleDlg.cpp | 7 +++--- .../WinControls/DockingWnd/DockingManager.cpp | 13 +++++----- .../FunctionList/functionParser.cpp | 2 +- .../WinControls/Preference/preferenceDlg.cpp | 8 +++---- .../WinControls/ProjectPanel/ProjectPanel.h | 13 +++++----- .../ReadDirectoryChangesPrivate.cpp | 2 +- .../ReadDirectoryChangesPrivate.h | 6 ++--- .../WinControls/StaticDialog/StaticDialog.cpp | 2 +- .../VerticalFileSwitcherListView.cpp | 4 ++-- .../src/WinControls/WindowsDlg/WindowsDlg.cpp | 15 ++++++------ .../src/WinControls/shortcut/shortcut.cpp | 5 ++-- PowerEditor/src/lastRecentFileList.h | 2 +- 24 files changed, 82 insertions(+), 86 deletions(-) diff --git a/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.cpp b/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.cpp index fdd0df67..26086a37 100644 --- a/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.cpp +++ b/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.cpp @@ -151,11 +151,11 @@ void Process::listenerStdOut() while (goOn) { // got data memset(bufferOut,0x00,MAX_LINE_LENGTH + 1); - int taille = sizeof(bufferOut) - sizeof(TCHAR); + int size = sizeof(bufferOut) - sizeof(TCHAR); Sleep(50); - if (!::PeekNamedPipe(_hPipeOutR, bufferOut, taille, &outbytesRead, &bytesAvail, NULL)) + if (!::PeekNamedPipe(_hPipeOutR, bufferOut, size, &outbytesRead, &bytesAvail, NULL)) { bytesAvail = 0; goOn = false; @@ -164,7 +164,7 @@ void Process::listenerStdOut() if (outbytesRead) { - result = :: ReadFile(_hPipeOutR, bufferOut, taille, &outbytesRead, NULL); + result = :: ReadFile(_hPipeOutR, bufferOut, size, &outbytesRead, NULL); if ((!result) && (outbytesRead == 0)) { goOn = false; @@ -202,7 +202,6 @@ void Process::listenerStdErr() BOOL result = 0; HANDLE hListenerEvent = ::OpenEvent(EVENT_ALL_ACCESS, FALSE, TEXT("listenerStdErrEvent")); - int taille = 0; TCHAR bufferErr[MAX_LINE_LENGTH + 1]; int nExitCode = STILL_ACTIVE; @@ -212,11 +211,11 @@ void Process::listenerStdErr() while (goOn) { // got data memset(bufferErr, 0x00, MAX_LINE_LENGTH + 1); - taille = sizeof(bufferErr) - sizeof(TCHAR); + size_t size = sizeof(bufferErr) - sizeof(TCHAR); Sleep(50); DWORD errbytesRead; - if (!::PeekNamedPipe(_hPipeErrR, bufferErr, taille, &errbytesRead, &bytesAvail, NULL)) + if (!::PeekNamedPipe(_hPipeErrR, bufferErr, size, &errbytesRead, &bytesAvail, NULL)) { bytesAvail = 0; goOn = false; @@ -225,7 +224,7 @@ void Process::listenerStdErr() if (errbytesRead) { - result = :: ReadFile(_hPipeErrR, bufferErr, taille, &errbytesRead, NULL); + result = :: ReadFile(_hPipeErrR, bufferErr, size, &errbytesRead, NULL); if ((!result) && (errbytesRead == 0)) { goOn = false; diff --git a/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.h b/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.h index 20c7d3ab..2d163780 100644 --- a/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.h +++ b/PowerEditor/src/MISC/Process/ProcessAvecThread/Process.h @@ -86,11 +86,11 @@ protected: //UINT _pid; // process ID assigned by caller static DWORD WINAPI staticListenerStdOut(void * myself){ - ((Process *)myself)->listenerStdOut(); + static_cast(myself)->listenerStdOut(); return 0; }; static DWORD WINAPI staticListenerStdErr(void * myself) { - ((Process *)myself)->listenerStdErr(); + static_cast(myself)->listenerStdErr(); return 0; }; void listenerStdOut(); diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index d21ffd12..451c9e2e 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -5964,10 +5964,11 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params) // random seed generation needs only one time. srand((unsigned int)time(NULL)); - HWND hNpp = ((TextPlayerParams *)params)->_nppHandle; - ScintillaEditView *pCurrentView = ((TextPlayerParams *)params)->_pCurrentView; - const char *text2display = ((TextPlayerParams *)params)->_text2display; - bool shouldBeTrolling = ((TextPlayerParams *)params)->_shouldBeTrolling; + TextPlayerParams* textPlayerParams = static_cast(params); + HWND hNpp = textPlayerParams->_nppHandle; + ScintillaEditView *pCurrentView = textPlayerParams->_pCurrentView; + const char *text2display = textPlayerParams->_text2display; + bool shouldBeTrolling = textPlayerParams->_shouldBeTrolling; // Open a new document ::SendMessage(hNpp, NPPM_MENUCOMMAND, 0, IDM_FILE_NEW); @@ -6042,7 +6043,7 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params) } //writeLog(TEXT("c:\\tmp\\log.txt"), "\n\n\n\n"); - const char * quoter = ((TextPlayerParams *)params)->_quoter; + const char * quoter = textPlayerParams->_quoter; string quoter_str = quoter; size_t pos = quoter_str.find("Anonymous"); if (pos == string::npos) @@ -6075,15 +6076,16 @@ DWORD WINAPI Notepad_plus::threadTextPlayer(void *params) DWORD WINAPI Notepad_plus::threadTextTroller(void *params) { - WaitForSingleObject(((TextTrollerParams *)params)->_mutex, INFINITE); + TextTrollerParams *textTrollerParams = static_cast(params); + WaitForSingleObject(textTrollerParams->_mutex, INFINITE); // random seed generation needs only one time. srand((unsigned int)time(NULL)); - ScintillaEditView *pCurrentView = ((TextTrollerParams *)params)->_pCurrentView; - const char *text2display = ((TextTrollerParams *)params)->_text2display; + ScintillaEditView *pCurrentView = textTrollerParams->_pCurrentView; + const char *text2display = textTrollerParams->_text2display; HWND curScintilla = pCurrentView->getHSelf(); - BufferID targetBufID = ((TextTrollerParams *)params)->_targetBufID; + BufferID targetBufID = textTrollerParams->_targetBufID; for (size_t i = 0, len = strlen(text2display); i < len; ++i) { @@ -6097,7 +6099,7 @@ DWORD WINAPI Notepad_plus::threadTextTroller(void *params) BufferID currentBufID = pCurrentView->getCurrentBufferID(); if (currentBufID != targetBufID) { - ReleaseMutex(((TextTrollerParams *)params)->_mutex); + ReleaseMutex(textTrollerParams->_mutex); return TRUE; } ::SendMessage(curScintilla, SCI_APPENDTEXT, 1, (LPARAM)charToShow); @@ -6148,7 +6150,7 @@ DWORD WINAPI Notepad_plus::threadTextTroller(void *params) ::SendMessage(pCurrentView->getHSelf(), SCI_DELETEBACK, 0, 0); } - ReleaseMutex(((TextTrollerParams *)params)->_mutex); + ReleaseMutex(textTrollerParams->_mutex); return TRUE; } diff --git a/PowerEditor/src/NppBigSwitch.cpp b/PowerEditor/src/NppBigSwitch.cpp index d999c814..3ea53a62 100644 --- a/PowerEditor/src/NppBigSwitch.cpp +++ b/PowerEditor/src/NppBigSwitch.cpp @@ -529,7 +529,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa { case COPYDATA_PARAMS: { - CmdLineParams *cmdLineParam = (CmdLineParams *)pCopyData->lpData; // CmdLineParams object from another instance + CmdLineParams *cmdLineParam = reinterpret_cast(pCopyData->lpData); // CmdLineParams object from another instance auto cmdLineParamsSize = static_cast(pCopyData->cbData); // CmdLineParams size from another instance if (sizeof(CmdLineParams) == cmdLineParamsSize) // make sure the structure is the same { @@ -810,7 +810,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lPa if (!wParam) return 0; - TaskListInfo * tli = (TaskListInfo *)wParam; + TaskListInfo * tli = reinterpret_cast(wParam); getTaskListInfo(tli); if (lParam != 0) diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index 957a1400..9fdc1e3f 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -41,7 +41,7 @@ using namespace std; DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params) { - MonitorInfo *monitorInfo = (MonitorInfo *)params; + MonitorInfo *monitorInfo = static_cast(params); Buffer *buf = monitorInfo->_buffer; HWND h = monitorInfo->_nppHandle; diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index db86b61b..616c9d78 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -3105,16 +3105,14 @@ void NppParameters::feedUserSettings(TiXmlNode *settingsRoot) void NppParameters::feedUserKeywordList(TiXmlNode *node) { const TCHAR * udlVersion = _userLangArray[_nbUserLang - 1]->_udlVersion.c_str(); - const TCHAR * keywordsName = nullptr; - TCHAR *kwl = nullptr; int id = -1; for (TiXmlNode *childNode = node->FirstChildElement(TEXT("Keywords")); childNode ; childNode = childNode->NextSibling(TEXT("Keywords"))) { - keywordsName = (childNode->ToElement())->Attribute(TEXT("name")); - kwl = nullptr; + const TCHAR * keywordsName = (childNode->ToElement())->Attribute(TEXT("name")); + TCHAR *kwl = nullptr; TiXmlNode *valueNode = childNode->FirstChild(); if (valueNode) @@ -3183,14 +3181,13 @@ void NppParameters::feedUserKeywordList(TiXmlNode *node) void NppParameters::feedUserStyles(TiXmlNode *node) { - const TCHAR *styleName = NULL; int id = -1; for (TiXmlNode *childNode = node->FirstChildElement(TEXT("WordsStyle")); childNode ; childNode = childNode->NextSibling(TEXT("WordsStyle"))) { - styleName = (childNode->ToElement())->Attribute(TEXT("name")); + const TCHAR *styleName = (childNode->ToElement())->Attribute(TEXT("name")); if (styleName) { if (globalMappper().styleIdMapper.find(styleName) != globalMappper().styleIdMapper.end()) diff --git a/PowerEditor/src/Parameters.h b/PowerEditor/src/Parameters.h index ee892bde..fad3bdb7 100644 --- a/PowerEditor/src/Parameters.h +++ b/PowerEditor/src/Parameters.h @@ -185,7 +185,7 @@ struct sessionFileInfo : public Position int _encoding = -1; generic_string _backupFilePath; - time_t _originalFileLastModifTimestamp; + time_t _originalFileLastModifTimestamp = 0; }; @@ -490,7 +490,7 @@ public: { if (this != &ls) { - *((StyleArray *)this) = ls; + *(static_cast(this)) = ls; this->_lexerName = ls._lexerName; this->_lexerDesc = ls._lexerDesc; this->_lexerUserExt = ls._lexerUserExt; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.cpp b/PowerEditor/src/ScitillaComponent/Buffer.cpp index 5f96ec01..7cc14592 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScitillaComponent/Buffer.cpp @@ -612,7 +612,7 @@ BufferID FileManager::loadFile(const TCHAR * filename, Document doc, int encodin if (res) { Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_REGULAR, fullpath); - BufferID id = (BufferID) newBuf; + BufferID id = static_cast(newBuf); newBuf->_id = id; if (backupFileName != NULL) @@ -1222,7 +1222,7 @@ BufferID FileManager::newEmptyDocument() Document doc = (Document)_pscratchTilla->execute(SCI_CREATEDOCUMENT); //this already sets a reference for filemanager Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str()); - BufferID id = (BufferID)newBuf; + BufferID id = static_cast(newBuf); newBuf->_id = id; _buffers.push_back(newBuf); ++_nrBufs; @@ -1240,7 +1240,7 @@ BufferID FileManager::bufferFromDocument(Document doc, bool dontIncrease, bool d if (!dontRef) _pscratchTilla->execute(SCI_ADDREFDOCUMENT, 0, doc); //set reference for FileManager Buffer* newBuf = new Buffer(this, _nextBufferID, doc, DOC_UNNAMED, newTitle.c_str()); - BufferID id = (BufferID)newBuf; + BufferID id = static_cast(newBuf); newBuf->_id = id; _buffers.push_back(newBuf); ++_nrBufs; diff --git a/PowerEditor/src/ScitillaComponent/Buffer.h b/PowerEditor/src/ScitillaComponent/Buffer.h index 8bda758a..417063eb 100644 --- a/PowerEditor/src/ScitillaComponent/Buffer.h +++ b/PowerEditor/src/ScitillaComponent/Buffer.h @@ -77,7 +77,7 @@ public: size_t getNrBuffers() { return _nrBufs; }; int getBufferIndexByID(BufferID id); Buffer * getBufferByIndex(size_t index); - Buffer * getBufferByID(BufferID id) {return (Buffer*)id;} + Buffer * getBufferByID(BufferID id) {return static_cast(id);} void beNotifiedOfBufferChange(Buffer * theBuf, int mask); diff --git a/PowerEditor/src/ScitillaComponent/DocTabView.cpp b/PowerEditor/src/ScitillaComponent/DocTabView.cpp index 95a0983a..7dbd5930 100644 --- a/PowerEditor/src/ScitillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScitillaComponent/DocTabView.cpp @@ -82,7 +82,7 @@ bool DocTabView::activateBuffer(BufferID buffer) BufferID DocTabView::activeBuffer() { int index = getCurrentTabIndex(); - return (BufferID)getBufferByIndex(index); + return static_cast(getBufferByIndex(index)); } @@ -94,7 +94,7 @@ BufferID DocTabView::findBufferByName(const TCHAR * fullfilename) //-1 if not fo for(size_t i = 0; i < _nbItem; ++i) { ::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast(&tie)); - BufferID id = (BufferID)tie.lParam; + BufferID id = reinterpret_cast(tie.lParam); Buffer * buf = MainFileManager->getBufferByID(id); if (!lstrcmp(fullfilename, buf->getFullPathName())) { @@ -113,7 +113,7 @@ int DocTabView::getIndexByBuffer(BufferID id) for(int i = 0; i < (int)_nbItem; ++i) { ::SendMessage(_hSelf, TCM_GETITEM, i, reinterpret_cast(&tie)); - if ((BufferID)tie.lParam == id) + if (reinterpret_cast(tie.lParam) == id) return i; } return -1; @@ -127,7 +127,7 @@ BufferID DocTabView::getBufferByIndex(size_t index) tie.mask = TCIF_PARAM; ::SendMessage(_hSelf, TCM_GETITEM, index, reinterpret_cast(&tie)); - return (BufferID)tie.lParam; + return reinterpret_cast(tie.lParam); } diff --git a/PowerEditor/src/ScitillaComponent/Printer.cpp b/PowerEditor/src/ScitillaComponent/Printer.cpp index 1bcb8d1d..f823246f 100644 --- a/PowerEditor/src/ScitillaComponent/Printer.cpp +++ b/PowerEditor/src/ScitillaComponent/Printer.cpp @@ -143,8 +143,8 @@ size_t Printer::doPrint(bool justDoIt) TEXTMETRIC tm; int fontSize = nppGUI._printSettings._headerFontSize?nppGUI._printSettings._headerFontSize:9; - int fontWeight = nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL; - int isFontItalic = nppGUI._printSettings._headerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE; + int fontWeight = nppGUI._printSettings._headerFontStyle & (FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL); + int isFontItalic = nppGUI._printSettings._headerFontStyle & (FONTSTYLE_ITALIC?TRUE:FALSE); const TCHAR *fontFace = (nppGUI._printSettings._headerFontName != TEXT(""))?nppGUI._printSettings._headerFontName.c_str():TEXT("Arial"); int headerLineHeight = ::MulDiv(fontSize, ptDpi.y, 72); @@ -165,8 +165,8 @@ size_t Printer::doPrint(bool justDoIt) headerLineHeight = tm.tmHeight + tm.tmExternalLeading; fontSize = nppGUI._printSettings._footerFontSize?nppGUI._printSettings._footerFontSize:9; - fontWeight = nppGUI._printSettings._footerFontStyle & FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL; - isFontItalic = nppGUI._printSettings._footerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE; + fontWeight = nppGUI._printSettings._footerFontStyle & (FONTSTYLE_BOLD?FW_BOLD:FW_NORMAL); + isFontItalic = nppGUI._printSettings._footerFontStyle & (FONTSTYLE_ITALIC?TRUE:FALSE); fontFace = (nppGUI._printSettings._footerFontName != TEXT(""))?nppGUI._printSettings._footerFontName.c_str():TEXT("Arial"); //::MessageBox(NULL, itoa(nppGUI._printSettings._footerFontStyle, , 10), TEXT("footer"), MB_OK); @@ -340,12 +340,11 @@ size_t Printer::doPrint(bool justDoIt) _pSEView->showMargin(ScintillaEditView::_SC_MARGE_LINENUMBER, false); size_t pageNum = 1; - bool printPage; const TCHAR pageVar[] = TEXT("$(CURRENT_PRINTING_PAGE)"); while (lengthPrinted < lengthDoc) { - printPage = (!(_pdlg.Flags & PD_PAGENUMS) || + bool printPage = (!(_pdlg.Flags & PD_PAGENUMS) || (pageNum >= _pdlg.nFromPage) && (pageNum <= _pdlg.nToPage)); if (!justDoIt) diff --git a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp index f1fa07cb..bd6e18ec 100644 --- a/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/ColourPopup.cpp @@ -69,7 +69,7 @@ INT_PTR CALLBACK ColourPopup::dlgProc(HWND hwnd, UINT message, WPARAM wParam, LP case WM_INITDIALOG : { - ColourPopup *pColourPopup = (ColourPopup *)(lParam); + ColourPopup *pColourPopup = reinterpret_cast(lParam); pColourPopup->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); pColourPopup->run_dlgProc(message, wParam, lParam); diff --git a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp index a86db1aa..c25945cb 100644 --- a/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp +++ b/PowerEditor/src/WinControls/ColourPicker/WordStyleDlg.cpp @@ -782,12 +782,11 @@ void WordStyleDlg::setVisualFromStyleList() //-- font style : bold & italic isEnable = false; - int isBold, isItalic, isUnderline; if (style._fontStyle != STYLE_NOT_USED) { - isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED; - isItalic = (style._fontStyle & FONTSTYLE_ITALIC)?BST_CHECKED:BST_UNCHECKED; - isUnderline = (style._fontStyle & FONTSTYLE_UNDERLINE)?BST_CHECKED:BST_UNCHECKED; + int isBold = (style._fontStyle & FONTSTYLE_BOLD)?BST_CHECKED:BST_UNCHECKED; + int isItalic = (style._fontStyle & FONTSTYLE_ITALIC)?BST_CHECKED:BST_UNCHECKED; + int isUnderline = (style._fontStyle & FONTSTYLE_UNDERLINE)?BST_CHECKED:BST_UNCHECKED; ::SendMessage(_hCheckBold, BM_SETCHECK, isBold, 0); ::SendMessage(_hCheckItalic, BM_SETCHECK, isItalic, 0); ::SendMessage(_hCheckUnderline, BM_SETCHECK, isUnderline, 0); diff --git a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp index 2cdf3c35..5cc51595 100644 --- a/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp +++ b/PowerEditor/src/WinControls/DockingWnd/DockingManager.cpp @@ -287,7 +287,7 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l { Gripper *pGripper = new Gripper; pGripper->init(_hInst, _hParent); - pGripper->startGrip((DockingCont*)lParam, this); + pGripper->startGrip(reinterpret_cast(lParam), this); break; } @@ -355,12 +355,12 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l case DMM_DOCK: case DMM_FLOAT: { - toggleActiveTb((DockingCont*)lParam, message); + toggleActiveTb(reinterpret_cast(lParam), message); return FALSE; } case DMM_CLOSE: { - tTbData TbData = *((DockingCont*)lParam)->getDataOfActiveTb(); + tTbData TbData = *(reinterpret_cast(lParam))->getDataOfActiveTb(); LRESULT res = SendNotify(TbData.hClient, DMN_CLOSE); // Be sure the active item is OK with closing if (res == 0) // Item will be closing? ::PostMessage(_hParent, WM_ACTIVATE, WA_ACTIVE, 0); // Tell editor to take back focus @@ -368,12 +368,12 @@ LRESULT DockingManager::runProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM l } case DMM_FLOATALL: { - toggleVisTb((DockingCont*)lParam, DMM_FLOAT); + toggleVisTb(reinterpret_cast(lParam), DMM_FLOAT); return FALSE; } case DMM_DOCKALL: { - toggleVisTb((DockingCont*)lParam, DMM_DOCK); + toggleVisTb(reinterpret_cast(lParam), DMM_DOCK); return FALSE; } case DMM_GETIMAGELIST: @@ -699,10 +699,9 @@ void DockingManager::showDockableDlg(HWND hDlg, BOOL view) void DockingManager::showDockableDlg(TCHAR* pszName, BOOL view) { - tTbData *pTbData = NULL; for (size_t i = 0, len = _vContainer.size(); i < len; ++i) { - pTbData = _vContainer[i]->findToolbarByName(pszName); + tTbData *pTbData = _vContainer[i]->findToolbarByName(pszName); if (pTbData != NULL) { _vContainer[i]->showToolbar(pTbData, view); diff --git a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp index 385d5820..82959d45 100644 --- a/PowerEditor/src/WinControls/FunctionList/functionParser.cpp +++ b/PowerEditor/src/WinControls/FunctionList/functionParser.cpp @@ -652,7 +652,7 @@ struct SortZones final void FunctionMixParser::parse(std::vector & foundInfos, size_t begin, size_t end, ScintillaEditView **ppEditView, generic_string classStructName) { - vector< pair > commentZones, scannedZones, nonCommentZones, nonScannedZones; + vector< pair > commentZones, scannedZones, nonScannedZones; getCommentZones(commentZones, begin, end, ppEditView); classParse(foundInfos, scannedZones, commentZones, begin, end, ppEditView, classStructName); diff --git a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp index 5b2a3a23..0e0c2040 100644 --- a/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp +++ b/PowerEditor/src/WinControls/Preference/preferenceDlg.cpp @@ -2015,10 +2015,10 @@ INT_PTR CALLBACK PrintSettingsDlg::run_dlgProc(UINT Message, WPARAM wParam, LPAR wsprintf(intStr, TEXT("%d"), nppGUI._printSettings._footerFontSize); ::SendDlgItemMessage(_hSelf, IDC_COMBO_FFONTSIZE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)intStr); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_HBOLD, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD?TRUE:FALSE, 0); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_HITALIC, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE, 0); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_FBOLD, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & FONTSTYLE_BOLD?TRUE:FALSE, 0); - ::SendDlgItemMessage(_hSelf, IDC_CHECK_FITALIC, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & FONTSTYLE_ITALIC?TRUE:FALSE, 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_HBOLD, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & (FONTSTYLE_BOLD ? TRUE : FALSE), 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_HITALIC, BM_SETCHECK, nppGUI._printSettings._headerFontStyle & (FONTSTYLE_ITALIC ? TRUE : FALSE), 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_FBOLD, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & (FONTSTYLE_BOLD ? TRUE : FALSE), 0); + ::SendDlgItemMessage(_hSelf, IDC_CHECK_FITALIC, BM_SETCHECK, nppGUI._printSettings._footerFontStyle & (FONTSTYLE_ITALIC ? TRUE : FALSE), 0); varList.push_back(strCouple(TEXT("Full file name path"), TEXT("$(FULL_CURRENT_PATH)"))); varList.push_back(strCouple(TEXT("File name"), TEXT("$(FILE_NAME)"))); diff --git a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h index 9c9c38a4..c22cb8b6 100644 --- a/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h +++ b/PowerEditor/src/WinControls/ProjectPanel/ProjectPanel.h @@ -71,9 +71,7 @@ class TiXmlNode; class ProjectPanel : public DockingDlgInterface { public: - ProjectPanel(): DockingDlgInterface(IDD_PROJECTPANEL),\ - _hToolbarMenu(NULL), _hWorkSpaceMenu(NULL), _hProjectMenu(NULL),\ - _hFolderMenu(NULL), _hFileMenu(NULL){}; + ProjectPanel(): DockingDlgInterface(IDD_PROJECTPANEL) {}; void init(HINSTANCE hInst, HWND hPere) { @@ -113,11 +111,14 @@ public: protected: TreeView _treeView; HIMAGELIST _hImaLst; - HWND _hToolbarMenu; - HMENU _hWorkSpaceMenu, _hProjectMenu, _hFolderMenu, _hFileMenu; + HWND _hToolbarMenu = nullptr; + HMENU _hWorkSpaceMenu = nullptr; + HMENU _hProjectMenu = nullptr; + HMENU _hFolderMenu = nullptr; + HMENU _hFileMenu = nullptr; generic_string _workSpaceFilePath; generic_string _selDirOfFilesFromDirDlg; - bool _isDirty; + bool _isDirty = false; void initMenus(); void destroyMenus(); diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp index a4f020bc..0c320d6a 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.cpp @@ -112,7 +112,7 @@ VOID CALLBACK CReadChangesRequest::NotificationCompletion( DWORD dwNumberOfBytesTransfered, // number of bytes transferred LPOVERLAPPED lpOverlapped) // I/O information buffer { - CReadChangesRequest* pBlock = (CReadChangesRequest*)lpOverlapped->hEvent; + CReadChangesRequest* pBlock = reinterpret_cast(lpOverlapped->hEvent); if (dwErrorCode == ERROR_OPERATION_ABORTED) { diff --git a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h index b3076f58..9fb07aa3 100644 --- a/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h +++ b/PowerEditor/src/WinControls/ReadDirectoryChanges/ReadDirectoryChangesPrivate.h @@ -111,7 +111,7 @@ public: static unsigned int WINAPI ThreadStartProc(LPVOID arg) { - CReadChangesServer* pServer = (CReadChangesServer*)arg; + CReadChangesServer* pServer = static_cast(arg); pServer->Run(); return 0; } @@ -119,14 +119,14 @@ public: // Called by QueueUserAPC to start orderly shutdown. static void CALLBACK TerminateProc(__in ULONG_PTR arg) { - CReadChangesServer* pServer = (CReadChangesServer*)arg; + CReadChangesServer* pServer = reinterpret_cast(arg); pServer->RequestTermination(); } // Called by QueueUserAPC to add another directory. static void CALLBACK AddDirectoryProc(__in ULONG_PTR arg) { - CReadChangesRequest* pRequest = (CReadChangesRequest*)arg; + CReadChangesRequest* pRequest = reinterpret_cast(arg); pRequest->m_pServer->AddDirectory(pRequest); } diff --git a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp index 12da65bf..2810d77f 100644 --- a/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp +++ b/PowerEditor/src/WinControls/StaticDialog/StaticDialog.cpp @@ -177,7 +177,7 @@ INT_PTR CALLBACK StaticDialog::dlgProc(HWND hwnd, UINT message, WPARAM wParam, L { case WM_INITDIALOG: { - StaticDialog *pStaticDlg = (StaticDialog *)(lParam); + StaticDialog *pStaticDlg = reinterpret_cast(lParam); pStaticDlg->_hSelf = hwnd; ::SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)lParam); ::GetWindowRect(hwnd, &(pStaticDlg->_rc)); diff --git a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp index 2a1c138d..b1b03150 100644 --- a/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp +++ b/PowerEditor/src/WinControls/VerticalFileSwitcher/VerticalFileSwitcherListView.cpp @@ -186,7 +186,7 @@ int VerticalFileSwitcherListView::newItem(BufferID bufferID, int iView) void VerticalFileSwitcherListView::setItemIconStatus(BufferID bufferID) { - Buffer *buf = (Buffer *)bufferID; + Buffer *buf = static_cast(bufferID); TCHAR fn[MAX_PATH]; lstrcpy(fn, ::PathFindFileName(buf->getFileName())); @@ -259,7 +259,7 @@ void VerticalFileSwitcherListView::activateItem(BufferID bufferID, int iView) int VerticalFileSwitcherListView::add(BufferID bufferID, int iView) { int index = ListView_GetItemCount(_hSelf); - Buffer *buf = (Buffer *)bufferID; + Buffer *buf = static_cast(bufferID); const TCHAR *fileName = buf->getFileName(); TaskLstFnStatus *tl = new TaskLstFnStatus(iView, 0, fileName, 0, (void *)bufferID); diff --git a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp index af682960..f9ecb197 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WindowsDlg.cpp @@ -543,7 +543,7 @@ void WindowsDlg::onGetMinMaxInfo(MINMAXINFO* lpMMI) LRESULT WindowsDlg::onWinMgr(WPARAM wp, LPARAM lp) { - NMWINMGR &nmw = *(NMWINMGR *)lp; + NMWINMGR &nmw = *reinterpret_cast(lp); if (nmw.code==NMWINMGR::GET_SIZEINFO) { switch(wp) { @@ -739,20 +739,19 @@ void WindowsDlg::doSortToTabs() NMWINDLG nmdlg; nmdlg.type = WDT_SORT; nmdlg.hwndFrom = _hSelf; - //nmdlg.curSel = curSel; nmdlg.curSel = _idxMap[curSel]; nmdlg.code = WDN_NOTIFY; - UINT n = nmdlg.nItems = ListView_GetItemCount(_hList); + nmdlg.nItems = ListView_GetItemCount(_hList); nmdlg.Items = new UINT[nmdlg.nItems]; - vector key; - key.resize(n, 0x7fffffff); - for(int i=-1, j=0;; ++j) { + + for(int i=-1, j=0;; ++j) + { i = ListView_GetNextItem(_hList, i, LVNI_ALL); - if (i == -1) break; + if (i == -1) + break; nmdlg.Items[j] = _idxMap[i]; if (i == curSel) nmdlg.curSel = j; - key[j] = i; } SendMessage(_hParent, WDN_NOTIFY, 0, LPARAM(&nmdlg)); diff --git a/PowerEditor/src/WinControls/shortcut/shortcut.cpp b/PowerEditor/src/WinControls/shortcut/shortcut.cpp index e4babe9f..43440022 100644 --- a/PowerEditor/src/WinControls/shortcut/shortcut.cpp +++ b/PowerEditor/src/WinControls/shortcut/shortcut.cpp @@ -583,7 +583,8 @@ void Accelerator::updateFullMenu() { ::DrawMenuBar(_hMenuParent); } -void Accelerator::updateMenuItemByCommand(CommandShortcut csc) { +void Accelerator::updateMenuItemByCommand(CommandShortcut csc) +{ int cmdID = (int)csc.getID(); // Ensure that the menu item checks set prior to this update remain in affect. @@ -641,9 +642,9 @@ void recordedMacroStep::PlayBack(Window* pNotepad, ScintillaEditView *pEditView) else { - char ansiBuffer[3]; if (_macroType == mtUseSParameter) { + char ansiBuffer[3]; ::WideCharToMultiByte(static_cast(pEditView->execute(SCI_GETCODEPAGE)), 0, _sParameter.c_str(), -1, ansiBuffer, 3, NULL, NULL); auto lParam = reinterpret_cast(ansiBuffer); pEditView->execute(_message, _wParameter, lParam); diff --git a/PowerEditor/src/lastRecentFileList.h b/PowerEditor/src/lastRecentFileList.h index ddfe14ac..4d76b49a 100644 --- a/PowerEditor/src/lastRecentFileList.h +++ b/PowerEditor/src/lastRecentFileList.h @@ -36,7 +36,7 @@ #include struct RecentItem { - int _id; + int _id = 0; generic_string _name; RecentItem(const TCHAR * name) : _name(name) {}; };