diff --git a/PowerEditor/src/NppDarkMode.cpp b/PowerEditor/src/NppDarkMode.cpp index f0b2812db..58d00679b 100644 --- a/PowerEditor/src/NppDarkMode.cpp +++ b/PowerEditor/src/NppDarkMode.cpp @@ -1313,7 +1313,7 @@ namespace NppDarkMode DWORD textFlags = isCenter ? DT_CENTER : DT_LEFT; - if(::SendMessage(hwnd, WM_QUERYUISTATE, 0, 0) != NULL) + if(::SendMessage(hwnd, WM_QUERYUISTATE, 0, 0) != static_cast(NULL)) { textFlags |= DT_HIDEPREFIX; } diff --git a/PowerEditor/src/ScintillaComponent/DocTabView.cpp b/PowerEditor/src/ScintillaComponent/DocTabView.cpp index 1d71d8870..d78219b94 100644 --- a/PowerEditor/src/ScintillaComponent/DocTabView.cpp +++ b/PowerEditor/src/ScintillaComponent/DocTabView.cpp @@ -195,7 +195,7 @@ void DocTabView::bufferUpdated(Buffer * buffer, int mask) void DocTabView::setBuffer(size_t index, BufferID id) { - if (index < 0 || index >= _nbItem) + if (index >= _nbItem) return; TCITEM tie{}; diff --git a/PowerEditor/src/ScintillaComponent/Printer.cpp b/PowerEditor/src/ScintillaComponent/Printer.cpp index 1d74eccad..95e461ec9 100644 --- a/PowerEditor/src/ScintillaComponent/Printer.cpp +++ b/PowerEditor/src/ScintillaComponent/Printer.cpp @@ -70,12 +70,12 @@ size_t Printer::doPrint(bool justDoIt) { const NppGUI & nppGUI = (NppParameters::getInstance()).getNppGUI(); - POINT ptPage; - POINT ptDpi; + POINT ptPage{}; + POINT ptDpi{}; - RECT rectMargins; - RECT rectPhysMargins; - RECT userMargins; + RECT rectMargins{}; + RECT rectPhysMargins{}; + RECT userMargins{}; // Get printer resolution ptDpi.x = GetDeviceCaps(_pdlg.hDC, LOGPIXELSX); // dpi in X direction @@ -126,7 +126,7 @@ size_t Printer::doPrint(bool justDoIt) // Convert page size to logical units and we're done! DPtoLP(_pdlg.hDC, &ptPage, 1); - TEXTMETRIC tm; + TEXTMETRIC tm{}; int fontSize = nppGUI._printSettings._headerFontSize?nppGUI._printSettings._headerFontSize:9; int fontWeight = (nppGUI._printSettings._headerFontStyle & FONTSTYLE_BOLD) ? FW_BOLD : FW_NORMAL; @@ -172,7 +172,7 @@ size_t Printer::doPrint(bool justDoIt) int printMarge = tm.tmHeight + tm.tmExternalLeading; printMarge = printMarge + printMarge / 2; - DOCINFO docInfo; + DOCINFO docInfo{}; docInfo.cbSize = sizeof(DOCINFO); docInfo.fwType = 0; docInfo.lpszDocName = _pSEView->getCurrentBuffer()->getFullPathName(); @@ -205,13 +205,11 @@ size_t Printer::doPrint(bool justDoIt) lengthDoc = _endPos; } - if (lengthPrinted < 0) - lengthPrinted = 0; if (lengthDoc > lengthDocMax) lengthDoc = lengthDocMax; } - NPP_RangeToFormat frPrint; + NPP_RangeToFormat frPrint{}; frPrint.hdc = _pdlg.hDC; frPrint.hdcTarget = _pdlg.hDC; frPrint.rc.left = rectMargins.left - rectPhysMargins.left; @@ -246,7 +244,7 @@ size_t Printer::doPrint(bool justDoIt) TCHAR longDate[bufferSize]; TCHAR time[bufferSize]; - SYSTEMTIME st; + SYSTEMTIME st{}; ::GetLocalTime(&st); ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, shortDate, bufferSize); ::GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, longDate, bufferSize); @@ -334,7 +332,7 @@ size_t Printer::doPrint(bool justDoIt) if (!justDoIt) printPage = false; - TCHAR pageString[32]; + TCHAR pageString[32]{}; wsprintf(pageString, TEXT("%0d"), pageNum); if (printPage) @@ -354,7 +352,7 @@ size_t Printer::doPrint(bool justDoIt) rcw.bottom = rcw.top + headerLineHeight; - SIZE size; + SIZE size{}; // Left part if (headerL[0] != '\0') @@ -421,7 +419,7 @@ size_t Printer::doPrint(bool justDoIt) RECT rcw = {frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 2, frPrint.rc.right, frPrint.rc.bottom + footerLineHeight + footerLineHeight / 2}; - SIZE size; + SIZE size{}; // Left part if (footerL[0] != '\0') @@ -491,7 +489,7 @@ size_t Printer::doPrint(bool justDoIt) if (fontFooter) ::DeleteObject(fontFooter); - return (pageNum - 1); + return (static_cast(pageNum) - 1); } diff --git a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp index 53cecb520..fa14c0578 100644 --- a/PowerEditor/src/WinControls/Grid/BabyGrid.cpp +++ b/PowerEditor/src/WinControls/Grid/BabyGrid.cpp @@ -1866,21 +1866,14 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } break; case BGM_SETGRIDDIM: - if((wParam>=0)&&(wParam<=MAX_ROWS)) - { - BGHS[SelfIndex].rows = static_cast(wParam); - } - else - { - if(wParam<0) - { - BGHS[SelfIndex].rows = 0; - } - else - { - BGHS[SelfIndex].rows = MAX_ROWS; - } - } + if (wParam<=MAX_ROWS) + { + BGHS[SelfIndex].rows = static_cast(wParam); + } + else + { + BGHS[SelfIndex].rows = MAX_ROWS; + } if((lParam>0)&&(lParam<=MAX_COLS)) { @@ -1906,7 +1899,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case BGM_SETCOLWIDTH: - if((wParam <= MAX_COLS)&&(wParam >= 0) && (lParam >= 0)) + if((wParam <= MAX_COLS) && (lParam >= 0)) { RECT rect; BGHS[SelfIndex].columnwidths[wParam] = static_cast(lParam); @@ -1916,15 +1909,12 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } break; case BGM_SETHEADERROWHEIGHT: - if(wParam >= 0) - { - RECT rect; - BGHS[SelfIndex].headerrowheight = static_cast(wParam); - SizeGrid(hWnd,SelfIndex); - GetClientRect(hWnd,&rect); - InvalidateRect(hWnd,&rect,FALSE); - } - break; + RECT rect; + BGHS[SelfIndex].headerrowheight = static_cast(wParam); + SizeGrid(hWnd, SelfIndex); + GetClientRect(hWnd, &rect); + InvalidateRect(hWnd, &rect, FALSE); + break; case BGM_GETHOMEROW: ReturnValue = BGHS[SelfIndex].homerow; @@ -2013,8 +2003,7 @@ LRESULT CALLBACK GridProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) break; case BGM_SETTITLEHEIGHT: - if(wParam<0){wParam =0;} - BGHS[SelfIndex].titleheight = static_cast(wParam); + BGHS[SelfIndex].titleheight = static_cast(wParam); SetHomeRow(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol); SetHomeCol(hWnd,SelfIndex,BGHS[SelfIndex].cursorrow,BGHS[SelfIndex].cursorcol); {