📄 f_openview.cpp
字号:
// f_openView.cpp : implementation of the CF_openView class
//
#include "stdafx.h"
#include "f_open.h"
#include "f_openDoc.h"
#include "f_openView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CF_openView
IMPLEMENT_DYNCREATE(CF_openView, CView)
BEGIN_MESSAGE_MAP(CF_openView, CView)
//{{AFX_MSG_MAP(CF_openView)
ON_UPDATE_COMMAND_UI(ID_FILE_OPEN, OnUpdateFileOpen)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
ON_COMMAND(ID_OPEN, OnOpen)
ON_UPDATE_COMMAND_UI(ID_OPEN, OnUpdateOpen)
ON_COMMAND(ID_OOPEN, OnOopen)
ON_UPDATE_COMMAND_UI(ID_OOPEN, OnUpdateOopen)
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CF_openView construction/destruction
CF_openView::CF_openView()
{
kk=new finfo;
haveseenOopen=FALSE;
// TODO: add construction code here
}
CF_openView::~CF_openView()
{
}
BOOL CF_openView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CF_openView drawing
void CF_openView::OnDraw(CDC* pDC)
{
CF_openDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CF_openView printing
BOOL CF_openView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CF_openView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CF_openView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CF_openView diagnostics
#ifdef _DEBUG
void CF_openView::AssertValid() const
{
CView::AssertValid();
}
void CF_openView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CF_openDoc* CF_openView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CF_openDoc)));
return (CF_openDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CF_openView message handlers
void CF_openView::OnUpdateFileOpen(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CF_openView::OnFileOpen()
{
// TODO: Add your command handler code here
}
void CF_openView::OnOpen()
{
// TODO: Add your command handler code here
CFileDialog fd( TRUE, ".off", "*.off", //参数含义依次,打开文件,默认文件扩展名.off,默认文件名*。off
OFN_READONLY | OFN_SHOWHELP | 0, //指明一些特定风格.具体是什么风格,不是很清楚。
"Polygon Files(*.off)|*.off|All Files(*.*)|*.*||",//可供选择的文件类型和相应的扩展名
NULL );//文件选择对话框。
int iReturn = fd.DoModal(); //创建文件对话框
if(iReturn == IDOK)
{
//////////////////////////////////////////////////////////////////////////
// 此处的文件为批读入,文件命规则为 m0086.off
CString fn = fd.GetFileName(); // m0086.off
//CString ft = fd.GetFileTitle(); //m0086
FILE *instream; //实参变量,来实现参数传递。
instream = fopen( fn, "rt" );//打开文件fn,文件指针instream指向fn.
if( instream == NULL )
{
AfxMessageBox("The file was not opened\n" );//弹出消息框,在消息框内显示文本。
exit(1);
}
else // 读文件 //OFF
{ //4710 8773 0
kk->Initialization( instream); //调用kcp的成员函数,实现读文件。
fclose( instream );//关闭已经打开的文件的指针instream。
AfxMessageBox("OFF文件打开完毕!");
}
// fclose( outstream );//关闭已经打开的文件的指针instream。
}
haveseenOopen=TRUE;
}
void CF_openView::OnUpdateOpen(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CF_openView::OnOopen()
{
// TODO: Add your command handler code here
CFileDialog fdd( TRUE, ".off", "*.off", //参数含义依次,打开文件,默认文件扩展名.off,默认文件名*。off
OFN_READONLY | OFN_SHOWHELP | 0, //指明一些特定风格.具体是什么风格,不是很清楚。
"Polygon Files(*.off)|*.off|All Files(*.*)|*.*||",//可供选择的文件类型和相应的扩展名
NULL ); //文件选择对话框。
int idReturn = fdd.DoModal(); //创建文件对话框
if(idReturn == IDOK)
{
//////////////////////////////////////////////////////////////////////////
// 此处的文件为批读入,文件命规则为 m0086.off
CString fnn = fdd.GetFileName(); // m0086.off
FILE *outstream; //实参变量,来实现参数传递。
outstream = fopen( fnn , "wt" );
if( outstream == NULL )
{
AfxMessageBox("The file was not writed\n" );//弹出消息框,在消息框内显示文本。
// exit(1);
}
else // 读文件 //OFF
{ //4710 8773 0
kk->edgeSum(outstream);
fprintf(outstream,"%d",kk->eNum);
fclose( outstream );//关闭已经打开的文件的指针instream。
AfxMessageBox("OFF文件写入完毕!");
}
}
}
void CF_openView::OnUpdateOopen(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(haveseenOopen);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -