mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-23 05:45:00 +02:00
Fix warnings in WindowsDlg.cpp, .h files
And add initializers. Fix #13542, close #13543
This commit is contained in:
parent
de618df55f
commit
59c8689ff4
@ -91,8 +91,8 @@ struct NumericStringEquivalence
|
|||||||
|
|
||||||
static int numstrcmp(const TCHAR *str1, const TCHAR *str2)
|
static int numstrcmp(const TCHAR *str1, const TCHAR *str2)
|
||||||
{
|
{
|
||||||
TCHAR *p1, *p2;
|
TCHAR *p1 = nullptr, *p2 = nullptr;
|
||||||
int c1, c2, lcmp = 0;
|
int c1 = 0, c2 = 0, lcmp = 0;
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (*str1 == 0 || *str2 == 0)
|
if (*str1 == 0 || *str2 == 0)
|
||||||
@ -132,10 +132,10 @@ struct NumericStringEquivalence
|
|||||||
|
|
||||||
struct BufferEquivalent
|
struct BufferEquivalent
|
||||||
{
|
{
|
||||||
NumericStringEquivalence _strequiv;
|
NumericStringEquivalence _strequiv{};
|
||||||
DocTabView* _pTab;
|
DocTabView* _pTab = nullptr;
|
||||||
int _iColumn;
|
int _iColumn = 0;
|
||||||
bool _reverse;
|
bool _reverse = false;
|
||||||
BufferEquivalent(DocTabView* pTab, int iColumn, bool reverse)
|
BufferEquivalent(DocTabView* pTab, int iColumn, bool reverse)
|
||||||
: _pTab(pTab), _iColumn(iColumn), _reverse(reverse)
|
: _pTab(pTab), _iColumn(iColumn), _reverse(reverse)
|
||||||
{}
|
{}
|
||||||
@ -220,7 +220,6 @@ BEGIN_WINDOW_MAP(WindowsDlgMap)
|
|||||||
BEGINCOLS(WRCT_REST,0,0) // Begin list control column
|
BEGINCOLS(WRCT_REST,0,0) // Begin list control column
|
||||||
BEGINROWS(WRCT_REST,0,0)
|
BEGINROWS(WRCT_REST,0,0)
|
||||||
RCREST(IDC_WINDOWS_LIST)
|
RCREST(IDC_WINDOWS_LIST)
|
||||||
RCSPACE(20)
|
|
||||||
ENDGROUP()
|
ENDGROUP()
|
||||||
RCSPACE(12)
|
RCSPACE(12)
|
||||||
BEGINROWS(WRCT_TOFIT,0,0)
|
BEGINROWS(WRCT_TOFIT,0,0)
|
||||||
@ -277,13 +276,9 @@ intptr_t CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
|
|
||||||
case WM_CTLCOLORDLG:
|
case WM_CTLCOLORDLG:
|
||||||
case WM_CTLCOLORSTATIC:
|
case WM_CTLCOLORSTATIC:
|
||||||
{
|
|
||||||
if (NppDarkMode::isEnabled())
|
|
||||||
{
|
{
|
||||||
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
return NppDarkMode::onCtlColorDarker(reinterpret_cast<HDC>(wParam));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case WM_PRINTCLIENT:
|
case WM_PRINTCLIENT:
|
||||||
{
|
{
|
||||||
@ -506,7 +501,7 @@ intptr_t CALLBACK WindowsDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
|
|||||||
_listMenu.enableItem(IDM_WINDOW_COPY_NAME, enableMenu);
|
_listMenu.enableItem(IDM_WINDOW_COPY_NAME, enableMenu);
|
||||||
_listMenu.enableItem(IDM_WINDOW_COPY_PATH, enableMenu);
|
_listMenu.enableItem(IDM_WINDOW_COPY_PATH, enableMenu);
|
||||||
|
|
||||||
POINT p = {};
|
POINT p{};
|
||||||
::GetCursorPos(&p);
|
::GetCursorPos(&p);
|
||||||
_listMenu.display(p);
|
_listMenu.display(p);
|
||||||
}
|
}
|
||||||
@ -520,11 +515,11 @@ void WindowsDlg::doColumnSort()
|
|||||||
if (_currentColumn == -1)
|
if (_currentColumn == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size_t i;
|
size_t i = 0;
|
||||||
size_t n = _idxMap.size();
|
size_t n = _idxMap.size();
|
||||||
vector<int> sortMap;
|
vector<int> sortMap;
|
||||||
sortMap.resize(n);
|
sortMap.resize(n);
|
||||||
for (i = 0; i < n; ++i)
|
for (; i < n; ++i)
|
||||||
sortMap[_idxMap[i]] = ListView_GetItemState(_hList, i, LVIS_SELECTED);
|
sortMap[_idxMap[i]] = ListView_GetItemState(_hList, i, LVIS_SELECTED);
|
||||||
|
|
||||||
stable_sort(_idxMap.begin(), _idxMap.end(), BufferEquivalent(_pTab, _currentColumn, _reverseSort));
|
stable_sort(_idxMap.begin(), _idxMap.end(), BufferEquivalent(_pTab, _currentColumn, _reverseSort));
|
||||||
@ -589,12 +584,11 @@ BOOL WindowsDlg::onInitDialog()
|
|||||||
ListView_SetTextBkColor(_hList, bgColor);
|
ListView_SetTextBkColor(_hList, bgColor);
|
||||||
ListView_SetTextColor(_hList, fgColor);
|
ListView_SetTextColor(_hList, fgColor);
|
||||||
|
|
||||||
RECT rc;
|
RECT rc{};
|
||||||
GetClientRect(_hList, &rc);
|
GetClientRect(_hList, &rc);
|
||||||
LONG width = rc.right - rc.left;
|
LONG width = rc.right - rc.left;
|
||||||
|
|
||||||
LVCOLUMN lvColumn;
|
LVCOLUMN lvColumn{};
|
||||||
memset(&lvColumn, 0, sizeof(lvColumn));
|
|
||||||
lvColumn.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
|
lvColumn.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
|
||||||
lvColumn.fmt = LVCFMT_LEFT;
|
lvColumn.fmt = LVCFMT_LEFT;
|
||||||
|
|
||||||
@ -640,8 +634,7 @@ BOOL WindowsDlg::onInitDialog()
|
|||||||
|
|
||||||
void WindowsDlg::updateColumnNames()
|
void WindowsDlg::updateColumnNames()
|
||||||
{
|
{
|
||||||
LVCOLUMN lvColumn;
|
LVCOLUMN lvColumn{};
|
||||||
memset(&lvColumn, 0, sizeof(lvColumn));
|
|
||||||
lvColumn.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
|
lvColumn.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
|
||||||
lvColumn.fmt = LVCFMT_LEFT;
|
lvColumn.fmt = LVCFMT_LEFT;
|
||||||
|
|
||||||
@ -787,7 +780,7 @@ void WindowsDlg::doRefresh(bool invalidate /*= false*/)
|
|||||||
void WindowsDlg::fitColumnsToSize()
|
void WindowsDlg::fitColumnsToSize()
|
||||||
{
|
{
|
||||||
// perhaps make the path column auto size
|
// perhaps make the path column auto size
|
||||||
RECT rc;
|
RECT rc{};
|
||||||
if (GetClientRect(_hList, &rc))
|
if (GetClientRect(_hList, &rc))
|
||||||
{
|
{
|
||||||
int len = (rc.right - rc.left);
|
int len = (rc.right - rc.left);
|
||||||
@ -821,14 +814,16 @@ void WindowsDlg::resetSelection()
|
|||||||
|
|
||||||
void WindowsDlg::doSave()
|
void WindowsDlg::doSave()
|
||||||
{
|
{
|
||||||
NMWINDLG nmdlg;
|
NMWINDLG nmdlg{};
|
||||||
nmdlg.type = WDT_SAVE;
|
nmdlg.type = WDT_SAVE;
|
||||||
nmdlg.curSel = ListView_GetNextItem(_hList, -1, LVNI_SELECTED);
|
nmdlg.curSel = ListView_GetNextItem(_hList, -1, LVNI_SELECTED);
|
||||||
nmdlg.hwndFrom = _hSelf;
|
nmdlg.hwndFrom = _hSelf;
|
||||||
nmdlg.code = WDN_NOTIFY;
|
nmdlg.code = WDN_NOTIFY;
|
||||||
nmdlg.nItems = ListView_GetSelectedCount(_hList);
|
nmdlg.nItems = ListView_GetSelectedCount(_hList);
|
||||||
nmdlg.Items = new UINT[nmdlg.nItems];
|
nmdlg.Items = new UINT[nmdlg.nItems];
|
||||||
for (int i=-1, j=0; ; ++j)
|
|
||||||
|
int i = -1;
|
||||||
|
for (UINT j = 0; j < nmdlg.nItems; ++j)
|
||||||
{
|
{
|
||||||
i = ListView_GetNextItem(_hList, i, LVNI_SELECTED);
|
i = ListView_GetNextItem(_hList, i, LVNI_SELECTED);
|
||||||
if (i == -1) break;
|
if (i == -1) break;
|
||||||
@ -853,7 +848,7 @@ void WindowsDlg::activateCurrent()
|
|||||||
{
|
{
|
||||||
if (ListView_GetSelectedCount(_hList) == 1)
|
if (ListView_GetSelectedCount(_hList) == 1)
|
||||||
{
|
{
|
||||||
NMWINDLG nmdlg;
|
NMWINDLG nmdlg{};
|
||||||
nmdlg.type = WDT_ACTIVATE;
|
nmdlg.type = WDT_ACTIVATE;
|
||||||
nmdlg.curSel = _idxMap[ListView_GetNextItem(_hList, -1, LVNI_ALL|LVNI_SELECTED)];
|
nmdlg.curSel = _idxMap[ListView_GetNextItem(_hList, -1, LVNI_ALL|LVNI_SELECTED)];
|
||||||
nmdlg.hwndFrom = _hSelf;
|
nmdlg.hwndFrom = _hSelf;
|
||||||
@ -867,7 +862,7 @@ void WindowsDlg::activateCurrent()
|
|||||||
|
|
||||||
void WindowsDlg::doClose()
|
void WindowsDlg::doClose()
|
||||||
{
|
{
|
||||||
NMWINDLG nmdlg;
|
NMWINDLG nmdlg{};
|
||||||
nmdlg.type = WDT_CLOSE;
|
nmdlg.type = WDT_CLOSE;
|
||||||
int index = ListView_GetNextItem(_hList, -1, LVNI_ALL|LVNI_SELECTED);
|
int index = ListView_GetNextItem(_hList, -1, LVNI_ALL|LVNI_SELECTED);
|
||||||
if (index == -1) return;
|
if (index == -1) return;
|
||||||
@ -879,7 +874,9 @@ void WindowsDlg::doClose()
|
|||||||
nmdlg.Items = new UINT[nmdlg.nItems];
|
nmdlg.Items = new UINT[nmdlg.nItems];
|
||||||
vector<int> key;
|
vector<int> key;
|
||||||
key.resize(n, 0x7fffffff);
|
key.resize(n, 0x7fffffff);
|
||||||
for (int i=-1, j=0; ; ++j)
|
|
||||||
|
int i = -1;
|
||||||
|
for (UINT j = 0; j < n; ++j)
|
||||||
{
|
{
|
||||||
i = ListView_GetNextItem(_hList, i, LVNI_SELECTED);
|
i = ListView_GetNextItem(_hList, i, LVNI_SELECTED);
|
||||||
if (i == -1) break;
|
if (i == -1) break;
|
||||||
@ -949,7 +946,7 @@ void WindowsDlg::doSort()
|
|||||||
size_t count = _pTab->nbItem();
|
size_t count = _pTab->nbItem();
|
||||||
std::vector<UINT> items(count);
|
std::vector<UINT> items(count);
|
||||||
auto currrentTabIndex = _pTab->getCurrentTabIndex();
|
auto currrentTabIndex = _pTab->getCurrentTabIndex();
|
||||||
NMWINDLG nmdlg = {};
|
NMWINDLG nmdlg{};
|
||||||
nmdlg.type = WDT_SORT;
|
nmdlg.type = WDT_SORT;
|
||||||
nmdlg.hwndFrom = _hSelf;
|
nmdlg.hwndFrom = _hSelf;
|
||||||
nmdlg.curSel = currrentTabIndex;
|
nmdlg.curSel = currrentTabIndex;
|
||||||
@ -1055,7 +1052,7 @@ void WindowsDlg::doSortToTabs()
|
|||||||
if (curSel == -1)
|
if (curSel == -1)
|
||||||
curSel = 0;
|
curSel = 0;
|
||||||
|
|
||||||
NMWINDLG nmdlg;
|
NMWINDLG nmdlg{};
|
||||||
nmdlg.type = WDT_SORT;
|
nmdlg.type = WDT_SORT;
|
||||||
nmdlg.hwndFrom = _hSelf;
|
nmdlg.hwndFrom = _hSelf;
|
||||||
nmdlg.curSel = _idxMap[curSel];
|
nmdlg.curSel = _idxMap[curSel];
|
||||||
@ -1063,7 +1060,8 @@ void WindowsDlg::doSortToTabs()
|
|||||||
nmdlg.nItems = ListView_GetItemCount(_hList);
|
nmdlg.nItems = ListView_GetItemCount(_hList);
|
||||||
nmdlg.Items = new UINT[nmdlg.nItems];
|
nmdlg.Items = new UINT[nmdlg.nItems];
|
||||||
|
|
||||||
for (int i=-1, j=0; ; ++j)
|
int i = -1;
|
||||||
|
for (UINT j = 0; j < nmdlg.nItems; ++j)
|
||||||
{
|
{
|
||||||
i = ListView_GetNextItem(_hList, i, LVNI_ALL);
|
i = ListView_GetNextItem(_hList, i, LVNI_ALL);
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
@ -1085,15 +1083,15 @@ void WindowsDlg::doSortToTabs()
|
|||||||
void WindowsDlg::putItemsToClipboard(bool isFullPath)
|
void WindowsDlg::putItemsToClipboard(bool isFullPath)
|
||||||
{
|
{
|
||||||
std::vector<Buffer*> buffers;
|
std::vector<Buffer*> buffers;
|
||||||
for (int i = -1, j = 0; ; ++j)
|
int i = -1;
|
||||||
|
do
|
||||||
{
|
{
|
||||||
i = ListView_GetNextItem(_hList, i, LVNI_SELECTED);
|
i = ListView_GetNextItem(_hList, i, LVNI_SELECTED);
|
||||||
if (i < 0)
|
|
||||||
break;
|
|
||||||
// Get the file name.
|
// Get the file name.
|
||||||
// Do not use ListView_GetItemText() because 1st column may contain "*" or "[Read Only]".
|
// Do not use ListView_GetItemText() because 1st column may contain "*" or "[Read Only]".
|
||||||
buffers.push_back(getBuffer(i));
|
buffers.push_back(getBuffer(i));
|
||||||
}
|
}
|
||||||
|
while (i >= 0);
|
||||||
|
|
||||||
buf2Clipborad(buffers, isFullPath, _hList);
|
buf2Clipborad(buffers, isFullPath, _hList);
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "SizeableDlg.h"
|
#include "SizeableDlg.h"
|
||||||
#include "Common.h"
|
|
||||||
#include "ContextMenu.h"
|
#include "ContextMenu.h"
|
||||||
|
|
||||||
class DocTabView;
|
class DocTabView;
|
||||||
@ -69,12 +68,12 @@ public :
|
|||||||
void doRefresh(bool invalidate = false);
|
void doRefresh(bool invalidate = false);
|
||||||
|
|
||||||
protected :
|
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;
|
||||||
virtual BOOL onInitDialog();
|
BOOL onInitDialog() override;
|
||||||
virtual void onSize(UINT nType, int cx, int cy);
|
void onSize(UINT nType, int cx, int cy) override;
|
||||||
virtual void onGetMinMaxInfo(MINMAXINFO* lpMMI);
|
void onGetMinMaxInfo(MINMAXINFO* lpMMI) override;
|
||||||
virtual LRESULT onWinMgr(WPARAM wp, LPARAM lp);
|
LRESULT onWinMgr(WPARAM wp, LPARAM lp) override;
|
||||||
virtual void destroy();
|
void destroy() override;
|
||||||
void updateColumnNames();
|
void updateColumnNames();
|
||||||
void fitColumnsToSize();
|
void fitColumnsToSize();
|
||||||
void resetSelection();
|
void resetSelection();
|
||||||
@ -90,8 +89,8 @@ protected :
|
|||||||
|
|
||||||
HWND _hList = nullptr;
|
HWND _hList = nullptr;
|
||||||
static RECT _lastKnownLocation;
|
static RECT _lastKnownLocation;
|
||||||
SIZE _szMinButton = {};
|
SIZE _szMinButton{};
|
||||||
SIZE _szMinListCtrl = {};
|
SIZE _szMinListCtrl{};
|
||||||
DocTabView* _pTab = nullptr;
|
DocTabView* _pTab = nullptr;
|
||||||
std::vector<int> _idxMap;
|
std::vector<int> _idxMap;
|
||||||
int _currentColumn = -1;
|
int _currentColumn = -1;
|
||||||
@ -100,7 +99,7 @@ protected :
|
|||||||
ContextMenu _listMenu;
|
ContextMenu _listMenu;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void init(HINSTANCE hInst, HWND parent);
|
void init(HINSTANCE hInst, HWND parent) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WindowsMenu
|
class WindowsMenu
|
||||||
|
Loading…
x
Reference in New Issue
Block a user