diff --git a/PowerEditor/src/MISC/Exception/MiniDumper.cpp b/PowerEditor/src/MISC/Exception/MiniDumper.cpp index 48c22efdd..61f6b2493 100644 --- a/PowerEditor/src/MISC/Exception/MiniDumper.cpp +++ b/PowerEditor/src/MISC/Exception/MiniDumper.cpp @@ -55,11 +55,11 @@ bool MiniDumper::writeDump(EXCEPTION_POINTERS * pExceptionInfo) if (hFile!=INVALID_HANDLE_VALUE) { - _MINIDUMP_EXCEPTION_INFORMATION ExInfo; + _MINIDUMP_EXCEPTION_INFORMATION ExInfo{}; ExInfo.ThreadId = ::GetCurrentThreadId(); ExInfo.ExceptionPointers = pExceptionInfo; - ExInfo.ClientPointers = NULL; + ExInfo.ClientPointers = FALSE; // write the dump BOOL bOK = pDump( GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL ); diff --git a/PowerEditor/src/ScintillaComponent/Buffer.cpp b/PowerEditor/src/ScintillaComponent/Buffer.cpp index e19ba3693..0604b275a 100644 --- a/PowerEditor/src/ScintillaComponent/Buffer.cpp +++ b/PowerEditor/src/ScintillaComponent/Buffer.cpp @@ -136,7 +136,7 @@ void Buffer::setLangType(LangType lang, const TCHAR* userLangName) void Buffer::updateTimeStamp() { FILETIME timeStampLive = {}; - WIN32_FILE_ATTRIBUTE_DATA attributes; + WIN32_FILE_ATTRIBUTE_DATA attributes{}; if (GetFileAttributesEx(_fullPathName.c_str(), GetFileExInfoStandard, &attributes) != 0) { timeStampLive = attributes.ftLastWriteTime; @@ -163,7 +163,7 @@ void Buffer::updateTimeStamp() std::wstring_convert> converter; std::string msg = converter.to_bytes(_fullPathName); char buf[1024]; - sprintf(buf, " in updateTimeStamp(): timeStampLive (%u/%u) < _timeStamp (%u/%u)", timeStampLive.dwLowDateTime, timeStampLive.dwHighDateTime, _timeStamp.dwLowDateTime, _timeStamp.dwHighDateTime); + sprintf(buf, " in updateTimeStamp(): timeStampLive (%lu/%lu) < _timeStamp (%lu/%lu)", timeStampLive.dwLowDateTime, timeStampLive.dwHighDateTime, _timeStamp.dwLowDateTime, _timeStamp.dwHighDateTime); msg += buf; writeLog(nppIssueLog.c_str(), msg.c_str()); } @@ -254,7 +254,7 @@ bool Buffer::checkFileState() // returns true if the status has been changed (it if (_currentStatus == DOC_UNNAMED || isMonitoringOn()) return false; - WIN32_FILE_ATTRIBUTE_DATA attributes; + WIN32_FILE_ATTRIBUTE_DATA attributes{}; bool isWow64Off = false; NppParameters& nppParam = NppParameters::getInstance(); @@ -323,7 +323,7 @@ bool Buffer::checkFileState() // returns true if the status has been changed (it std::wstring_convert> converter; std::string msg = converter.to_bytes(_fullPathName); char buf[1024]; - sprintf(buf, " in checkFileState(): attributes.ftLastWriteTime (%u/%u) < _timeStamp (%u/%u)", attributes.ftLastWriteTime.dwLowDateTime, attributes.ftLastWriteTime.dwHighDateTime, _timeStamp.dwLowDateTime, _timeStamp.dwHighDateTime); + sprintf(buf, " in checkFileState(): attributes.ftLastWriteTime (%lu/%lu) < _timeStamp (%lu/%lu)", attributes.ftLastWriteTime.dwLowDateTime, attributes.ftLastWriteTime.dwHighDateTime, _timeStamp.dwLowDateTime, _timeStamp.dwHighDateTime); msg += buf; writeLog(nppIssueLog.c_str(), msg.c_str()); } @@ -359,7 +359,7 @@ bool Buffer::checkFileState() // returns true if the status has been changed (it void Buffer::reload() { - WIN32_FILE_ATTRIBUTE_DATA attributes; + WIN32_FILE_ATTRIBUTE_DATA attributes{}; if (GetFileAttributesEx(_fullPathName.c_str(), GetFileExInfoStandard, &attributes) != 0) { _timeStamp = attributes.ftLastWriteTime; @@ -373,10 +373,10 @@ int64_t Buffer::getFileLength() const if (_currentStatus == DOC_UNNAMED) return -1; - WIN32_FILE_ATTRIBUTE_DATA attributes; + WIN32_FILE_ATTRIBUTE_DATA attributes{}; if (GetFileAttributesEx(_fullPathName.c_str(), GetFileExInfoStandard, &attributes) != 0) { - LARGE_INTEGER size; + LARGE_INTEGER size{}; size.LowPart = attributes.nFileSizeLow; size.HighPart = attributes.nFileSizeHigh; return size.QuadPart; @@ -391,7 +391,7 @@ generic_string Buffer::getFileTime(fileTimeType ftt) const if (_currentStatus != DOC_UNNAMED) { - WIN32_FILE_ATTRIBUTE_DATA attributes; + WIN32_FILE_ATTRIBUTE_DATA attributes{}; if (GetFileAttributesEx(_fullPathName.c_str(), GetFileExInfoStandard, &attributes) != 0) { FILETIME rawtime; diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp index 3b8080590..9ba9b400e 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.cpp @@ -54,9 +54,9 @@ generic_string getTextFromCombo(HWND hCombo) void delLeftWordInEdit(HWND hEdit) { - TCHAR str[FINDREPLACE_MAXLENGTH]; + TCHAR str[FINDREPLACE_MAXLENGTH] = { '\0' }; ::SendMessage(hEdit, WM_GETTEXT, FINDREPLACE_MAXLENGTH - 1, reinterpret_cast(str)); - WORD cursor; + WORD cursor = 0; ::SendMessage(hEdit, EM_GETSEL, (WPARAM)&cursor, 0); WORD wordstart = cursor; while (wordstart > 0) { @@ -228,8 +228,8 @@ void Searching::displaySectionCentered(size_t posStart, size_t posEnd, Scintilla pEditView->execute(SCI_CHOOSECARETX); } -LONG_PTR FindReplaceDlg::originalFinderProc = NULL; -LONG_PTR FindReplaceDlg::originalComboEditProc = NULL; +WNDPROC FindReplaceDlg::originalFinderProc = nullptr; +WNDPROC FindReplaceDlg::originalComboEditProc = nullptr; // important : to activate all styles const int STYLING_MASK = 255; @@ -1257,7 +1257,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA GetComboBoxInfo(hFindCombo, &cbinfo); if (!cbinfo.hwndItem) return FALSE; - originalComboEditProc = SetWindowLongPtr(cbinfo.hwndItem, GWLP_WNDPROC, reinterpret_cast(comboEditProc)); + originalComboEditProc = reinterpret_cast(SetWindowLongPtr(cbinfo.hwndItem, GWLP_WNDPROC, reinterpret_cast(comboEditProc))); SetWindowLongPtr(cbinfo.hwndItem, GWLP_USERDATA, reinterpret_cast(cbinfo.hwndCombo)); GetComboBoxInfo(hReplaceCombo, &cbinfo); SetWindowLongPtr(cbinfo.hwndItem, GWLP_WNDPROC, reinterpret_cast(comboEditProc)); @@ -1294,12 +1294,12 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA SendMessage(hComboBox, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), MAKELPARAM(true, 0)); } - RECT arc; + RECT arc{}; ::GetWindowRect(::GetDlgItem(_hSelf, IDCANCEL), &arc); _markClosePos.bottom = _findInFilesClosePos.bottom = _replaceClosePos.bottom = _findClosePos.bottom = arc.bottom - arc.top; _markClosePos.right = _findInFilesClosePos.right = _replaceClosePos.right = _findClosePos.right = arc.right - arc.left; - POINT p; + POINT p{}; p.x = arc.left; p.y = arc.top; ::ScreenToClient(_hSelf, &p); @@ -2190,7 +2190,7 @@ intptr_t CALLBACK FindReplaceDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA RECT rc = { 0, 0, 0, 0}; getWindowRect(rc); int w = rc.right - rc.left; - POINT p; + POINT p{}; p.x = rc.left; p.y = rc.top; bool& isLessModeOn = NppParameters::getInstance().getNppGUI()._findWindowLessMode; @@ -3037,7 +3037,7 @@ void FindReplaceDlg::findAllIn(InWhat op) _pFinder->_scintView.init(_hInst, _pFinder->getHSelf()); // Subclass the ScintillaEditView for the Finder (Scintilla doesn't notify all key presses) - originalFinderProc = SetWindowLongPtr(_pFinder->_scintView.getHSelf(), GWLP_WNDPROC, reinterpret_cast(finderProc)); + originalFinderProc = reinterpret_cast(SetWindowLongPtr(_pFinder->_scintView.getHSelf(), GWLP_WNDPROC, reinterpret_cast(finderProc))); _pFinder->setFinderReadOnly(true); _pFinder->_scintView.execute(SCI_SETCODEPAGE, SC_CP_UTF8); @@ -3087,7 +3087,7 @@ void FindReplaceDlg::findAllIn(InWhat op) { // Send the address of _MarkingsStruct to the lexer char ptrword[sizeof(void*) * 2 + 1]; - sprintf(ptrword, "%p", &_pFinder->_markingsStruct); + sprintf(ptrword, "%p", static_cast(&_pFinder->_markingsStruct)); _pFinder->_scintView.execute(SCI_SETPROPERTY, reinterpret_cast("@MarkingsStruct"), reinterpret_cast(ptrword)); //enable "Search Results Window" under Search Menu @@ -3170,7 +3170,7 @@ Finder * FindReplaceDlg::createFinder() pFinder->_scintView.changeTextDirection(true); // Subclass the ScintillaEditView for the Finder (Scintilla doesn't notify all key presses) - originalFinderProc = SetWindowLongPtr(pFinder->_scintView.getHSelf(), GWLP_WNDPROC, reinterpret_cast(finderProc)); + originalFinderProc = reinterpret_cast(SetWindowLongPtr(pFinder->_scintView.getHSelf(), GWLP_WNDPROC, reinterpret_cast(finderProc))); pFinder->setFinderReadOnly(true); pFinder->_scintView.execute(SCI_SETCODEPAGE, SC_CP_UTF8); @@ -3206,7 +3206,7 @@ Finder * FindReplaceDlg::createFinder() // Send the address of _MarkingsStruct to the lexer char ptrword[sizeof(void*) * 2 + 1]; - sprintf(ptrword, "%p", &pFinder->_markingsStruct); + sprintf(ptrword, "%p", static_cast(&pFinder->_markingsStruct)); pFinder->_scintView.execute(SCI_SETPROPERTY, reinterpret_cast("@MarkingsStruct"), reinterpret_cast(ptrword)); _findersOfFinder.push_back(pFinder); @@ -3333,7 +3333,7 @@ void FindReplaceDlg::enableReplaceFunc(bool isEnable) ::MoveWindow(::GetDlgItem(_hSelf, IDC_IN_SELECTION_CHECK), pInSectionCheckPos->left + _deltaWidth, pInSectionCheckPos->top, pInSectionCheckPos->right, pInSectionCheckPos->bottom, TRUE); ::MoveWindow(::GetDlgItem(_hSelf, IDC_REPLACEINSELECTION), pInSelectionFramePos->left + _deltaWidth, pInSelectionFramePos->top, pInSelectionFramePos->right, pInSelectionFramePos->bottom, TRUE); - TCHAR label[MAX_PATH]; + TCHAR label[MAX_PATH] = { '\0' }; _tab.getCurrentTitle(label, MAX_PATH); ::SetWindowText(_hSelf, label); @@ -3496,7 +3496,7 @@ void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus if (!NppParameters::getInstance().getNppGUI()._muteSounds) ::MessageBeep(0xFFFFFFFF); - FLASHWINFO flashInfo; + FLASHWINFO flashInfo{}; flashInfo.cbSize = sizeof(FLASHWINFO); flashInfo.hwnd = isVisible()?_hSelf:GetParent(_hSelf); flashInfo.uCount = 3; @@ -3508,7 +3508,7 @@ void FindReplaceDlg::setStatusbarMessage(const generic_string & msg, FindStatus { if (!isVisible()) { - FLASHWINFO flashInfo; + FLASHWINFO flashInfo{}; flashInfo.cbSize = sizeof(FLASHWINFO); flashInfo.hwnd = GetParent(_hSelf); flashInfo.uCount = 2; @@ -4027,7 +4027,7 @@ LRESULT FAR PASCAL FindReplaceDlg::finderProc(HWND hwnd, UINT message, WPARAM wP } else // Call default (original) window procedure - return CallWindowProc((WNDPROC) originalFinderProc, hwnd, message, wParam, lParam); + return CallWindowProc(originalFinderProc, hwnd, message, wParam, lParam); } LRESULT FAR PASCAL FindReplaceDlg::comboEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) @@ -4061,7 +4061,7 @@ LRESULT FAR PASCAL FindReplaceDlg::comboEditProc(HWND hwnd, UINT message, WPARAM delLeftWordInEdit(hwnd); return 0; } - return CallWindowProc((WNDPROC)originalComboEditProc, hwnd, message, wParam, lParam); + return CallWindowProc(originalComboEditProc, hwnd, message, wParam, lParam); } void FindReplaceDlg::hideOrShowCtrl4reduceOrNormalMode(DIALOG_TYPE dlgT) @@ -4750,7 +4750,7 @@ void Finder::finishFilesSearch(int count, int searchedCount, bool isMatchLines, //SCI_SETILEXER resets the lexer property @MarkingsStruct and then no data could be exchanged with the searchResult lexer char ptrword[sizeof(void*) * 2 + 1]; - sprintf(ptrword, "%p", &_markingsStruct); + sprintf(ptrword, "%p", static_cast(&_markingsStruct)); _scintView.execute(SCI_SETPROPERTY, reinterpret_cast("@MarkingsStruct"), reinterpret_cast(ptrword)); //previous code: _scintView.execute(SCI_SETILEXER, 0, reinterpret_cast(CreateLexer("searchResult"))); diff --git a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h index 8873ba9aa..c1ffba367 100644 --- a/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h +++ b/PowerEditor/src/ScintillaComponent/FindReplaceDlg.h @@ -366,8 +366,8 @@ public : protected : void resizeDialogElements(LONG newWidth); virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam); - static LONG_PTR originalFinderProc; - static LONG_PTR originalComboEditProc; + static WNDPROC originalFinderProc; + static WNDPROC originalComboEditProc; static LRESULT FAR PASCAL comboEditProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp index cd165ad3b..c38435b64 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp @@ -796,8 +796,7 @@ void SetHomeRow(HWND hWnd,int SI,int row,int col) void SetHomeCol(HWND hWnd,int SI,int row,int col) { - RECT gridrect,cellrect; - BOOL LASTCOLVISIBLE; + RECT gridrect{}, cellrect{}; //get rect of grid window GetClientRect(hWnd,&gridrect); //get rect of current cell @@ -807,16 +806,6 @@ void SetHomeCol(HWND hWnd,int SI,int row,int col) { //scroll right is needed BGHS[SI].homecol++; - //see if last column is visible - cellrect = GetCellRect(hWnd,SI,row,BGHS[SI].cols); - if(cellrect.right <= gridrect.right) - { - LASTCOLVISIBLE=TRUE; - } - else - { - LASTCOLVISIBLE=FALSE; - } cellrect = GetCellRect(hWnd,SI,row,col); InvalidateRect(hWnd,&gridrect,FALSE); } @@ -826,16 +815,6 @@ void SetHomeCol(HWND hWnd,int SI,int row,int col) { //scroll left is needed BGHS[SI].homecol--; - //see if last column is visible - cellrect = GetCellRect(hWnd,SI,row,BGHS[SI].cols); - if(cellrect.right <= gridrect.right) - { - LASTCOLVISIBLE=TRUE; - } - else - { - LASTCOLVISIBLE=FALSE; - } cellrect = GetCellRect(hWnd,SI,row,col); InvalidateRect(hWnd,&gridrect,FALSE); @@ -1352,20 +1331,17 @@ int FindLongestLine(HDC hdc, wchar_t* text, SIZE* size) LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - int wmId, wmEvent; + int wmId; PAINTSTRUCT ps; - HDC hdc; TCHAR buffer[bufferLen]; int SelfIndex; int ReturnValue; - HMENU SelfMenu; HINSTANCE hInst; int iDataType; SelfIndex=FindGrid(GetMenu(hWnd)); - SelfMenu=BGHS[SelfIndex].gridmenu; //update the grid width and height variable { @@ -1383,7 +1359,6 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { case WM_COMMAND: wmId = LOWORD(wParam); - wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { @@ -1394,7 +1369,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_PAINT: - hdc = BeginPaint(hWnd, &ps); + BeginPaint(hWnd, &ps); RECT rt; GetClientRect(hWnd, &rt); CalcVisibleCellBoundaries(SelfIndex); diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp index 36b649e73..df9c16e09 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp +++ b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.cpp @@ -383,7 +383,7 @@ CWinMgr::OnGetSizeInfo(SIZEINFO& szi, WINRECT* wrc, HWND hWnd) // BOOL CWinMgr::SendGetSizeInfo(SIZEINFO& szi, HWND hWnd, UINT nID) { - NMWINMGR nmw; + NMWINMGR nmw{}; nmw.code = NMWINMGR::GET_SIZEINFO; // request size info nmw.idFrom = nID; // ID of child I'm computing nmw.sizeinfo = szi; // copy diff --git a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h index 211375a63..e69bf82b8 100644 --- a/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h +++ b/PowerEditor/src/WinControls/WindowsDlg/WinMgr.h @@ -207,15 +207,15 @@ struct NMWINMGR : public NMHDR { // each notification code has its own part of union union { - SIZEINFO sizeinfo; // used for GET_SIZEINFO + SIZEINFO sizeinfo{}; // used for GET_SIZEINFO struct { // used for SIZEBAR_MOVED - POINT ptMoved; // distance moved (x or y = zero) + POINT ptMoved{}; // distance moved (x or y = zero) } sizebar; }; - BOOL processed; + BOOL processed = FALSE; // ctor: initialize to zeroes - NMWINMGR() { memset(this,0,sizeof(NMWINMGR)); } + NMWINMGR() : NMHDR{ nullptr, 0, 0 }, sizeinfo{}, processed(FALSE) {} }; ///////////////////