?? 12view.cpp
字號:
// 12View.cpp : implementation of the CMy12View class
//
#include "stdafx.h"
#include "12.h"
#include "12Doc.h"
#include "12View.h"
//#include <fstream.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMy12View
IMPLEMENT_DYNCREATE(CMy12View, CView)
BEGIN_MESSAGE_MAP(CMy12View, CView)
//{{AFX_MSG_MAP(CMy12View)
ON_COMMAND(IDM_FILE_WRITE, OnFileWrite)
ON_COMMAND(IDM_FILE_READ, OnFileRead)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CMy12View construction/destruction
CMy12View::CMy12View()
{
// TODO: add construction code here
}
CMy12View::~CMy12View()
{
}
BOOL CMy12View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CMy12View drawing
void CMy12View::OnDraw(CDC* pDC)
{
CMy12Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CMy12View printing
BOOL CMy12View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CMy12View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CMy12View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CMy12View diagnostics
#ifdef _DEBUG
void CMy12View::AssertValid() const
{
CView::AssertValid();
}
void CMy12View::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CMy12Doc* CMy12View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMy12Doc)));
return (CMy12Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMy12View message handlers
void CMy12View::OnFileWrite()
{
// TODO: Add your command handler code here
/* FILE *pFile=fopen("1.txt","w");
fwrite("http://www.sunxin,org",1,strlen("http://www.sunxin,org"),pFile);
fclose(pFile);
fflush(pFile); */
/* FILE *pFile=fopen("2.txt","w");
char ch[3];
ch[0]='a';
ch[1]=10;
ch[2]='b';
fwrite(ch,1,3,pFile);
fclose(pFile);*/
/* FILE *pFile=fopen("3.txt","w");
int i=98341;
char ch[5];
itoa(i,ch,10);
fwrite(ch,1,5,pFile);
fclose(pFile);
*/
/* ofstream ofs("4.txt");
ofs.write("http://www.xunxin.org",strlen("http://www.xunxin.org"));
ofs.close();
*/
/* HANDLE hFile;
hFile=CreateFile("5.txt",GENERIC_WRITE,0,NULL,
CREATE_NEW,FILE_ATTRIBUTE_NORMAL,NULL);
DWORD dwWrites;
WriteFile(hFile,"http://www.sunxin.org",strlen("http://www.sunxin.org"),
&dwWrites,NULL);
CloseHandle(hFile);
*/
CFile file("6.txt",CFile::modeCreate|CFile::modeWrite);
file.Write("http://www.xunxin.org",strlen("http://www.xunxin.org"));
file.Close();
}
void CMy12View::OnFileRead()
{
// TODO: Add your command handler code here
/* FILE *pFile=fopen("1.txt","r");
char ch[100];
memset(ch,0,100);
fread(ch,1,100,pFile);
MessageBox(ch);
fclose(pFile); */
/* FILE *pFile=fopen("2.txt","r");
char ch[100];
fread(ch,1,3,pFile);
ch[3]=0;
MessageBox(ch);
fclose(pFile);*/
/* ifstream ifs("4.txt");
char ch[100];
memset(ch,0,100);
ifs.read(ch,100);
ifs.close();
MessageBox(ch);
*/
/* HANDLE hFile;
hFile=CreateFile("5.txt",GENERIC_READ,0,NULL,
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
char ch[100];
DWORD dwReads;
ReadFile(hFile,ch,100,&dwReads,NULL);
CloseHandle(hFile);
MessageBox(ch);
*/
CFile file("6.txt",CFile::modeRead);
char *pBuf;
DWORD dwFilelen;
dwFilelen=file.GetLength();
pBuf=new char[dwFilelen+1];
pBuf[dwFilelen]=0;
file.Read(pBuf,dwFilelen);
file.Close();
MessageBox(pBuf);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -