Skip to content

Commit e9bb39a

Browse files
committed
Clipboard of LogWnd
1 parent ed74a6b commit e9bb39a

5 files changed

Lines changed: 18 additions & 16 deletions

File tree

MFCLib/LogWndDoc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#include "LogWndView.h"
88

99

10-
#define MAXBUFFERLINE 5000
10+
// 最大行数
11+
#define MAXBUFFERLINE 10000
1112

1213

1314
//
@@ -66,7 +67,6 @@ class CLogWndDoc : public CDocument, public CVTextDocument
6667
protected:
6768
DECLARE_MESSAGE_MAP()
6869

69-
7070
public:
7171
CString save_fname;
7272
CLogRingBuffer* ringBuffer;

MFCLib/LogWndFrame.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ int CLogWndFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
8484
void CLogWndFrame::OnLogCopy()
8585
{
8686
CString data = pView->getCopyData();
87-
87+
8888
char* mbstr = ts2mbs((LPCTSTR)data);
89-
int size = (int)strlen(mbstr);
89+
size_t size = strlen(mbstr);
9090
if (size<=0) {
9191
::free(mbstr);
9292
return;
@@ -98,17 +98,24 @@ void CLogWndFrame::OnLogCopy()
9898
::GlobalUnlock(hMem);
9999
::free(mbstr);
100100

101+
// to Clipboard
101102
if (!OpenClipboard()) {
102103
::GlobalFree(hMem);
103104
DEBUG_ERROR("CLogWndFrame::OnLogCopy(): ERROR: Clipboad open error!!\n");
104105
return;
105106
}
106-
107-
EmptyClipboard();
108-
SetClipboardData(CF_TEXT, hMem);
107+
if (!EmptyClipboard()) {
108+
::GlobalFree(hMem);
109+
DEBUG_ERROR("CLogWndFrame::OnLogCopy(): ERROR: Clipboad empty error!!\n");
110+
return;
111+
}
112+
if (::SetClipboardData(CF_TEXT, hMem) == NULL) {
113+
::GlobalFree(hMem);
114+
DEBUG_ERROR("CLogWndFrame::OnLogCopy(): ERROR: Clipboad set error!!\n");
115+
CloseClipboard();
116+
return;
117+
}
109118
CloseClipboard();
110-
::GlobalFree(hMem);
111-
112119
return;
113120
}
114121

MFCLib/LogWndFrame.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
#pragma once
22

3-
43
/**
54
CLogWndFrame クラス
65
76
CDxMGRView クラス用フレーム
87
9-
108
*/
119

1210
#include "ExTextFrame.h"

MFCLib/LogWndView.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ void CLogWndView::OnMouseMove(UINT nFlags, CPoint point)
396396
CString CLogWndView::getCopyData(void)
397397
{
398398
CString ret = _T("");
399-
if (m_copysy<0 || m_copysy>m_copyey) return ret;
399+
400+
if (m_copysy < 0 || m_copysy > m_copyey) return ret;
400401

401402
CLogWndDoc* pdoc = GetDocument();
402403
if (!pdoc || !pdoc->ringBuffer) return ret;

MFCLib/LogWndView.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ class CLogWndDoc;
1515
class CLogWndFrame;
1616

1717

18-
1918
class CLogWndView : public CExTextView
2019
{
2120
protected:
@@ -75,7 +74,6 @@ class CLogWndView : public CExTextView
7574
int m_copysy;
7675
int m_copyey;
7776

78-
7977
void resetScrollSize(void);
8078
void setScrollPosition(CDC* pDC, CLogRingBuffer* pBR);
8179
void clearViewDoc(void);
@@ -109,6 +107,4 @@ inline CLogWndDoc* CLogWndView::GetDocument() const { return reinterpret_cast<CL
109107

110108
#endif
111109

112-
113-
114110
} // namespace

0 commit comments

Comments
 (0)