dropdialog.cpp

来自「接口封装 封装 我的 电动 的哦 得得」· C++ 代码 · 共 105 行

CPP
105
字号
// DropDialog.cpp: Implementierungsdatei
//

#include "stdafx.h"
#include "Interface.h"
#include "DropDialog.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CDropDialog 


CDropDialog::CDropDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CDropDialog::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDropDialog)
		// HINWEIS: Der Klassen-Assistent f黦t hier Elementinitialisierung ein
	//}}AFX_DATA_INIT
}

void CDropDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDropDialog)
	DDX_Control(pDX, IDC_LIST1, m_DropTable);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDropDialog, CDialog)
	//{{AFX_MSG_MAP(CDropDialog)
	ON_BN_CLICKED(IDC_RESET, OnReset)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f黵 Nachrichten CDropDialog 

BOOL CDropDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CString t;
	for (int i=0; i<5; i++)
	{
		t.Format ("Column %i", i);
		m_DropTable.InsertColumn(i, t, LVCFMT_LEFT, 75);
	}

	RegisterDragDrop(GetSafeHwnd(), this);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zur點kgeben
}

void CDropDialog::OnReset() 
{
	m_DropTable.DeleteAllItems();
}

void CDropDialog::ProcessData(CString Data)
{
	MessageBox(Data, "Dropped text");

	CString t1(Data), t2;
	int idx = t1.Find('\n');

	while (idx !=-1)
	{
		t2 = t1.Left(idx);
		t1 = t1.Mid(idx+1);
		InsertRow(t2);
		idx = t1.Find('\n');
	}
}

void CDropDialog::InsertRow(CString TabSeparated)
{
	CString t1(TabSeparated), t2;

	if (t1.Right(1)!="\t")
		t1+="\t";

	int idx = t1.Find('\t'), i = 1, row=LB_ERR;

	t2 = t1.Left(idx);
	t1 = t1.Mid(idx+1);
	row = m_DropTable.InsertItem(m_DropTable.GetItemCount()+1, t2);
	idx = t1.Find('\t');

	while (idx != -1 && i < 5 && row != LB_ERR)
	{	
		t2 = t1.Left(idx);
		t1 = t1.Mid(idx+1);
		m_DropTable.SetItemText(row, i, t2);
		i++;
		idx = t1.Find('\t');
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?