This commit is contained in:
Igor Pavlov
2016-09-29 00:00:00 +00:00
committed by Kornel Lesiński
parent 1eddf527ca
commit 232ce79574
83 changed files with 1088 additions and 307 deletions

View File

@@ -43,7 +43,7 @@ CEnumFormatEtc::CEnumFormatEtc(const FORMATETC *pFormatEtc, ULONG numFormats)
m_Index = 0;
m_NumFormats = 0;
m_Formats = new FORMATETC[numFormats];
if (m_Formats)
// if (m_Formats)
{
m_NumFormats = numFormats;
for (ULONG i = 0; i < numFormats; i++)

View File

@@ -3,6 +3,7 @@
#include "StdAfx.h"
#include <Windowsx.h>
// #include <stdio.h>
#include "../../../Common/IntToString.h"
#include "../../../Common/StringConvert.h"
@@ -619,10 +620,47 @@ bool CPanel::OnNotifyReBar(LPNMHDR header, LRESULT & /* result */)
return false;
}
/*
UInt32 g_OnNotify = 0;
UInt32 g_LVIF_TEXT = 0;
UInt32 g_Time = 0;
void Print_OnNotify(const char *name)
{
char s[256];
DWORD tim = GetTickCount();
sprintf(s,
"Time = %7u ms, Notify = %9u, TEXT = %9u, %s",
tim - g_Time,
g_OnNotify,
g_LVIF_TEXT,
name);
g_Time = tim;
OutputDebugStringA(s);
g_OnNotify = 0;
g_LVIF_TEXT = 0;
}
*/
bool CPanel::OnNotify(UINT /* controlID */, LPNMHDR header, LRESULT &result)
{
/*
g_OnNotify++;
if (header->hwndFrom == _listView)
{
if (header->code == LVN_GETDISPINFOW)
{
LV_DISPINFOW *dispInfo = (LV_DISPINFOW *)header;
if ((dispInfo->item.mask & LVIF_TEXT))
g_LVIF_TEXT++;
}
}
*/
if (!_processNotify)
return false;
if (header->hwndFrom == _headerComboBox)
return OnNotifyComboBox(header, result);
else if (header->hwndFrom == _headerReBar)

View File

@@ -361,6 +361,7 @@ public:
// CMyComboBox _headerComboBox;
CMyComboBoxEdit _comboBoxEdit;
CMyListView _listView;
bool _thereAre_ListView_Items;
NWindows::NControl::CStatusBar _statusBar;
bool _lastFocusedIsList;
// NWindows::NControl::CStatusBar _statusBar2;
@@ -380,6 +381,18 @@ public:
bool PanelCreated;
void DeleteListItems()
{
if (_thereAre_ListView_Items)
{
bool b = _enableItemChangeNotify;
_enableItemChangeNotify = false;
_listView.DeleteAllItems();
_thereAre_ListView_Items = false;
_enableItemChangeNotify = b;
}
}
HWND GetParent();
UInt32 GetRealIndex(const LVITEMW &item) const
@@ -502,6 +515,7 @@ public:
_flatModeForDisk(false),
_flatModeForArc(false),
PanelCreated(false),
_thereAre_ListView_Items(false),
// _showNtfsStrems_Mode(false),
// _showNtfsStrems_ModeForDisk(false),

View File

@@ -404,8 +404,11 @@ void CPanel::OnDrag(LPNMLISTVIEW /* nmListView */)
}
else
{
if (res != DRAGDROP_S_CANCEL && res != S_OK)
// we ignore E_UNEXPECTED that is returned if we drag file to printer
if (res != DRAGDROP_S_CANCEL && res != S_OK
&& res != E_UNEXPECTED)
MessageBoxError(res);
res = dropSourceSpec->Result;
}

View File

@@ -30,6 +30,8 @@ using namespace NFind;
void CPanel::ReleaseFolder()
{
DeleteListItems();
_folder.Release();
_folderCompare.Release();
@@ -175,15 +177,36 @@ HRESULT CPanel::BindToPath(const UString &fullPath, const UString &arcFormat, bo
}
else if (fileInfo.IsDir())
{
#ifdef _WIN32
if (DoesNameContainWildcard(sysPath))
{
FString dirPrefix, fileName;
NDir::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
if (DoesNameContainWildcard(dirPrefix))
return E_INVALIDARG;
sysPath = fs2us(dirPrefix + fileInfo.Name);
}
#endif
NName::NormalizeDirPathPrefix(sysPath);
_folder->BindToFolder(sysPath, &newFolder);
}
else
{
FString dirPrefix, fileName;
NDir::GetFullPathAndSplit(us2fs(sysPath), dirPrefix, fileName);
HRESULT res;
// = OpenAsArc(fs2us(fileName), arcFormat, encrypted);
HRESULT res = S_OK;
#ifdef _WIN32
if (DoesNameContainWildcard(dirPrefix))
return E_INVALIDARG;
if (DoesNameContainWildcard(fileName))
res = S_FALSE;
else
#endif
{
CTempFileInfo tfi;
tfi.RelPath = fs2us(fileName);
@@ -258,9 +281,9 @@ HRESULT CPanel::BindToPathAndRefresh(const UString &path)
CDisableTimerProcessing disableTimerProcessing(*this);
CDisableNotify disableNotify(*this);
bool archiveIsOpened, encrypted;
RINOK(BindToPath(path, UString(), archiveIsOpened, encrypted));
HRESULT res = BindToPath(path, UString(), archiveIsOpened, encrypted);
RefreshListCtrl(UString(), -1, true, UStringVector());
return S_OK;
return res;
}
void CPanel::SetBookmark(unsigned index)

View File

@@ -92,7 +92,7 @@ HRESULT CPanel::InitColumns()
{
SaveListViewInfo();
_listView.DeleteAllItems();
// DeleteListItems();
_selectedStatusVector.Clear();
{
@@ -411,9 +411,21 @@ void CPanel::SetFocusedSelectedItem(int index, bool select)
}
}
// #define PRINT_STAT
#ifdef PRINT_STAT
void Print_OnNotify(const char *name);
#else
#define Print_OnNotify(x)
#endif
HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool selectFocused,
const UStringVector &selectedNames)
{
if (!_folder)
return S_OK;
_dontShowMode = false;
LoadFullPathAndShow();
// OutputDebugStringA("=======\n");
@@ -431,11 +443,11 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
ZeroMemory(&item, sizeof(item));
// DWORD tickCount0 = GetTickCount();
_enableItemChangeNotify = false;
_listView.DeleteAllItems();
// _enableItemChangeNotify = false;
DeleteListItems();
_enableItemChangeNotify = true;
int listViewItemCount = 0;
_selectedStatusVector.Clear();
@@ -512,6 +524,12 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
}
}
_thereAre_ListView_Items = true;
// OutputDebugStringA("\n\n");
Print_OnNotify("===== Before Load");
if (showDots)
{
UString itemName = L"..";
@@ -642,7 +660,8 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
// item.pszText = const_cast<wchar_t *>((const wchar_t *)name);
item.pszText = LPSTR_TEXTCALLBACKW;
/* LPSTR_TEXTCALLBACKW works, but in some cases there are problems,
since we block notify handler. */
since we block notify handler.
LPSTR_TEXTCALLBACKW can be 2-3 times faster for loading in this loop. */
}
UInt32 attrib = 0;
@@ -687,14 +706,35 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
listViewItemCount++;
}
// OutputDebugStringA("End2\n");
/*
xp-64: there is different order when Windows calls CPanel::OnNotify for _listView modes:
Details : after whole code
List : 2 times:
1) - ListView.SotRedraw()
2) - after whole code
Small Icons :
Large icons : 2 times:
1) - ListView.Sort()
2) - after whole code (calls with reverse order of items)
So we need to allow Notify(), when windows requests names during the following code.
*/
Print_OnNotify("after Load");
disableNotify.SetMemMode_Enable();
disableNotify.Restore();
if (_listView.GetItemCount() > 0 && cursorIndex >= 0)
SetFocusedSelectedItem(cursorIndex, selectFocused);
// DWORD tickCount3 = GetTickCount();
Print_OnNotify("after SetFocusedSelectedItem");
SetSortRawStatus();
_listView.SortItems(CompareItems, (LPARAM)this);
// DWORD tickCount4 = GetTickCount();
Print_OnNotify("after Sort");
if (cursorIndex < 0 && _listView.GetItemCount() > 0)
{
if (focusedPos >= _listView.GetItemCount())
@@ -702,23 +742,29 @@ HRESULT CPanel::RefreshListCtrl(const UString &focusedName, int focusedPos, bool
// we select item only in showDots mode.
SetFocusedSelectedItem(focusedPos, showDots);
}
// m_RedrawEnabled = true;
// DWORD tickCount5 = GetTickCount();
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
// DWORD tickCount6 = GetTickCount();
disableNotify.SetMemMode_Enable();
disableNotify.Restore();
// m_RedrawEnabled = true;
Print_OnNotify("after SetFocusedSelectedItem2");
_listView.EnsureVisible(_listView.GetFocusedItem(), false);
// disableNotify.SetMemMode_Enable();
// disableNotify.Restore();
Print_OnNotify("after EnsureVisible");
_listView.SetRedraw(true);
// DWORD tickCount7 = GetTickCount();
Print_OnNotify("after SetRedraw");
_listView.InvalidateRect(NULL, true);
// DWORD tickCount8 = GetTickCount();
// OutputDebugStringA("End1\n");
Print_OnNotify("after InvalidateRect");
/*
_listView.UpdateWindow();
*/
Refresh_StatusBar();
// DWORD tickCount9 = GetTickCount();
/*
char s[256];
sprintf(s,

View File

@@ -356,8 +356,8 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
i += t;
}
}
text[dest] = 0;
// OutputDebugStringW(text);
return 0;
}
}

View File

@@ -348,7 +348,7 @@ BOOL CPanel::OnEndLabelEdit(LV_DISPINFOW * lpnmh)
// We need clear all items to disable GetText before Reload:
// number of items can change.
// _listView.DeleteAllItems();
// DeleteListItems();
// But seems it can still call GetText (maybe for current item)
// so we can't delete items.

View File

@@ -9,24 +9,19 @@ void SplitStringToTwoStrings(const UString &src, UString &dest1, UString &dest2)
dest1.Empty();
dest2.Empty();
bool quoteMode = false;
unsigned i;
for (i = 0; i < src.Len(); i++)
for (unsigned i = 0; i < src.Len(); i++)
{
wchar_t c = src[i];
const wchar_t c = src[i];
if (c == L'\"')
quoteMode = !quoteMode;
else if (c == L' ' && !quoteMode)
{
if (!quoteMode)
{
i++;
break;
}
dest2 = src.Ptr(i + 1);
return;
}
else
dest1 += c;
}
dest2 = src.Ptr(i);
}
void SplitString(const UString &srcString, UStringVector &destStrings)