mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-28 00:04:25 +02:00
Fix some GCC and MSC warnings
- optimize dark mode - add initializers Fix #13867, close #13868
This commit is contained in:
parent
d6bdc5d3f8
commit
a647991cd7
@ -53,13 +53,13 @@ SUBMAKEFLAGS := -O --no-print-directory
|
||||
ifeq "$(filter-out 0,$(DEBUG))" ""
|
||||
BUILD_TYPE := release
|
||||
BUILD_SUFFIX :=
|
||||
CXXFLAGS += -O3 -Wconversion
|
||||
CXXFLAGS += -O3 -Wno-alloc-size-larger-than -Wconversion
|
||||
CPP_DEFINE += NDEBUG
|
||||
LDFLAGS += -s
|
||||
else
|
||||
BUILD_TYPE := debug
|
||||
BUILD_SUFFIX := -debug
|
||||
CXXFLAGS += -Og -g -Wpedantic -Wall -Wextra -Wno-cast-function-type -Wconversion
|
||||
CXXFLAGS += -Og -g -Wpedantic -Wall -Wextra -Wno-cast-function-type -Wno-overloaded-virtual -Wconversion
|
||||
CPP_DEFINE += DEBUG
|
||||
endif
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include "Common.h"
|
||||
|
||||
#include "regExtDlg.h"
|
||||
#include "resource.h"
|
||||
#include "Parameters.h"
|
||||
@ -109,20 +109,12 @@ intptr_t CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case WM_CTLCOLORLISTBOX:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColorListbox(wParam, lParam);
|
||||
}
|
||||
break;
|
||||
return NppDarkMode::onCtlColorListbox(wParam, lParam);
|
||||
}
|
||||
|
||||
case WM_CTLCOLORDLG:
|
||||
{
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
||||
}
|
||||
break;
|
||||
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
||||
}
|
||||
|
||||
case WM_CTLCOLORSTATIC:
|
||||
@ -136,12 +128,7 @@ intptr_t CALLBACK RegExtDlg::run_dlgProc(UINT Message, WPARAM wParam, LPARAM lPa
|
||||
{
|
||||
return NppDarkMode::onCtlColorDarkerBGStaticText(hdcStatic, nppParam.isAdmin());
|
||||
}
|
||||
|
||||
if (NppDarkMode::isEnabled())
|
||||
{
|
||||
return NppDarkMode::onCtlColorDarker(hdcStatic);
|
||||
}
|
||||
return FALSE;
|
||||
return NppDarkMode::onCtlColorDarker(hdcStatic);
|
||||
}
|
||||
|
||||
case WM_PRINTCLIENT:
|
||||
@ -340,7 +327,7 @@ void RegExtDlg::getRegisteredExts()
|
||||
int nbRegisteredKey = getNbSubKey(HKEY_CLASSES_ROOT);
|
||||
for (int i = 0 ; i < nbRegisteredKey ; ++i)
|
||||
{
|
||||
TCHAR extName[extNameLen];
|
||||
TCHAR extName[extNameLen]{};
|
||||
//FILETIME fileTime;
|
||||
int extNameActualLen = extNameLen;
|
||||
int res = ::RegEnumKeyEx(HKEY_CLASSES_ROOT, i, extName, reinterpret_cast<LPDWORD>(&extNameActualLen), nullptr, nullptr, nullptr, nullptr);
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "regExtDlgRc.h"
|
||||
#include "StaticDialog.h"
|
||||
|
||||
const int extNameLen = 32;
|
||||
constexpr int extNameLen = 32;
|
||||
|
||||
class RegExtDlg : public StaticDialog
|
||||
{
|
||||
@ -33,7 +33,7 @@ public :
|
||||
private :
|
||||
bool _isCustomize = false;
|
||||
|
||||
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
intptr_t CALLBACK run_dlgProc(UINT Message, WPARAM wParam, LPARAM lParam) override;
|
||||
|
||||
void getRegisteredExts();
|
||||
void getDefSupportedExts();
|
||||
@ -42,13 +42,13 @@ private :
|
||||
void writeNppPath();
|
||||
|
||||
int getNbSubKey(HKEY hKey) const {
|
||||
int nbSubKey;
|
||||
int nbSubKey = 0;
|
||||
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, (LPDWORD)&nbSubKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
return (result == ERROR_SUCCESS)?nbSubKey:0;
|
||||
}
|
||||
|
||||
int getNbSubValue(HKEY hKey) const {
|
||||
int nbSubValue;
|
||||
int nbSubValue = 0;
|
||||
long result = ::RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL, (LPDWORD)&nbSubValue, NULL, NULL, NULL, NULL);
|
||||
return (result == ERROR_SUCCESS)?nbSubValue:0;
|
||||
}
|
||||
|
@ -39,9 +39,11 @@
|
||||
#define S_R3(v,w,x,y,z,i) {z+=(((w|x)&y)|(w&x))+SHABLK(i)+0x8F1BBCDC+ROL32(v,5);w=ROL32(w,30);}
|
||||
#define S_R4(v,w,x,y,z,i) {z+=(w^x^y)+SHABLK(i)+0xCA62C1D6+ROL32(v,5);w=ROL32(w,30);}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
// Disable compiler warning 'Conditional expression is constant'
|
||||
#pragma warning(disable: 4127)
|
||||
#endif
|
||||
|
||||
CSHA1::CSHA1()
|
||||
{
|
||||
@ -172,9 +174,9 @@ bool CSHA1::HashFile(const TCHAR* tszFileName)
|
||||
|
||||
void CSHA1::Final()
|
||||
{
|
||||
UINT_32 i;
|
||||
UINT_32 i = 0;
|
||||
|
||||
UINT_8 pbFinalCount[8];
|
||||
UINT_8 pbFinalCount[8]{};
|
||||
for(i = 0; i < 8; ++i)
|
||||
pbFinalCount[i] = static_cast<UINT_8>((m_count[((i >= 4) ? 0 : 1)] >>
|
||||
((3 - (i & 3)) * 8) ) & 0xFF); // Endian independent
|
||||
@ -205,7 +207,7 @@ bool CSHA1::ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType) const
|
||||
{
|
||||
if(tszReport == NULL) return false;
|
||||
|
||||
TCHAR tszTemp[16];
|
||||
TCHAR tszTemp[16]{};
|
||||
|
||||
if((rtReportType == REPORT_HEX) || (rtReportType == REPORT_HEX_SHORT))
|
||||
{
|
||||
@ -239,7 +241,7 @@ bool CSHA1::ReportHash(TCHAR* tszReport, REPORT_TYPE rtReportType) const
|
||||
#ifdef SHA1_STL_FUNCTIONS
|
||||
bool CSHA1::ReportHashStl(std::basic_string<TCHAR>& strOut, REPORT_TYPE rtReportType) const
|
||||
{
|
||||
TCHAR tszOut[84];
|
||||
TCHAR tszOut[84]{};
|
||||
const bool bResult = ReportHash(tszOut, rtReportType);
|
||||
if(bResult) strOut = tszOut;
|
||||
return bResult;
|
||||
@ -253,4 +255,6 @@ bool CSHA1::GetHash(UINT_8* pbDest20) const
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
@ -18,7 +18,9 @@
|
||||
#include <wincrypt.h>
|
||||
#include "sha512.h"
|
||||
|
||||
#pragma comment(lib, "crypt32.lib")
|
||||
//#if defined(_MSC_VER)
|
||||
//#pragma comment(lib, "crypt32.lib")
|
||||
//#endif
|
||||
|
||||
void calc_sha_512(unsigned char hash[64], const void *input, size_t len) {
|
||||
HCRYPTPROV hProv = 0;
|
||||
|
@ -508,11 +508,10 @@ LRESULT Notepad_plus::init(HWND hwnd)
|
||||
|
||||
// Find the first separator which is between IDM_LANG_TEXT and languages
|
||||
int x = 0;
|
||||
MENUITEMINFO menuItemInfo
|
||||
{
|
||||
.cbSize = sizeof(MENUITEMINFO),
|
||||
.fMask = MIIM_FTYPE
|
||||
};
|
||||
MENUITEMINFO menuItemInfo{};
|
||||
menuItemInfo.cbSize = sizeof(MENUITEMINFO);
|
||||
menuItemInfo.fMask = MIIM_FTYPE;
|
||||
|
||||
for (; x < nbItem; ++x)
|
||||
{
|
||||
::GetMenuItemInfo(subMenu, x, TRUE, &menuItemInfo);
|
||||
|
@ -33,7 +33,9 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifndef WM_DPICHANGED
|
||||
#define WM_DPICHANGED 0x02E0
|
||||
#endif
|
||||
|
||||
|
||||
struct SortTaskListPred final
|
||||
@ -374,8 +376,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
case NPPM_LAUNCHFINDINFILESDLG:
|
||||
{
|
||||
// Find in files function code should be here due to the number of parameters (2) cannot be passed via WM_COMMAND
|
||||
const int strSize = FINDREPLACE_MAXLENGTH;
|
||||
TCHAR str[strSize];
|
||||
constexpr int strSize = FINDREPLACE_MAXLENGTH;
|
||||
TCHAR str[strSize]{};
|
||||
|
||||
bool isFirstTime = !_findReplaceDlg.isCreated();
|
||||
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL());
|
||||
@ -397,8 +399,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case NPPM_INTERNAL_FINDINPROJECTS:
|
||||
{
|
||||
const int strSize = FINDREPLACE_MAXLENGTH;
|
||||
TCHAR str[strSize];
|
||||
constexpr int strSize = FINDREPLACE_MAXLENGTH;
|
||||
TCHAR str[strSize]{};
|
||||
|
||||
bool isFirstTime = not _findReplaceDlg.isCreated();
|
||||
_findReplaceDlg.doDialog(FIND_DLG, _nativeLangSpeaker.isRTL());
|
||||
@ -414,8 +416,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case NPPM_INTERNAL_FINDINFINDERDLG:
|
||||
{
|
||||
const int strSize = FINDREPLACE_MAXLENGTH;
|
||||
TCHAR str[strSize];
|
||||
constexpr int strSize = FINDREPLACE_MAXLENGTH;
|
||||
TCHAR str[strSize]{};
|
||||
Finder *launcher = reinterpret_cast<Finder *>(wParam);
|
||||
|
||||
bool isFirstTime = !_findInFinderDlg.isCreated();
|
||||
@ -558,7 +560,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case NPPM_RELOADFILE:
|
||||
{
|
||||
TCHAR longNameFullpath[MAX_PATH];
|
||||
TCHAR longNameFullpath[MAX_PATH]{};
|
||||
const TCHAR* pFilePath = reinterpret_cast<const TCHAR*>(lParam);
|
||||
wcscpy_s(longNameFullpath, MAX_PATH, pFilePath);
|
||||
if (wcschr(longNameFullpath, '~'))
|
||||
@ -949,12 +951,12 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case NPPM_GETFILENAMEATCURSOR: // wParam = buffer length, lParam = (TCHAR*)buffer
|
||||
{
|
||||
const int strSize = CURRENTWORD_MAXLENGTH;
|
||||
TCHAR str[strSize];
|
||||
TCHAR strLine[strSize];
|
||||
size_t lineNumber;
|
||||
intptr_t col;
|
||||
int hasSlash;
|
||||
constexpr int strSize = CURRENTWORD_MAXLENGTH;
|
||||
TCHAR str[strSize]{};
|
||||
TCHAR strLine[strSize]{};
|
||||
size_t lineNumber = 0;
|
||||
intptr_t col = 0;
|
||||
int hasSlash = 0;
|
||||
TCHAR *pTchar = reinterpret_cast<TCHAR *>(lParam);
|
||||
|
||||
_pEditView->getGenericSelectedText(str, strSize); // this is either the selected text, or the word under the cursor if there is no selection
|
||||
@ -966,8 +968,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
if (hasSlash == FALSE)
|
||||
{
|
||||
// it's not a full file name so try to find the beginning and ending of it
|
||||
intptr_t start;
|
||||
intptr_t end;
|
||||
intptr_t start = 0;
|
||||
intptr_t end = 0;
|
||||
const TCHAR *delimiters;
|
||||
|
||||
lineNumber = _pEditView->getCurrentLineNumber();
|
||||
@ -1004,8 +1006,8 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
case NPPM_GETNPPFULLFILEPATH:
|
||||
case NPPM_GETNPPDIRECTORY:
|
||||
{
|
||||
const int strSize = MAX_PATH;
|
||||
TCHAR str[strSize];
|
||||
constexpr int strSize = MAX_PATH;
|
||||
TCHAR str[strSize]{};
|
||||
|
||||
::GetModuleFileName(NULL, str, strSize);
|
||||
|
||||
@ -1222,7 +1224,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
case NPPM_DECODESCI:
|
||||
{
|
||||
// convert to ASCII
|
||||
ScintillaEditView *pSci;
|
||||
ScintillaEditView *pSci = nullptr;
|
||||
if (wParam == MAIN_VIEW)
|
||||
pSci = &_mainEditView;
|
||||
else if (wParam == SUB_VIEW)
|
||||
@ -1260,7 +1262,7 @@ LRESULT Notepad_plus::process(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
|
||||
case NPPM_ENCODESCI:
|
||||
{
|
||||
// convert
|
||||
ScintillaEditView *pSci;
|
||||
ScintillaEditView *pSci = nullptr;
|
||||
if (wParam == MAIN_VIEW)
|
||||
pSci = &_mainEditView;
|
||||
else if (wParam == SUB_VIEW)
|
||||
|
@ -41,7 +41,7 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
|
||||
const TCHAR *fullFileName = (const TCHAR *)buf->getFullPathName();
|
||||
|
||||
//The folder to watch :
|
||||
WCHAR folderToMonitor[MAX_PATH];
|
||||
WCHAR folderToMonitor[MAX_PATH]{};
|
||||
wcscpy_s(folderToMonitor, fullFileName);
|
||||
|
||||
::PathRemoveFileSpecW(folderToMonitor);
|
||||
@ -74,7 +74,7 @@ DWORD WINAPI Notepad_plus::monitorFileOnChange(void * params)
|
||||
case WAIT_OBJECT_0 + 1:
|
||||
// We've received a notification in the queue.
|
||||
{
|
||||
DWORD dwAction;
|
||||
DWORD dwAction = 0;
|
||||
generic_string fn;
|
||||
// Process all available changes, ignore User actions
|
||||
while (dirChanges.Pop(dwAction, fn))
|
||||
@ -125,9 +125,9 @@ bool resolveLinkFile(generic_string& linkFilePath)
|
||||
{
|
||||
bool isResolved = false;
|
||||
|
||||
IShellLink* psl;
|
||||
WCHAR targetFilePath[MAX_PATH];
|
||||
WIN32_FIND_DATA wfd = {};
|
||||
IShellLink* psl = nullptr;
|
||||
WCHAR targetFilePath[MAX_PATH]{};
|
||||
WIN32_FIND_DATA wfd{};
|
||||
|
||||
HRESULT hres = CoInitialize(NULL);
|
||||
if (SUCCEEDED(hres))
|
||||
@ -135,7 +135,7 @@ bool resolveLinkFile(generic_string& linkFilePath)
|
||||
hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&psl);
|
||||
if (SUCCEEDED(hres))
|
||||
{
|
||||
IPersistFile* ppf;
|
||||
IPersistFile* ppf = nullptr;
|
||||
hres = psl->QueryInterface(IID_IPersistFile, (void**)&ppf);
|
||||
if (SUCCEEDED(hres))
|
||||
{
|
||||
@ -661,7 +661,7 @@ bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
|
||||
|
||||
if (openInAdminModeRes == IDYES)
|
||||
{
|
||||
TCHAR nppFullPath[MAX_PATH];
|
||||
TCHAR nppFullPath[MAX_PATH]{};
|
||||
::GetModuleFileName(NULL, nppFullPath, MAX_PATH);
|
||||
|
||||
generic_string args = TEXT("-multiInst");
|
||||
@ -696,7 +696,7 @@ bool Notepad_plus::doSave(BufferID id, const TCHAR * filename, bool isCopy)
|
||||
|
||||
if (openInAdminModeRes == IDYES)
|
||||
{
|
||||
TCHAR nppFullPath[MAX_PATH];
|
||||
TCHAR nppFullPath[MAX_PATH]{};
|
||||
::GetModuleFileName(NULL, nppFullPath, MAX_PATH);
|
||||
|
||||
BufferID bufferID = _pEditView->getCurrentBufferID();
|
||||
@ -1612,8 +1612,8 @@ bool Notepad_plus::fileSave(BufferID id)
|
||||
}
|
||||
else if (backup == bak_verbose)
|
||||
{
|
||||
const int temBufLen = 32;
|
||||
TCHAR tmpbuf[temBufLen];
|
||||
constexpr int temBufLen = 32;
|
||||
TCHAR tmpbuf[temBufLen]{};
|
||||
time_t ltime = time(0);
|
||||
struct tm *today;
|
||||
|
||||
@ -2412,7 +2412,7 @@ bool Notepad_plus::fileLoadSession(const TCHAR *fn)
|
||||
}
|
||||
if (!isEmptyNpp && (nppGUI._multiInstSetting == multiInstOnSession || nppGUI._multiInstSetting == multiInst))
|
||||
{
|
||||
TCHAR nppFullPath[MAX_PATH];
|
||||
TCHAR nppFullPath[MAX_PATH]{};
|
||||
::GetModuleFileName(NULL, nppFullPath, MAX_PATH);
|
||||
|
||||
|
||||
|
@ -38,29 +38,29 @@ public:
|
||||
_ppEditView = ppEditView;
|
||||
};
|
||||
|
||||
void setParent(HWND parent2set){
|
||||
_hParent = parent2set;
|
||||
};
|
||||
void setParent(HWND parent2set){
|
||||
_hParent = parent2set;
|
||||
};
|
||||
|
||||
void switchEncoding();
|
||||
void insertChar(unsigned char char2insert) const;
|
||||
void insertString(LPWSTR string2insert) const;
|
||||
|
||||
virtual void setBackgroundColor(int bgColour) const {
|
||||
void setBackgroundColor(COLORREF bgColour) override {
|
||||
ListView_SetBkColor(_listView.getHSelf(), bgColour);
|
||||
ListView_SetTextBkColor(_listView.getHSelf(), bgColour);
|
||||
_listView.redraw(true);
|
||||
};
|
||||
virtual void setForegroundColor(int fgColour) const {
|
||||
};
|
||||
|
||||
void setForegroundColor(COLORREF fgColour) override {
|
||||
ListView_SetTextColor(_listView.getHSelf(), fgColour);
|
||||
_listView.redraw(true);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
protected:
|
||||
virtual intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam);
|
||||
intptr_t CALLBACK run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
|
||||
|
||||
private:
|
||||
ScintillaEditView **_ppEditView = nullptr;
|
||||
AsciiListView _listView;
|
||||
};
|
||||
|
||||
|
@ -121,22 +121,22 @@ private:
|
||||
DockingCont *_pCont = nullptr;
|
||||
|
||||
// mouse offset in moving rectangle
|
||||
POINT _ptOffset = {};
|
||||
POINT _ptOffset{};
|
||||
|
||||
// remembers old mouse point
|
||||
POINT _ptOld = {};
|
||||
POINT _ptOld{};
|
||||
BOOL _bPtOldValid = FALSE;
|
||||
|
||||
// remember last drawn rectangle (jg)
|
||||
RECT _rcPrev = {};
|
||||
RECT _rcPrev{};
|
||||
|
||||
// for sorting tabs
|
||||
HWND _hTab = nullptr;
|
||||
HWND _hTabSource = nullptr;
|
||||
BOOL _startMovingFromTab = FALSE;
|
||||
int _iItem = 0;
|
||||
RECT _rcItem = {};
|
||||
TCITEM _tcItem;
|
||||
RECT _rcItem{};
|
||||
TCITEM _tcItem{};
|
||||
|
||||
HDC _hdc = nullptr;
|
||||
HBITMAP _hbm = nullptr;
|
||||
|
@ -3255,11 +3255,9 @@ intptr_t CALLBACK LanguageSubDlg::run_dlgProc(UINT message, WPARAM wParam, LPARA
|
||||
// Find the first separator which is between IDM_LANG_TEXT and languages
|
||||
int nbItem = ::GetMenuItemCount(subMenu);
|
||||
int x = 0;
|
||||
MENUITEMINFO menuItemInfo
|
||||
{
|
||||
.cbSize = sizeof(MENUITEMINFO),
|
||||
.fMask = MIIM_FTYPE
|
||||
};
|
||||
MENUITEMINFO menuItemInfo{};
|
||||
menuItemInfo.cbSize = sizeof(MENUITEMINFO);
|
||||
menuItemInfo.fMask = MIIM_FTYPE;
|
||||
for (; x < nbItem; ++x)
|
||||
{
|
||||
::GetMenuItemInfo(subMenu, x, TRUE, &menuItemInfo);
|
||||
|
@ -73,7 +73,7 @@ LRESULT TreeView::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
// with the TVE_COLLAPSE and TVE_COLLAPSERESET flags set.
|
||||
// That in turn removes child items which is unwanted.
|
||||
// Below is a workaround for that.
|
||||
TVITEM tvItem = {};
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = reinterpret_cast<HTREEITEM>(lParam);
|
||||
tvItem.mask = TVIF_STATE | TVIF_HANDLE | TVIF_PARAM;
|
||||
tvItem.stateMask = TVIS_EXPANDEDONCE;
|
||||
@ -83,7 +83,7 @@ LRESULT TreeView::runProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// If the flag is set, then manually notify parent that an item is collapsed/expanded
|
||||
// so that it can change icon, etc.
|
||||
NMTREEVIEW nmtv = {};
|
||||
NMTREEVIEW nmtv{};
|
||||
nmtv.hdr.code = TVN_ITEMEXPANDED;
|
||||
nmtv.hdr.hwndFrom = _hSelf;
|
||||
nmtv.hdr.idFrom = 0;
|
||||
@ -112,7 +112,7 @@ bool TreeView::setItemParam(HTREEITEM Item2Set, LPARAM param)
|
||||
if (!Item2Set)
|
||||
return false;
|
||||
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = Item2Set;
|
||||
tvItem.mask = TVIF_PARAM;
|
||||
tvItem.lParam = param;
|
||||
@ -126,7 +126,7 @@ LPARAM TreeView::getItemParam(HTREEITEM Item2Get) const
|
||||
if (!Item2Get)
|
||||
return false;
|
||||
//TCHAR textBuffer[MAX_PATH];
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = Item2Get;
|
||||
tvItem.mask = TVIF_PARAM;
|
||||
//tvItem.pszText = textBuffer;
|
||||
@ -140,7 +140,7 @@ generic_string TreeView::getItemDisplayName(HTREEITEM Item2Set) const
|
||||
if (!Item2Set)
|
||||
return TEXT("");
|
||||
TCHAR textBuffer[MAX_PATH] = { '\0' };
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = Item2Set;
|
||||
tvItem.mask = TVIF_TEXT;
|
||||
tvItem.pszText = textBuffer;
|
||||
@ -154,7 +154,7 @@ bool TreeView::renameItem(HTREEITEM Item2Set, const TCHAR *newName)
|
||||
if (!Item2Set || !newName)
|
||||
return false;
|
||||
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = Item2Set;
|
||||
tvItem.mask = TVIF_TEXT;
|
||||
tvItem.pszText = (LPWSTR)newName;
|
||||
@ -165,7 +165,7 @@ bool TreeView::renameItem(HTREEITEM Item2Set, const TCHAR *newName)
|
||||
|
||||
HTREEITEM TreeView::addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iImage, LPARAM lParam)
|
||||
{
|
||||
TVITEM tvi;
|
||||
TVITEM tvi{};
|
||||
tvi.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
|
||||
|
||||
// Set the item label.
|
||||
@ -178,7 +178,7 @@ HTREEITEM TreeView::addItem(const TCHAR *itemName, HTREEITEM hParentItem, int iI
|
||||
|
||||
tvi.lParam = lParam;
|
||||
|
||||
TVINSERTSTRUCT tvInsertStruct;
|
||||
TVINSERTSTRUCT tvInsertStruct{};
|
||||
tvInsertStruct.item = tvi;
|
||||
tvInsertStruct.hInsertAfter = TVI_LAST;
|
||||
tvInsertStruct.hParent = hParentItem;
|
||||
@ -192,7 +192,7 @@ void TreeView::removeItem(HTREEITEM hTreeItem)
|
||||
cleanSubEntries(hTreeItem);
|
||||
|
||||
// Deallocate current entry
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = hTreeItem;
|
||||
tvItem.mask = TVIF_PARAM;
|
||||
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
|
||||
@ -217,15 +217,15 @@ void TreeView::dupTree(HTREEITEM hTree2Dup, HTREEITEM hParentItem)
|
||||
{
|
||||
for (HTREEITEM hItem = getChildFrom(hTree2Dup); hItem != NULL; hItem = getNextSibling(hItem))
|
||||
{
|
||||
TCHAR textBuffer[MAX_PATH];
|
||||
TVITEM tvItem;
|
||||
TCHAR textBuffer[MAX_PATH]{};
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = hItem;
|
||||
tvItem.pszText = textBuffer;
|
||||
tvItem.cchTextMax = MAX_PATH;
|
||||
tvItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||||
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
|
||||
|
||||
TVINSERTSTRUCT tvInsertStruct;
|
||||
TVINSERTSTRUCT tvInsertStruct{};
|
||||
tvInsertStruct.item = tvItem;
|
||||
tvInsertStruct.hInsertAfter = TVI_LAST;
|
||||
tvInsertStruct.hParent = hParentItem;
|
||||
@ -236,16 +236,16 @@ void TreeView::dupTree(HTREEITEM hTree2Dup, HTREEITEM hParentItem)
|
||||
|
||||
HTREEITEM TreeView::searchSubItemByName(const TCHAR *itemName, HTREEITEM hParentItem)
|
||||
{
|
||||
HTREEITEM hItem = NULL;
|
||||
if (hParentItem != NULL)
|
||||
HTREEITEM hItem = nullptr;
|
||||
if (hParentItem != nullptr)
|
||||
hItem = getChildFrom(hParentItem);
|
||||
else
|
||||
hItem = getRoot();
|
||||
|
||||
for ( ; hItem != NULL; hItem = getNextSibling(hItem))
|
||||
while (hItem != nullptr)
|
||||
{
|
||||
TCHAR textBuffer[MAX_PATH] = { '\0' };
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = hItem;
|
||||
tvItem.pszText = textBuffer;
|
||||
tvItem.cchTextMax = MAX_PATH;
|
||||
@ -256,8 +256,10 @@ HTREEITEM TreeView::searchSubItemByName(const TCHAR *itemName, HTREEITEM hParent
|
||||
{
|
||||
return hItem;
|
||||
}
|
||||
|
||||
hItem = getNextSibling(hItem);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BOOL TreeView::setImageList(int w, int h, int nbImage, int image_id, ...)
|
||||
@ -300,7 +302,7 @@ void TreeView::cleanSubEntries(HTREEITEM hTreeItem)
|
||||
{
|
||||
for (HTREEITEM hItem = getChildFrom(hTreeItem); hItem != NULL; hItem = getNextSibling(hItem))
|
||||
{
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = hItem;
|
||||
tvItem.mask = TVIF_PARAM;
|
||||
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
|
||||
@ -350,7 +352,7 @@ void TreeView::foldExpandAll(bool isFold) const
|
||||
|
||||
void TreeView::setItemImage(HTREEITEM hTreeItem, int iImage, int iSelectedImage)
|
||||
{
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = hTreeItem;
|
||||
tvItem.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||||
tvItem.iImage = iImage;
|
||||
@ -384,7 +386,7 @@ void TreeView::beginDrag(NMTREEVIEW* tv)
|
||||
void TreeView::dragItem(HWND parentHandle, int x, int y)
|
||||
{
|
||||
// convert the dialog coords to control coords
|
||||
POINT point;
|
||||
POINT point{};
|
||||
point.x = (SHORT)x;
|
||||
point.y = (SHORT)y;
|
||||
::ClientToScreen(parentHandle, &point);
|
||||
@ -398,7 +400,7 @@ void TreeView::dragItem(HWND parentHandle, int x, int y)
|
||||
|
||||
// find out if the pointer is on an item
|
||||
// If so, highlight the item as a drop target.
|
||||
TVHITTESTINFO hitTestInfo;
|
||||
TVHITTESTINFO hitTestInfo{};
|
||||
hitTestInfo.pt.x = point.x;
|
||||
hitTestInfo.pt.y = point.y;
|
||||
HTREEITEM targetItem = reinterpret_cast<HTREEITEM>(::SendMessage(_hSelf, TVM_HITTEST, 0, reinterpret_cast<LPARAM>(&hitTestInfo)));
|
||||
@ -486,15 +488,15 @@ bool TreeView::isParent(HTREEITEM targetItem, HTREEITEM draggedItem)
|
||||
|
||||
void TreeView::moveTreeViewItem(HTREEITEM draggedItem, HTREEITEM targetItem)
|
||||
{
|
||||
TCHAR textBuffer[MAX_PATH];
|
||||
TVITEM tvDraggingItem;
|
||||
TCHAR textBuffer[MAX_PATH]{};
|
||||
TVITEM tvDraggingItem{};
|
||||
tvDraggingItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||||
tvDraggingItem.pszText = textBuffer;
|
||||
tvDraggingItem.cchTextMax = MAX_PATH;
|
||||
tvDraggingItem.hItem = draggedItem;
|
||||
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvDraggingItem));
|
||||
|
||||
TVINSERTSTRUCT tvInsertStruct;
|
||||
TVINSERTSTRUCT tvInsertStruct{};
|
||||
tvInsertStruct.item = tvDraggingItem;
|
||||
tvInsertStruct.hInsertAfter = (HTREEITEM)TVI_LAST;
|
||||
tvInsertStruct.hParent = targetItem;
|
||||
@ -535,10 +537,10 @@ bool TreeView::swapTreeViewItem(HTREEITEM itemGoDown, HTREEITEM itemGoUp)
|
||||
return false;
|
||||
|
||||
// get both item infos
|
||||
TCHAR textBufferUp[MAX_PATH];
|
||||
TCHAR textBufferDown[MAX_PATH];
|
||||
TVITEM tvUpItem;
|
||||
TVITEM tvDownItem;
|
||||
TCHAR textBufferUp[MAX_PATH]{};
|
||||
TCHAR textBufferDown[MAX_PATH]{};
|
||||
TVITEM tvUpItem{};
|
||||
TVITEM tvDownItem{};
|
||||
tvUpItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||||
tvDownItem.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
|
||||
tvUpItem.pszText = textBufferUp;
|
||||
@ -551,14 +553,14 @@ bool TreeView::swapTreeViewItem(HTREEITEM itemGoDown, HTREEITEM itemGoUp)
|
||||
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvDownItem));
|
||||
|
||||
// add 2 new items
|
||||
TVINSERTSTRUCT tvInsertUp;
|
||||
TVINSERTSTRUCT tvInsertUp{};
|
||||
tvInsertUp.item = tvUpItem;
|
||||
tvInsertUp.hInsertAfter = itemTop;
|
||||
tvInsertUp.hParent = parentGoUp;
|
||||
HTREEITEM hTreeParent1stInserted = reinterpret_cast<HTREEITEM>(::SendMessage(_hSelf, TVM_INSERTITEM, 0, reinterpret_cast<LPARAM>(&tvInsertUp)));
|
||||
dupTree(itemGoUp, hTreeParent1stInserted);
|
||||
|
||||
TVINSERTSTRUCT tvInsertDown;
|
||||
TVINSERTSTRUCT tvInsertDown{};
|
||||
tvInsertDown.item = tvDownItem;
|
||||
tvInsertDown.hInsertAfter = hTreeParent1stInserted;
|
||||
tvInsertDown.hParent = parentGoDown;
|
||||
@ -587,7 +589,7 @@ bool TreeView::swapTreeViewItem(HTREEITEM itemGoDown, HTREEITEM itemGoUp)
|
||||
|
||||
bool TreeView::canDropIn(HTREEITEM targetItem)
|
||||
{
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.mask = TVIF_IMAGE;
|
||||
tvItem.hItem = targetItem;
|
||||
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
|
||||
@ -603,7 +605,7 @@ bool TreeView::canDropIn(HTREEITEM targetItem)
|
||||
|
||||
bool TreeView::canDragOut(HTREEITEM targetItem)
|
||||
{
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.mask = TVIF_IMAGE;
|
||||
tvItem.hItem = targetItem;
|
||||
SendMessage(_hSelf, TVM_GETITEM, 0, reinterpret_cast<LPARAM>(&tvItem));
|
||||
@ -632,7 +634,7 @@ bool TreeView::searchLeafRecusivelyAndBuildTree(HTREEITEM tree2Build, const gene
|
||||
return false;
|
||||
|
||||
TCHAR textBuffer[MAX_PATH] = { '\0' };
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = tree2Search;
|
||||
tvItem.pszText = textBuffer;
|
||||
tvItem.cchTextMax = MAX_PATH;
|
||||
@ -647,7 +649,7 @@ bool TreeView::searchLeafRecusivelyAndBuildTree(HTREEITEM tree2Build, const gene
|
||||
size_t res = itemNameUpperCase.find(text2SearchUpperCase);
|
||||
if (res != generic_string::npos)
|
||||
{
|
||||
TVINSERTSTRUCT tvInsertStruct;
|
||||
TVINSERTSTRUCT tvInsertStruct{};
|
||||
tvInsertStruct.item = tvItem;
|
||||
tvInsertStruct.hInsertAfter = TVI_LAST;
|
||||
tvInsertStruct.hParent = tree2Build;
|
||||
@ -674,7 +676,7 @@ bool TreeView::retrieveFoldingStateTo(TreeStateNode & treeState2Construct, HTREE
|
||||
return false;
|
||||
|
||||
TCHAR textBuffer[MAX_PATH] = { '\0' };
|
||||
TVITEM tvItem;
|
||||
TVITEM tvItem{};
|
||||
tvItem.hItem = treeviewNode;
|
||||
tvItem.pszText = textBuffer;
|
||||
tvItem.cchTextMax = MAX_PATH;
|
||||
@ -740,7 +742,7 @@ void TreeView::sort(HTREEITEM hTreeItem, bool isRecusive)
|
||||
|
||||
void TreeView::customSorting(HTREEITEM hTreeItem, PFNTVCOMPARE sortingCallbackFunc, LPARAM lParam, bool isRecusive)
|
||||
{
|
||||
TVSORTCB treeViewSortCB;
|
||||
TVSORTCB treeViewSortCB{};
|
||||
treeViewSortCB.hParent = hTreeItem;
|
||||
treeViewSortCB.lpfnCompare = sortingCallbackFunc;
|
||||
treeViewSortCB.lParam = lParam;
|
||||
|
Loading…
x
Reference in New Issue
Block a user