




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
工学院实验报告实验项目:Web浏览器应用程序(网络编程实验) 计算机科学与技术 专业 0801 班姓 名: 于佳涛 学 号: 080102060051指导老师: 赵福祥 2011年 11 月实现目标:使用CHtmlView类可以实现一个应用程序,使之具有Wed浏览器的功能,包括浏览网页、前进、后退、返回主页和搜索功能。实验程序的技术要点:(1)利用MFC AppWizard生成应用程序框架. (2)掌握利用CHtmlView类开发Web客户机端程序的方法.程序代码及运行结果:1. 利用MFC AppWizard生成应用程序框架.(1) 应用程序类:Cyujiatao0051App,对应yujiatao0051.h和yujiatao0051.cpp文件.(2) 框架类:CMainFrame,对应MainFrm.h和MainFrm.cpp文件.(3) 文档类:C yujiatao0051Doc,对应yujiatao0051Doc.h和yujiatao0051.cpp文件.(4) HtmlView类:Cyujiatao0051View,对应yujiatao0051View.h和yujiatao0051.cpp文件.2. 程序代码(1) yujiatao0051View.cpp文件的实现 / yujiatao0051View.cpp : implementation of the C yujiatao0051View class/#include stdafx.h#include yujiatao0051.h#include yujiatao0051Doc.h#include yujiatao0051View.h#include MainFrm.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ C yujiatao0051ViewIMPLEMENT_DYNCREATE(CYujiatao0051View, CHtmlView)BEGIN_MESSAGE_MAP(CYujiatao0051View, CHtmlView)/AFX_MSG_MAP(CYujiatao0051View)ON_COMMAND(ID_BACK, OnBack)ON_COMMAND(ID_FOWARD, OnFoward)ON_COMMAND(ID_HOMEPAGE, OnHomepage)ON_COMMAND(ID_SEARCH, OnSearch)ON_COMMAND(ID_STOP, OnStop)ON_COMMAND(ID_UPDATE, OnUpdate)/AFX_MSG_MAP/ Standard printing commandsON_COMMAND(ID_FILE_PRINT, CHtmlView:OnFilePrint)END_MESSAGE_MAP()/ CYujiatao0051View construction/destructionCYujiatao0051View:CYujiatao0051View()/ TODO: add construction code hereCYujiatao0051View:CYujiatao0051View()BOOL CYujiatao0051View:PreCreateWindow(CREATESTRUCT& cs)/ TODO: Modify the Window class or styles here by modifying/ the CREATESTRUCT csreturn CHtmlView:PreCreateWindow(cs);/ CYujiatao0051View drawingvoid CYujiatao0051View:OnDraw(CDC* pDC)CYujiatao0051Doc* pDoc = GetDocument();ASSERT_VALID(pDoc);/ TODO: add draw code for native data herevoid CYujiatao0051View:OnInitialUpdate()CHtmlView:OnInitialUpdate();/ TODO: This code navigates to a popular spot on the web./ change the code to go where youd like.Navigate2(_T(/visualc/),NULL,NULL);/ CYujiatao0051View printing/ CYujiatao0051View diagnostics#ifdef _DEBUGvoid CYujiatao0051View:AssertValid() constCHtmlView:AssertValid();void CYujiatao0051View:Dump(CDumpContext& dc) constCHtmlView:Dump(dc);CYujiatao0051Doc* CYujiatao0051View:GetDocument() / non-debug version is inlineASSERT(m_pDocument-IsKindOf(RUNTIME_CLASS(CYujiatao0051Doc);return (CYujiatao0051Doc*)m_pDocument;#endif /_DEBUG/ CYujiatao0051View message handlersvoid CYujiatao0051View:OnBack() / TODO: Add your command handler code hereGoBack();void CYujiatao0051View:OnFoward() / TODO: Add your command handler code hereGoForward();void CYujiatao0051View:OnHomepage() / TODO: Add your command handler code hereGoHome();void CYujiatao0051View:OnSearch() / TODO: Add your command handler code hereGoSearch();void CYujiatao0051View:OnStop() / TODO: Add your command handler code hereStop();void CYujiatao0051View:OnUpdate() / TODO: Add your command handler code hereRefresh();void CYujiatao0051View:OnDocumentComplete(LPCTSTR lpszURL) / TODO: Add your specialized code here and/or call the base class(CMainFrame*)GetParentFrame()-SetPage(lpszURL);/CHtmlView:OnDocumentComplete(lpszURL);(2) MainFrm.h文件的实现 / MainFrm.h : interface of the CMainFrame class#if !defined(AFX_MAINFRM_H_46D187BD_7941_4BD8_9652_A780FF979164_INCLUDED_)#define AFX_MAINFRM_H_46D187BD_7941_4BD8_9652_A780FF979164_INCLUDED_#if _MSC_VER 1000#pragma once#endif / _MSC_VER 1000class CMainFrame : public CFrameWndprotected: / create from serialization onlyCMainFrame();DECLARE_DYNCREATE(CMainFrame)/ ClassWizard generated virtual function overrides/AFX_VIRTUAL(CMainFrame)virtual BOOL PreCreateWindow(CREATESTRUCT& cs);/AFX_VIRTUAL/ Implementationpublic:virtual CMainFrame();void OnNew();void SetPage(LPCTSTR lpszURL);#ifdef _DEBUGvirtual void AssertValid() const;virtual void Dump(CDumpContext& dc) const;#endifprotected: / control bar embedded membersCStatusBar m_wndStatusBar;CToolBar m_wndToolBar;CReBar m_wndReBar;CDialogBar m_wndDlgBar;/ Generated message map functionsprotected:/AFX_MSG(CMainFrame)afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);/ NOTE - the ClassWizard will add and remove member functions here./ DO NOT EDIT what you see in these blocks of generated code!/AFX_MSGDECLARE_MESSAGE_MAP();/AFX_INSERT_LOCATION/ Microsoft Visual C+ will insert additional declarations immediately before the previous line.#endif / !defined(AFX_MAINFRM_H_46D187BD_7941_4BD8_9652_A780FF979164_INCLUDED_)(3) MainFrm.cpp文件的实现 / MainFrm.cpp : implementation of the CMainFrame class#include stdafx.h#include Yujiatao0051.h#include Yujiatao0051View.h#include MainFrm.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/ CMainFrameIMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)/AFX_MSG_MAP(CMainFrame)/ NOTE - the ClassWizard will add and remove mapping macros here./ DO NOT EDIT what you see in these blocks of generated code !ON_WM_CREATE()/AFX_MSG_MAPON_COMMAND(IDOK,OnNew)END_MESSAGE_MAP()static UINT indicators =ID_SEPARATOR, / status line indicatorID_INDICATOR_CAPS,ID_INDICATOR_NUM,ID_INDICATOR_SCRL,;/ CMainFrame construction/destructionCMainFrame:CMainFrame()/ TODO: add member initialization code hereCMainFrame:CMainFrame()int CMainFrame:OnCreate(LPCREATESTRUCT lpCreateStruct)if (CFrameWnd:OnCreate(lpCreateStruct) = -1)return -1;if (!m_wndToolBar.CreateEx(this) |!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)TRACE0(Failed to create toolbarn);return -1; / fail to createif (!m_wndDlgBar.Create(this, IDR_MAINFRAME, CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR)TRACE0(Failed to create dialogbarn);return -1;/ fail to createif (!m_wndReBar.Create(this) |!m_wndReBar.AddBar(&m_wndToolBar) |!m_wndReBar.AddBar(&m_wndDlgBar)TRACE0(Failed to create rebarn);return -1; / fail to createif (!m_wndStatusBar.Create(this) |!m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)TRACE0(Failed to create status barn);return -1; / fail to create/ TODO: Remove this if you dont want tool tipsm_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |CBRS_TOOLTIPS
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 地毯后整工专项考核试卷及答案
- 塔吊司机数字化技能考核试卷及答案
- 建筑设计节目创新创业项目商业计划书
- 乒乓球制作工岗位操作规程考核试卷及答案
- 挂面制作工前沿技术考核试卷及答案
- 智慧医疗影像诊断平台创新创业项目商业计划书
- 宠物领养配对系统创新创业项目商业计划书
- 林下经济示范园区创新创业项目商业计划书
- 民用阀门及管道连接件制作工成本控制考核试卷及答案
- 起重装卸机械操作工专项考核试卷及答案
- 颅脑CT检查技术讲解
- 2025年高中数学说题比赛系列课件
- 临期品处理办法及流程
- 压裂泵往复密封动态磨损机理及失效自愈控制技术研究
- 消除三病反歧视培训
- 《矿山压力与岩层控制》教案
- 公司储备干部培训启动大会
- 初中英语1900词汇按词性分类
- 《道路交通安全违法行为记分管理办法》知识专题培训
- 《旅游研究方法课程》-课程教学大纲
- 裂纹损伤容限评估技术
评论
0/150
提交评论