📄 testview.cpp
字号:
// TestView.cpp : CTestView 类的实现
//
#include "stdafx.h"
#include "Test.h"
#include "TestDoc.h"
#include "TestView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CTestView
IMPLEMENT_DYNCREATE(CTestView, CView)
BEGIN_MESSAGE_MAP(CTestView, CView)
// 标准打印命令
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
ON_WM_RBUTTONDOWN()
END_MESSAGE_MAP()
// CTestView 构造/销毁
CTestView::CTestView()
{
// TODO: 在此处添加构造代码
}
CTestView::~CTestView()
{
}
BOOL CTestView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: 在此处通过修改 CREATESTRUCT cs 来修改窗口类或
// 样式
return CView::PreCreateWindow(cs);
}
// CTestView 绘制
void CTestView::OnDraw(CDC* /*pDC*/)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: 在此处为本机数据添加绘制代码
}
// CTestView 打印
BOOL CTestView::OnPreparePrinting(CPrintInfo* pInfo)
{
// 默认准备
return DoPreparePrinting(pInfo);
}
void CTestView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印前添加额外的初始化
}
void CTestView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: 打印后添加清除过程
}
// CTestView 诊断
#ifdef _DEBUG
void CTestView::AssertValid() const
{
CView::AssertValid();
}
void CTestView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CTestDoc* CTestView::GetDocument() const // 非调试版本是内联的
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestDoc)));
return (CTestDoc*)m_pDocument;
}
#endif //_DEBUG
// CTestView 消息处理程序
#include "afxinet.h"
void CTestView::OnRButtonDown(UINT nFlags, CPoint point)
{
CInternetSession MySession;
CString StrURL="http://www.163.com";
CString StrInfo="查询情况如下:\n";
CInternetFile* MyFile = NULL;
try
{
MyFile=(CInternetFile*)MySession.OpenURL(StrURL);
}
catch (CInternetException* pEx)
{
MyFile = NULL;
pEx->Delete();
}
if (MyFile)
{
CString StrLine;
for (int i=0; i < 20 && MyFile->ReadString(StrLine); i++)
{
StrInfo += StrLine + "\r\n";
}
MyFile->Close();
delete MyFile;
}
else
{
StrInfo+= " 没有查询结果!\r\n";
}
MessageBox(StrInfo,"信息提示",MB_OK);
CView::OnRButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -