【VC开源代码栏目提醒】:网学会员为广大网友收集整理了,CFile_4View.cpp,希望对大家有所帮助!
// CFile_4View.cpp : implementation of the CCFile_4View class
//
#include "stdafx.h"
#include "CFile_4.h"
#include "CFile_4Doc.h"
#include "CFile_4View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCFile_4View
IMPLEMENT_DYNCREATE(CCFile_4View, CView)
BEGIN_MESSAGE_MAP(CCFile_4View, CView)
//{{AFX_MSG_MAP(CCFile_4View)
ON_COMMAND(IDM_SEARCH, OnSearch)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCFile_4View construction/destruction
CCFile_4View::CCFile_4View()
{
// TODO: add construction code here
}
CCFile_4View::~CCFile_4View()
{
}
BOOL CCFile_4View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CCFile_4View drawing
void CCFile_4View::OnDraw(CDC* pDC)
{
CCFile_4Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CCFile_4View printing
BOOL CCFile_4View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CCFile_4View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CCFile_4View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CCFile_4View diagnostics
#ifdef _DEBUG
void CCFile_4View::AssertValid() const
{
CView::AssertValid();
}
void CCFile_4View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CCFile_4Doc* CCFile_4View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CCFile_4Doc)));
return (CCFile_4Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CCFile_4View message handlers
void CCFile_4View::OnSearch()
{
// TODO: Add your command handler code here
char load[100];
::GetCurrentDirectory(100,load); //获得当前文件目录
strcat(load,"\\*.*");
CFileFind filefind;
BOOL bfind=filefind.FindFile(load); //寻找文件
CString str;
CString strResult;
while(bfind)
{
bfind=filefind.FindNextFile(); //寻找下一个
if(filefind.GetFileName()=="MFC.txt")
{
str=filefind.GetFilePath(); //获得文件的路径
strResult.Format("%s",str);
MessageBox(strResult); //显示
}
}
}