⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mylist.cpp

📁 对文件进行处理。 包括文件复制、分割、连接、查看等。
💻 CPP
字号:
// MyList.cpp : implementation file
//

#include "stdafx.h"
#include "MyList.h"

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

CMyList::CMyList()
{
	m_nMaxWidth=0;
}

CMyList::~CMyList()
{
}


BEGIN_MESSAGE_MAP(CMyList, CListBox)
	//{{AFX_MSG_MAP(CMyList)
	ON_WM_DROPFILES()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyList message handlers

BOOL CMyList::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}

void CMyList::OnDropFiles(HDROP hDropInfo) 
{
	// TODO: Add your message handler code here and/or call default
	CString inf;char buf[255];
	int filecount=::DragQueryFile(hDropInfo,-1,0,0);
	for(int i=0;i<filecount;i++)
	{
		int size=0;
		size=DragQueryFile(hDropInfo,0,buf,0);
		DragQueryFile(hDropInfo,i,buf,size*2);
		inf.Format("%s",buf);
		AddString(inf);
	}
	CListBox::OnDropFiles(hDropInfo);
}

int CMyList::AddString(LPCTSTR lpszItem)
{
	int nRet=CListBox::AddString(lpszItem);
	int spoint=0;
	CString str;
	CClientDC myDC(this);
	CFont* pListBoxFont=GetFont();
	SIZE	sSize;
	if(pListBoxFont!=NULL)
	{
		CFont* pOldFont=myDC.SelectObject(pListBoxFont);
		for(int i=0;i<GetCount();i++)
		{
			GetText(i,str);
			GetTextExtentPoint32(myDC.m_hDC,lpszItem, strlen(str), &sSize);
			if(sSize.cx>spoint)
				spoint=(int)sSize.cx;
		}
	}
	SetHorizontalExtent(spoint+3);
	return nRet;
}

int CMyList::DeleteString(UINT nIndex)
{
	int nRet=CListBox::DeleteString(nIndex);
	int spoint=0;
	CString str;
	CClientDC myDC(this);
	CFont* pListBoxFont=GetFont();
	SIZE	sSize;
	if(pListBoxFont!=NULL)
	{
		CFont* pOldFont=myDC.SelectObject(pListBoxFont);
		for(int i=0;i<GetCount();i++)
		{
			GetText(i,str);
			GetTextExtentPoint32(myDC.m_hDC,str, strlen(str), &sSize);
			if(sSize.cx>spoint)
				spoint=(int)sSize.cx;
		}
	}
	SetHorizontalExtent(spoint+3);
	return nRet;
}

⌨️ 快捷键说明

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