Skip to content

Commit

Permalink
BUGFIX: ListCtrl控件需要获得真实的列数
Browse files Browse the repository at this point in the history
  • Loading branch information
thejinchao committed Dec 13, 2014
1 parent ad906dc commit e5bb1f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions AxTrace/AT_ListCtrlEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,18 @@ void CListCtrlEx::copyToClipboard(void)
if(nItem<0) return;
if(!OpenClipboard()) return;

int columnCounts = Header_GetItemCount(ListView_GetHeader(m_hWnd));

std::wstring strClip;
wchar_t wszTemp[MAX_SUBITEM_LENGTH]={0};
while(nItem>=0)
{
for(int i=0; i<COLUMN_COUNTS; i++)
for (int i = 0; i<columnCounts; i++)
{
GetItemText(nItem, i, wszTemp, MAX_SUBITEM_LENGTH);

strClip += wszTemp;
if(i != COLUMN_COUNTS-1) strClip += _T("\t");
if (i != columnCounts - 1) strClip += _T("\t");
else strClip += _T("\r\n");
}

Expand Down Expand Up @@ -145,15 +147,16 @@ void CListCtrlEx::saveToFile(void)

wchar_t wszTemp[MAX_SUBITEM_LENGTH]={0};

int columnCounts = Header_GetItemCount(ListView_GetHeader(m_hWnd));
int counts = this->GetItemCount();
for(int i=0; i<counts; i++)
{
for(int j=0; j<COLUMN_COUNTS; j++)
for (int j = 0; j<columnCounts; j++)
{
GetItemText(i, j, wszTemp, MAX_SUBITEM_LENGTH);

fwrite(wszTemp, 2, wcslen(wszTemp), fp);
if(j != COLUMN_COUNTS-1) fwrite(_T("\t"), 2, 1, fp);
if (j != columnCounts - 1) fwrite(_T("\t"), 2, 1, fp);
else fwrite(_T("\r\n"), 2, 2, fp);
}
}
Expand Down
2 changes: 1 addition & 1 deletion AxTrace/AT_ListCtrlEx.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CListCtrlEx : public CWindowImpl<CListCtrlEx, CListViewCtrl>, public CCust
DWORD OnItemPrePaint(int /*idCtrl*/, LPNMCUSTOMDRAW pCD);

public:
enum { COLUMN_COUNTS=3, MAX_SUBITEM_LENGTH=2048 }; //hack...
enum { MAX_SUBITEM_LENGTH=2048 }; //hack...

/** scroll to bottom */
void scrollToBottom(void);
Expand Down

0 comments on commit e5bb1f1

Please sign in to comment.