`
zhaohaolin
  • 浏览: 982355 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

利用Visual C++打造自己的IE浏览器

阅读更多
2005-06-29 09:03 作者: 刘涛 出处: 天极网 责任编辑:>方舟
<!---->
  下载本文源代码

  IE浏览器作为微软Windows系统捆绑销售的一个浏览工具,用来浏览千姿百态的网页,目前它已经占据了浏览器市场的半壁江山,成为Windows用户不可或缺的工具。首先,它的界面设计的很漂亮,如扁平按纽(按钮上的图像为灰色,当鼠标放在按钮上时,按钮突起,这种状态称为手柄,并且其上的图像变得鲜艳醒目)、按钮上的文字说明以及按钮边上的小黑三角形状的下拉箭头(单击时显示下拉菜单)、工具条上的地址输入栏等,都体现了Windows2000的风格;其次,它的收藏栏可以收藏用户喜爱的网络地址,这一切都为IE的流行打下了坚实的基础。说了那么多,也许读者朋友们感觉到IE实现起来一定非常困难,其实IE也是个"纸老虎",实现它的难点主要是在界面效果和显示收藏夹上,笔者在本实例中有针对性的叙述了IE界面、收藏网页的显示、网页的浏览等功能的实现,仔细看过这篇文章后,相信读者朋友们一定可以打造出一个属于自己的浏览器。本实例中的程序代码编译运行后的界面效果如图一所示:


图一、浏览器的运行界面

  一、实现方法

  1、浏览器的界面实现

  首先启动Visual C++6.0,生成一个名为mfcie单文档项目,注意在此过程中不要选择工具条和状态条选项,这样才能更方便我们在后续工作中用代码实现Windwos2000风格的工具条、状态条;在工具条中添加地址栏;项目的视图类的基类设置为ChtmlView,该类的Navigate2()成员函数专门用来现实超文本格式的文档。在主框架类CmainFrame中定义CStatusBar m_wndStatusBar(状态条对象)、CToolBar m_wndToolBar(工具栏对象)、CReBar m_wndReBar(、CComboBoxEx m_wndAddress(扩展的组合框对象,用来作为地址栏)、CAnimateCtrl m_wndAnimate(动画控件,用来在工具栏上显示动画)、图像列表对象CImageList img(存放显示在工具栏上的图标)等对象。向当前项目AVI资源文件,ID标志IDR_MFCAVI,添加Bitmap(位图)资源,ID标志分别为IDB_COLDTOOLBAR、IDB_HOTTOOLBAR,分别如下所示:




图二、包含按钮图标的位图

  1)IE风格工具条

  IE风格界面的实现主要在主框架类的CMainFrame::OnCreate()函数中实现,它的主要思想如下: CReBar对象用来作为工具条、地址栏、动画控件的容器,CImageList对象然后分别装载工具栏上按钮的热点图像和正常状态下显示的图像,并将该对象附给工具条对象,使之建立关联。为了显示扁平工具栏,需要用CreateEx()函数创建CToolBar对象m_wndToolBar,用ModifyStyle()函数将工具栏的风格设为扁平类型,注意这里不能用CToolBar::Create() 或 CToolBar:: SetBarStyle()设置这种新风格。CToolBar 类不支持TBSTYLE_FLAT,要解决这个问题,必须绕过CToolBar类,使用CWnd::ModifyStyle()。要将某一个工具栏按钮设置为附带有下拉按钮,可以调用SetButtonInfo()设置按钮的风格为TBSTYLE_DROPDOWN。至于按钮带有中文提示,用工具栏的SetButtonText()就可以轻松实现了。下面是实现IE风格界面的代码和注释:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
 CImageList img; //图像列表对象;
 CString str; //字符串对象;
 if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  return -1;
 if (!m_wndReBar.Create(this)) //创建CReBar对象;
 { TRACE0("Failed to create rebar\n");
  return -1; }
 if (!m_wndToolBar.CreateEx(this)) //使用CreateEx()函数创建工具条对象;
  { TRACE0("Failed to create toolbar\n");
   return -1; }
 //设置工具栏中的按钮最大最小尺寸;
 m_wndToolBar.GetToolBarCtrl().SetButtonWidth(50, 150);
 //设置工具栏上的按钮支持下拉箭头风格;
 m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
 //向图像列表装载热点图像资源,IDB_HOTTOOLBAR为热点图像资源ID img.Create(IDB_HOTTOOLBAR, 22, 0, RGB(255, 0, 255));
 m_wndToolBar.GetToolBarCtrl().SetHotImageList(&img);
 img.Detach();
 //图象列表装载正常状态的图像资源,IDB_COLDTOOLBAR为图像资源ID
 img.Create(IDB_COLDTOOLBAR, 22, 0, RGB(255, 0, 255));
 m_wndToolBar.GetToolBarCtrl().SetImageList(&img);
 img.Detach();
 //设置工具条为扁平风格
 m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
 //设置工具条上的按钮个数为9个;
 m_wndToolBar.SetButtons(NULL, 9);
 // 装载字符串资源,设置按钮上的文本和按钮的标识号; 
 m_wndToolBar.SetButtonInfo(0, ID_GO_BACK, TBSTYLE_BUTTON, 0);
 str.LoadString(IDS_BACK);
 m_wndToolBar.SetButtonText(0, str);
 m_wndToolBar.SetButtonInfo(1, ID_GO_FORWARD, TBSTYLE_BUTTON, 1);
 str.LoadString(IDS_FORWARD);
 m_wndToolBar.SetButtonText(1, str);
 m_wndToolBar.SetButtonInfo(2, ID_VIEW_STOP, TBSTYLE_BUTTON, 2);
 str.LoadString(IDS_STOP);
 m_wndToolBar.SetButtonText(2, str);
 m_wndToolBar.SetButtonInfo(3, ID_VIEW_REFRESH, TBSTYLE_BUTTON, 3);
 str.LoadString(IDS_REFRESH);
 m_wndToolBar.SetButtonText(3, str);
 m_wndToolBar.SetButtonInfo(4, ID_GO_START_PAGE, TBSTYLE_BUTTON, 4);
 str.LoadString(IDS_HOME);
 m_wndToolBar.SetButtonText(4, str);
 m_wndToolBar.SetButtonInfo(5, ID_GO_SEARCH_THE_WEB, TBSTYLE_BUTTON, 5);
 str.LoadString(IDS_SEARCH);
 m_wndToolBar.SetButtonText(5, str);
 m_wndToolBar.SetButtonInfo(6, ID_FAVORITES_DROPDOWN,TBSTYLE_BUTTON | TBSTYLE_DROPDOWN, 6);
 str.LoadString(IDS_FAVORITES);
 m_wndToolBar.SetButtonText(6, str);
 m_wndToolBar.SetButtonInfo(7, ID_FILE_PRINT, TBSTYLE_BUTTON, 7);
 str.LoadString(IDS_PRINT);
 m_wndToolBar.SetButtonText(7, str);
 m_wndToolBar.SetButtonInfo(8, ID_FONT_DROPDOWN, TBSTYLE_BUTTON | TBSTYLE_DROPDOWN, 8);
 str.LoadString(IDS_FONT);
 m_wndToolBar.SetButtonText(8, str);
 // 设置工具栏上的按钮尺寸和显示在按钮上的图标尺寸;
 CRect rectToolBar;
 m_wndToolBar.GetItemRect(0, &rectToolBar);
 m_wndToolBar.SetSizes(rectToolBar.Size(), CSize(30,20));
 //创建组合框,用来作为地址栏;
 if (!m_wndAddress.Create(CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 200, 120), this, AFX_IDW_TOOLBAR + 1))
  { TRACE0("Failed to create combobox\n");
   return -1; }
 //创建动画控件对象,并打开AVI资源IDR_MFCAVI;
 m_wndAnimate.Create(WS_CHILD | WS_VISIBLE, CRect(0, 0, 10, 10), this, AFX_IDW_TOOLBAR + 2);
 m_wndAnimate.Open(IDR_MFCAVI);
 //将工具条、地址栏、动画控件等添加到CReBar对象中;
 m_wndReBar.AddBar(&m_wndToolBar);
 m_wndReBar.AddBar(&m_wndAnimate, NULL, NULL, RBBS_FIXEDSIZE | RBBS_FIXEDBMP);
 str.LoadString(IDS_ADDRESS);
 m_wndReBar.AddBar(&m_wndAddress, str, NULL, RBBS_FIXEDBMP | RBBS_BREAK);
 //再次设置工具条风格,使之有工具栏提示功能;
 m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
 //设置状态条;
 if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT)))
 { TRACE0("Failed to create status bar\n");
  return -1; }
 …….//实现"Favorites"菜单的部分,该部分在第二部分介绍;
 return 0;
}
 2)工具条上的下拉菜单

  当用户点击按钮上的下拉箭头时,将出现相应的菜单,为了实现这个功能,首先需要在CMainFrame.cpp文件的消息映射中添加消息映射:ON_NOTIFY(TBN_DROPDOWN, AFX_IDW_TOOLBAR, OnDropDown);在CmainFrame.h文件中添加消息映射函数声明:afx_msg void OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult);最后添加下面的代码:

void CMainFrame::OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult)
{
 NMTOOLBAR* pNMToolBar = (NMTOOLBAR*)pNotifyStruct;
 CRect rect;
 // 得到下拉箭头的位置;
 m_wndToolBar.GetToolBarCtrl().GetRect(pNMToolBar->iItem, &rect);
 rect.top = rect.bottom;
 ::ClientToScreen(pNMToolBar->hdr.hwndFrom, &rect.TopLeft());
 if(pNMToolBar->iItem == ID_FONT_DROPDOWN)
 //判断是否为选择字体的下拉箭头;
 {
  CMenu menu;
  CMenu* pPopup;
  menu.LoadMenu(IDR_FONT_POPUP);
  pPopup = menu.GetSubMenu(0);
  pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, rect.top + 1, AfxGetMainWnd());
 }
 else if(pNMToolBar->iItem == ID_FAVORITES_DROPDOWN)
 {//判断是否为显示收藏网页的下拉箭头;
  CMenu* pPopup;
  pPopup = GetMenu()->GetSubMenu(3);
  pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON, rect.left, 
  rect.top + 1, AfxGetMainWnd());
 }
 *pResult = TBDDRET_DEFAULT;
}
 3)工具条上的动画实现

  为了美化程序的界面,程序的复合工具条上放置了一个动画控件,用来在适当的时机播放一个动画片段,实现动画效果。下面的代码实现了创建动画控件对象,并打开AVI资源IDR_MFCAVI:

m_wndAnimate.Create(WS_CHILD | WS_VISIBLE, CRect(0, 0, 10, 10), this, AFX_IDW_TOOLBAR + 2);
m_wndAnimate.Open(IDR_MFCAVI);

  CanimateCtrl类提供了Play()、Seek()、Stop()、Close()等函数用来为播放视频文件服务,它们使用起来都非常简单,这里就不再赘述了。

  4)地址栏的操作

  当用户在地址栏上输入网页地址并按下回车键后,浏览器将显示该网页的内容,并将在地址栏中记录下该地址。因为回车键按下后对应的消息ID为IDOK,为此,需要在CmainFrame类中添加消息映射ON_COMMAND(IDOK, OnNewAddressEnter)和消息响应函数afx_msg void OnNewAddressEnter()。该函数实现代码如下:

void CMainFrame::OnNewAddressEnter()
{
 CString str;
 //获取地址栏中的字符串;
 m_wndAddress.GetEditCtrl()->GetWindowText(str);
 ((CMfcieView*)GetActiveView())->Navigate2(str, 0, NULL);//显示该网页;
 //将该网址添加到地址栏对应的组合框中;
 COMBOBOXEXITEM item;
 item.mask = CBEIF_TEXT;
 item.iItem = -1;
 item.pszText = (LPTSTR)(LPCTSTR)str;
 m_wndAddress.InsertItem(&item);
}

  同理,还要在CmainFrame类中为地址栏(ID 为AFX_IDW_TOOLBAR + 1)添加消息映射ON_CBN_SELENDOK(AFX_IDW_TOOLBAR + 1,OnNewAddress)和消息响应函数OnNewAddress,用来处理用户从地址栏组合框中选择网址的操作,该函数的实现代码如下:

void CMainFrame::OnNewAddress()
{
 CString str;
 m_wndAddress.GetLBText(m_wndAddress.GetCurSel(), str);
 ((CMFCIEView*)GetActiveView())->Navigate2(str, 0, NULL);
}

  2、实现收藏菜单

  一般IE的用户都有个习惯,那就是将自己喜欢的网址保存起来,以方便今后快速的登陆,为了使我们的浏览器能够显示IE收藏过的网址,程序中设置了一个"Favorites"菜单,通过RegOpenKey()、RegQueryValueEx()等函数操作Windows的注册表中的HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders项,将收藏的网址显示到菜单上。为此,实例中定义了两个函数,实现代码如下所示:

TCHAR GetDir( ) //得到存放用户收藏网址的目录;
{
 TCHAR sz[MAX_PATH];
 TCHAR szPath[MAX_PATH];
 HKEY hKey;
 DWORD dwSize;
 CMenu* pMenu;
 // 得到"Favorites"菜单,并删除空白的子菜单项;
 pMenu = GetMenu()->GetSubMenu(3);
 while(pMenu->DeleteMenu(0, MF_BYPOSITION));
 // find out from the registry where the favorites are located.
 if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\
User Shell Folders"), &hKey) != ERROR_SUCCESS)
 {
  TRACE0("Favorites folder not found\n");
  return 0;
 }
 dwSize = sizeof(sz);
 RegQueryValueEx(hKey, _T("Favorites"), NULL, NULL, (LPBYTE)sz, &dwSize);
 ExpandEnvironmentStrings(sz, szPath, MAX_PATH);
 RegCloseKey(hKey);
 Return szPath
}
int CMainFrame::BuildFavoritesMenu(LPCTSTR pszPath, int nStartPos, CMenu* pMenu)
{
 CString strPath(pszPath);
 CString strPath2;
 CString str;
 WIN32_FIND_DATA wfd;
 HANDLE h;
 int nPos;
 int nEndPos;
 int nNewEndPos;
 int nLastDir;
 TCHAR buf[INTERNET_MAX_PATH_LENGTH];
 CStringArray astrFavorites;
 CStringArray astrDirs;
 CMenu* pSubMenu;
 if(strPath[strPath.GetLength() - 1] != _T(’\\’))
  strPath += _T(’\\’);
  strPath2 = strPath;
  strPath += "*.*";
  // 扫描当前目录,首先搜索*.URL文件,然后是可能含有*.URL文件的子目录;
  h = FindFirstFile(strPath, &wfd);
  if(h != INVALID_HANDLE_VALUE)
  {
   nEndPos = nStartPos;
   do
   {
    if((wfd.dwFileAttributes&
(FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))==0)
    {
     str = wfd.cFileName;
     if(str.Right(4) == _T(".url"))
     {/*URL文件和INI文件格式类似,所以我们可以使用 GetPrivateProfileString() 来得到我们所需要的信息。*/
      ::GetPrivateProfileString(_T("InternetShortcut"), T("URL"),
           _T(""),buf,INTERNET_MAX_PATH_LENGTH,
           strPath2 + str);
      str = str.Left(str.GetLength() - 4);
      // 判断是否已经重复;
      for(nPos = nStartPos ; nPos < nEndPos ; ++nPos)
      {
       if(str.CompareNoCase(astrFavorites[nPos]) < 0)
        break;
      }
      astrFavorites.InsertAt(nPos, str);//添加该字符串;
      m_astrFavoriteURLs.InsertAt(nPos, buf);//保留相应的地址
      ++nEndPos;
     }
    }
   } while(FindNextFile(h, &wfd));
   FindClose(h);
   // 将找到的项目添加到菜单中;
   for(nPos = nStartPos ; nPos < nEndPos ; ++nPos)
   {
    pMenu->AppendMenu(MF_STRING | MF_ENABLED, 0xe00 + nPos, astrFavorites[nPos]);
   }
   // 搜索子目录
   nLastDir = 0;
   h = FindFirstFile(strPath, &wfd);
   ASSERT(h != INVALID_HANDLE_VALUE);
   do
   {
    if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
    { //对目录进行搜索;
     if(lstrcmp(wfd.cFileName,_T(".")) == 0 || lstrcmp(wfd.cFileName, _T("..")) == 0)
      continue;
     for(nPos = 0 ; nPos < nLastDir ; ++nPos)
     {
      if(astrDirs[nPos].CompareNoCase(wfd.cFileName) > 0)
       break;
     }
     pSubMenu = new CMenu;
     pSubMenu->CreatePopupMenu();
     // call this function recursively.
     nNewEndPos = BuildFavoritesMenu(strPath2 + wfd.cFileName, nEndPos, pSubMenu);
     if(nNewEndPos != nEndPos)
     {
      // 插入子菜单;
      nEndPos = nNewEndPos;
      pMenu->InsertMenu(nPos, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT)pSubMenu->m_hMenu, wfd.cFileName);
      pSubMenu->Detach();
      astrDirs.InsertAt(nPos, wfd.cFileName);
      ++nLastDir;
     }
     delete pSubMenu;
    }
   } while(FindNextFile(h, &wfd));
     FindClose(h);
  }
  return nEndPos;
}

  3、显示超文本

  微软ChtmView类的Navigate2函数可以实现超文本文件的显示,GoBack()、GoForward()等函数可以分别实现网页浏览的回退和前进操作。以响应"Favorite"菜单项为例,需要在程序的CmainFrame类中添加消息映射ON_COMMAND_RANGE(0xe00, 0xfff, OnFavorite)和消息响应函数OnFavorite,来响应ID为0xe00-0xfff范围内的菜单单击处理,具体实现代码如下:

void CMainFrame::OnFavorite(UINT nID)
{
((CMFCIEView*)GetActiveView())->Navigate2(m_astrFavoriteURLs[nID-0xe00], 0, NULL);
}

  二、编程步骤

  1、 启动Visual C++6.0,生成一个单文档视图结构的应用程序,将该程序命名为"mfcie",注意在生成项目的过程中不要选择工具条和状态条选项,项目的视图类的基类设置为ChtmlView;

  2、 按照上文中的说明,使用Class Wizard在程序的项目中添加相应的消息响应函数;

  3、 向程序的项目中添加AVI、位图资源;

  4、 添加代码,编译运行程序。

三、程序代码

//////////////////////////////////////////////
#if !defined(AFX_MAINFRM_H__47FF4081_CE1B_11D0_BEB6_00C04FC99F83__INCLUDED_)
#define AFX_MAINFRM_H__47FF4081_CE1B_11D0_BEB6_00C04FC99F83__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
// Attributes
public:
CStringArray m_astrFavoriteURLs;
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMainFrame)
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
void SetAddress(LPCTSTR lpszUrl);
void StartAnimation();
int BuildFavoritesMenu(LPCTSTR pszPath, int nStartPos, CMenu* pMenu);
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CReBar m_wndReBar;
// Generated message map functions
protected:
CComboBoxEx m_wndAddress;
CAnimateCtrl m_wndAnimate;
//{{AFX_MSG(CMainFrame)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
//}}AFX_MSG
afx_msg void DoNothing();
afx_msg void OnNewAddress();
afx_msg void OnNewAddressEnter();
afx_msg void OnFavorite(UINT nID);
afx_msg void OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult);
DECLARE_MESSAGE_MAP()
};
#endif

///////////////////// MainFrm.cpp : implementation of the CMainFrame class
#include "stdafx.h"
#include "mfcie.h"
#include <wininet.h>
#include "MainFrm.h"
#include "mfcieDoc.h"
#include "mfcieVw.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
//}}AFX_MSG_MAP
ON_CBN_SELENDOK(AFX_IDW_TOOLBAR + 1,OnNewAddress)
ON_COMMAND_RANGE(0xe00, 0xfff, OnFavorite)
ON_COMMAND(IDOK, OnNewAddressEnter)
ON_NOTIFY(TBN_DROPDOWN, AFX_IDW_TOOLBAR, OnDropDown)
ON_COMMAND(ID_FAVORITES_DROPDOWN, DoNothing)
ON_COMMAND(ID_FONT_DROPDOWN, DoNothing)
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
CMainFrame::CMainFrame()
{
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
CImageList img;
CString str;
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndReBar.Create(this))
{
TRACE0("Failed to create rebar\n");
return -1; // fail to create
}
if (!m_wndToolBar.CreateEx(this))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
// set up toolbar properties
m_wndToolBar.GetToolBarCtrl().SetButtonWidth(50, 150);
m_wndToolBar.GetToolBarCtrl().SetExtendedStyle(TBSTYLE_EX_DRAWDDARROWS);
img.Create(IDB_HOTTOOLBAR, 22, 0, RGB(255, 0, 255));
m_wndToolBar.GetToolBarCtrl().SetHotImageList(&img);
img.Detach();
img.Create(IDB_COLDTOOLBAR, 22, 0, RGB(255, 0, 255));
m_wndToolBar.GetToolBarCtrl().SetImageList(&img);
img.Detach();
m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT | TBSTYLE_TRANSPARENT);
m_wndToolBar.SetButtons(NULL, 9);
// set up each toolbar button
m_wndToolBar.SetButtonInfo(0, ID_GO_BACK, TBSTYLE_BUTTON, 0);
str.LoadString(IDS_BACK);
m_wndToolBar.SetButtonText(0, str);
m_wndToolBar.SetButtonInfo(1, ID_GO_FORWARD, TBSTYLE_BUTTON, 1);
str.LoadString(IDS_FORWARD);
m_wndToolBar.SetButtonText(1, str);
m_wndToolBar.SetButtonInfo(2, ID_VIEW_STOP, TBSTYLE_BUTTON, 2);
str.LoadString(IDS_STOP);
m_wndToolBar.SetButtonText(2, str);
m_wndToolBar.SetButtonInfo(3, ID_VIEW_REFRESH, TBSTYLE_BUTTON, 3);
str.LoadString(IDS_REFRESH);
m_wndToolBar.SetButtonText(3, str);
m_wndToolBar.SetButtonInfo(4, ID_GO_START_PAGE, TBSTYLE_BUTTON, 4);
str.LoadString(IDS_HOME);
m_wndToolBar.SetButtonText(4, str);
m_wndToolBar.SetButtonInfo(5, ID_GO_SEARCH_THE_WEB, TBSTYLE_BUTTON, 5);
str.LoadString(IDS_SEARCH);
m_wndToolBar.SetButtonText(5, str);
m_wndToolBar.SetButtonInfo(6, ID_FAVORITES_DROPDOWN, TBSTYLE_BUTTON |
TBSTYLE_DROPDOWN, 6);
str.LoadString(IDS_FAVORITES);
m_wndToolBar.SetButtonText(6, str);
m_wndToolBar.SetButtonInfo(7, ID_FILE_PRINT, TBSTYLE_BUTTON, 7);
str.LoadString(IDS_PRINT);
m_wndToolBar.SetButtonText(7, str);
m_wndToolBar.SetButtonInfo(8, ID_FONT_DROPDOWN, TBSTYLE_BUTTON |
TBSTYLE_DROPDOWN, 8);
str.LoadString(IDS_FONT);
m_wndToolBar.SetButtonText(8, str);
CRect rectToolBar;
// set up toolbar button sizes
m_wndToolBar.GetItemRect(0, &rectToolBar);
m_wndToolBar.SetSizes(rectToolBar.Size(), CSize(30,20));
// create a combo box for the address bar
if (!m_wndAddress.Create(CBS_DROPDOWN | WS_CHILD, CRect(0, 0, 100, 120),
this, AFX_IDW_TOOLBAR + 1))
{
TRACE0("Failed to create combobox\n");
return -1; // fail to create
}
// create the animation control
m_wndAnimate.Create(WS_CHILD | WS_VISIBLE, CRect(0, 0, 10, 10),
this, AFX_IDW_TOOLBAR + 2);
m_wndAnimate.Open(IDR_MFCAVI);
// add the toolbar, animation, and address bar to the rebar
m_wndReBar.AddBar(&m_wndToolBar);
m_wndReBar.AddBar(&m_wndAnimate, NULL, NULL, RBBS_FIXEDSIZE | RBBS_FIXEDBMP);
str.LoadString(IDS_ADDRESS);
m_wndReBar.AddBar(&m_wndAddress, str, NULL, RBBS_FIXEDBMP | RBBS_BREAK);
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_FIXED);
if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
// set up Favorites menu
TCHAR sz[MAX_PATH];
TCHAR szPath[MAX_PATH];
HKEY hKey;
DWORD dwSize;
CMenu* pMenu;
// first get rid of bogus submenu items.
pMenu = GetMenu()->GetSubMenu(3);
while(pMenu->DeleteMenu(0, MF_BYPOSITION));
// find out from the registry where the favorites are located.
if(RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\
Explorer\\User Shell Folders"), &hKey) != ERROR_SUCCESS)
{
TRACE0("Favorites folder not found\n");
return 0;
}
dwSize = sizeof(sz);
RegQueryValueEx(hKey, _T("Favorites"), NULL, NULL, (LPBYTE)sz, &dwSize);
ExpandEnvironmentStrings(sz, szPath, MAX_PATH);
RegCloseKey(hKey);
BuildFavoritesMenu(szPath, 0, pMenu);
return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.lpszClass = AfxRegisterWndClass(0);
return CFrameWnd::PreCreateWindow(cs);
}

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}

#endif //_DEBUG

int CMainFrame::BuildFavoritesMenu(LPCTSTR pszPath, int nStartPos, CMenu* pMenu)
{
CString strPath(pszPath);
CString strPath2;
CString str;
WIN32_FIND_DATA wfd;
HANDLE h;
int nPos;
int nEndPos;
int nNewEndPos;
int nLastDir;
TCHAR buf[INTERNET_MAX_PATH_LENGTH];
CStringArray astrFavorites;
CStringArray astrDirs;
CMenu* pSubMenu;
// make sure there’s a trailing backslash
if(strPath[strPath.GetLength() - 1] != _T(’\\’))
strPath += _T(’\\’);
strPath2 = strPath;
strPath += "*.*";
// now scan the directory, first for .URL files and then for subdirectories
// that may also contain .URL files
h = FindFirstFile(strPath, &wfd);
if(h != INVALID_HANDLE_VALUE)
{
nEndPos = nStartPos;
do
{
if((wfd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY|
FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM))==0)
{
str = wfd.cFileName;
if(str.Right(4) == _T(".url"))
{
// an .URL file is formatted just like an .INI file, so we can
// use GetPrivateProfileString() to get the information we want
::GetPrivateProfileString(_T("InternetShortcut"),
_T("URL"), _T(""), buf, INTERNET_MAX_PATH_LENGTH, strPath2 + str);
str = str.Left(str.GetLength() - 4);
// scan through the array and perform an insertion sort
// to make sure the menu ends up in alphabetic order
for(nPos = nStartPos ; nPos < nEndPos ; ++nPos)
{
if(str.CompareNoCase(astrFavorites[nPos]) < 0)
break;
}
astrFavorites.InsertAt(nPos, str);
m_astrFavoriteURLs.InsertAt(nPos, buf);
++nEndPos;
}
}
} while(FindNextFile(h, &wfd));
FindClose(h);
// Now add these items to the menu
for(nPos = nStartPos ; nPos < nEndPos ; ++nPos)
{
pMenu->AppendMenu(MF_STRING | MF_ENABLED, 0xe00 + nPos,
astrFavorites[nPos]);
}
// now that we’ve got all the .URL files, check the subdirectories for more
nLastDir = 0;
h = FindFirstFile(strPath, &wfd);
ASSERT(h != INVALID_HANDLE_VALUE);
do
{
if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
// ignore the current and parent directory entries
if(lstrcmp(wfd.cFileName, _T(".")) == 0 || lstrcmp(wfd.cFileName,
_T("..")) == 0)
continue;
for(nPos = 0 ; nPos < nLastDir ; ++nPos)
{
if(astrDirs[nPos].CompareNoCase(wfd.cFileName) > 0)
break;
}
pSubMenu = new CMenu;
pSubMenu->CreatePopupMenu();
// call this function recursively.
nNewEndPos = BuildFavoritesMenu(strPath2 + wfd.cFileName,
nEndPos, pSubMenu);
if(nNewEndPos != nEndPos)
{
// only intert a submenu if there are in fact .URL files in the subdirectory
nEndPos = nNewEndPos;
pMenu->InsertMenu(nPos, MF_BYPOSITION | MF_POPUP | MF_STRING,
(UINT)pSubMenu->m_hMenu, wfd.cFileName);
pSubMenu->Detach();
astrDirs.InsertAt(nPos, wfd.cFileName);
++nLastDir;
}
delete pSubMenu;
}
} while(FindNextFile(h, &wfd));
FindClose(h);
}
return nEndPos;
}

void CMainFrame::OnFavorite(UINT nID)
{
((CMfcieView*)GetActiveView())->Navigate2(m_astrFavoriteURLs[nID-0xe00],
0, NULL);
}

void CMainFrame::SetAddress(LPCTSTR lpszUrl)
{
// This is called when the browser has completely loaded the new location,
// so make sure the text in the address bar is up to date and stop the
// animation.
m_wndAddress.SetWindowText(lpszUrl);
m_wndAnimate.Stop();
m_wndAnimate.Seek(0);
}

void CMainFrame::StartAnimation()
{
// Start the animation. This is called when the browser begins to
// navigate to a new location
m_wndAnimate.Play(0, -1, -1);
}

void CMainFrame::OnNewAddress()
{
// gets called when an item in the Address combo box is selected
// just navigate to the newly selected location.
CString str;

m_wndAddress.GetLBText(m_wndAddress.GetCurSel(), str);
((CMfcieView*)GetActiveView())->Navigate2(str, 0, NULL);
}

void CMainFrame::OnNewAddressEnter()
{
// gets called when an item is entered manually into the edit box portion
// of the Address combo box.
// navigate to the newly selected location and also add this address to the
// list of addresses in the combo box.
CString str;
m_wndAddress.GetEditCtrl()->GetWindowText(str);
((CMfcieView*)GetActiveView())->Navigate2(str, 0, NULL);
COMBOBOXEXITEM item;
item.mask = CBEIF_TEXT;
item.iItem = -1;
item.pszText = (LPTSTR)(LPCTSTR)str;
m_wndAddress.InsertItem(&item);
}

void CMainFrame::DoNothing()
{
// this is here only so that the toolbar buttons for the dropdown menus
// will have a callback, and thus will not be disabled.
}

void CMainFrame::OnDropDown(NMHDR* pNotifyStruct, LRESULT* pResult)
{
// this function handles the dropdown menus from the toolbar
NMTOOLBAR* pNMToolBar = (NMTOOLBAR*)pNotifyStruct;
CRect rect;
// translate the current toolbar item rectangle into screen coordinates
// so that we’ll know where to pop up the menu
m_wndToolBar.GetToolBarCtrl().GetRect(pNMToolBar->iItem, &rect);
rect.top = rect.bottom;
::ClientToScreen(pNMToolBar->hdr.hwndFrom, &rect.TopLeft());
if(pNMToolBar->iItem == ID_FONT_DROPDOWN)
{
CMenu menu;
CMenu* pPopup;
// the font popup is stored in a resource
menu.LoadMenu(IDR_FONT_POPUP);
pPopup = menu.GetSubMenu(0);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
rect.left, rect.top + 1, AfxGetMainWnd());
}
else if(pNMToolBar->iItem == ID_FAVORITES_DROPDOWN)
{
CMenu* pPopup;

// for the favorties popup, just steal the menu from the main window
pPopup = GetMenu()->GetSubMenu(3);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,
rect.left, rect.top + 1, AfxGetMainWnd());
}
*pResult = TBDDRET_DEFAULT;
}

///////////////////////////////////
#if !defined(AFX_MFCIEVIEW_H__47FF4085_CE1B_11D0_BEB6_00C04FC99F83__INCLUDED_)
#define AFX_MFCIEVIEW_H__47FF4085_CE1B_11D0_BEB6_00C04FC99F83__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CMfcieView : public CHtmlView
{
protected: // create from serialization only
CMfcieView();
DECLARE_DYNCREATE(CMfcieView)
// Attributes
public:
CMfcieDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMfcieView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual void OnInitialUpdate();
//}}AFX_VIRTUAL
void OnTitleChange(LPCTSTR lpszText);
void OnDocumentComplete(LPCTSTR lpszUrl);
void OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags,
LPCTSTR lpszTargetFrameName, CByteArray& baPostedData,
LPCTSTR lpszHeaders, BOOL* pbCancel);
// Implementation
public:
virtual ~CMfcieView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CMfcieView)
afx_msg void OnGoBack();
afx_msg void OnGoForward();
afx_msg void OnGoSearchTheWeb();
afx_msg void OnGoStartPage();
afx_msg void OnViewStop();
afx_msg void OnViewRefresh();
afx_msg void OnHelpWebTutorial();
afx_msg void OnHelpOnlineSupport();
afx_msg void OnHelpMicrosoftOnTheWebFreeStuff();
afx_msg void OnHelpMicrosoftOnTheWebFrequentlyAskedQuestions();
afx_msg void OnHelpMicrosoftOnTheWebGetFasterInternetAccess();
afx_msg void OnHelpMicrosoftOnTheWebMicrosoftHomePage();
afx_msg void OnHelpMicrosoftOnTheWebSearchTheWeb();
afx_msg void OnHelpMicrosoftOnTheWebSendFeedback();
afx_msg void OnHelpMicrosoftOnTheWebInternetStartPage();
afx_msg void OnHelpMicrosoftOnTheWebBestOfTheWeb();
afx_msg void OnViewFontsLargest();
afx_msg void OnViewFontsLarge();
afx_msg void OnViewFontsMedium();
afx_msg void OnViewFontsSmall();
afx_msg void OnViewFontsSmallest();
afx_msg void OnFileOpen();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in mfcieView.cpp
inline CMfcieDoc* CMfcieView::GetDocument()
{ return (CMfcieDoc*)m_pDocument; }
#endif
#endif

////////////////////////////////////////////////
#include "stdafx.h"
#include "mfcie.h"
#include "MainFrm.h"

#include "mfcieDoc.h"
#include "mfcieVw.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

////////////////////////////////////// CMfcieView
IMPLEMENT_DYNCREATE(CMfcieView, CHtmlView)
BEGIN_MESSAGE_MAP(CMfcieView, CHtmlView)
//{{AFX_MSG_MAP(CMfcieView)
ON_COMMAND(ID_GO_BACK, OnGoBack)
ON_COMMAND(ID_GO_FORWARD, OnGoForward)
ON_COMMAND(ID_GO_SEARCH_THE_WEB, OnGoSearchTheWeb)
ON_COMMAND(ID_GO_START_PAGE, OnGoStartPage)
ON_COMMAND(ID_VIEW_STOP, OnViewStop)
ON_COMMAND(ID_VIEW_REFRESH, OnViewRefresh)
ON_COMMAND(ID_HELP_WEB_TUTORIAL, OnHelpWebTutorial)
ON_COMMAND(ID_HELP_ONLINE_SUPPORT, OnHelpOnlineSupport)
ON_COMMAND(ID_HELP_MICROSOFT_ON_THE_WEB_FREE_STUFF, OnHelpMicrosoftOnTheWebFreeStuff)
ON_COMMAND(ID_HELP_MICROSOFT_ON_THE_WEB_FREQUENTLY_ASKED_QUESTIONS, OnHelpMicrosoftOnTheWebFrequentlyAskedQuestions)
ON_COMMAND(ID_HELP_MICROSOFT_ON_THE_WEB_GET_FASTER_INTERNET_ACCESS, OnHelpMicrosoftOnTheWebGetFasterInternetAccess)
ON_COMMAND(ID_HELP_MICROSOFT_ON_THE_WEB_MICROSOFT_HOME_PAGE, OnHelpMicrosoftOnTheWebMicrosoftHomePage)
ON_COMMAND(ID_HELP_MICROSOFT_ON_THE_WEB_SEARCH_THE_WEB, OnHelpMicrosoftOnTheWebSearchTheWeb)
ON_COMMAND(ID_HELP_MICROSOFT_ON_THE_WEB_SEND_FEEDBACK, OnHelpMicrosoftOnTheWebSendFeedback)
ON_COMMAND(ID_HELP_MICROSOFT_ON_THE_WEB_INTERNET_START_PAGE, OnHelpMicrosoftOnTheWebInternetStartPage)
ON_COMMAND(ID_HELP_MICROSOFT_ON_THE_WEB_BEST_OF_THE_WEB, OnHelpMicrosoftOnTheWebBestOfTheWeb)
ON_COMMAND(ID_VIEW_FONTS_LARGEST, OnViewFontsLargest)
ON_COMMAND(ID_VIEW_FONTS_LARGE, OnViewFontsLarge)
ON_COMMAND(ID_VIEW_FONTS_MEDIUM, OnViewFontsMedium)
ON_COMMAND(ID_VIEW_FONTS_SMALL, OnViewFontsSmall)
ON_COMMAND(ID_VIEW_FONTS_SMALLEST, OnViewFontsSmallest)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

CMfcieView::CMfcieView()
{
}

CMfcieView::~CMfcieView()
{
}

BOOL CMfcieView::PreCreateWindow(CREATESTRUCT& cs)
{
cs.lpszClass = AfxRegisterWndClass(0);
return CView::PreCreateWindow(cs);
}

void CMfcieView::OnDraw(CDC* pDC)
{
CMfcieDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
}

#ifdef _DEBUG
void CMfcieView::AssertValid() const
{
CView::AssertValid();
}

void CMfcieView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}

CMfcieDoc* CMfcieView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMfcieDoc)));
return (CMfcieDoc*)m_pDocument;
}
#endif //_DEBUG

void CMfcieView::OnTitleChange(LPCTSTR lpszText)
{
// this will change the main frame’s title bar
if (m_pDocument != NULL)
m_pDocument->SetTitle(lpszText);
}

void CMfcieView::OnDocumentComplete(LPCTSTR lpszUrl)
{
// make sure the main frame has the new URL. This call also stops the animation
((CMainFrame*)GetParentFrame())->SetAddress(lpszUrl);
}

void CMfcieView::OnInitialUpdate()
{
// Go to the home page initially
CHtmlView::OnInitialUpdate();
GoHome();
}

void CMfcieView::OnBeforeNavigate2(LPCTSTR /*lpszURL*/, DWORD /*nFlags*/,
LPCTSTR /*lpszTargetFrameName*/, CByteArray& /*baPostedData*/,
LPCTSTR /*lpszHeaders*/, BOOL* /*pbCancel*/)
{
// start the animation so that is plays while the new page is being loaded
((CMainFrame*)GetParentFrame())->StartAnimation();
}

// these are all simple one-liners to do simple controlling of the browser
void CMfcieView::OnGoBack()
{
GoBack();
}

void CMfcieView::OnGoForward()
{
GoForward();
}

void CMfcieView::OnGoSearchTheWeb()
{
GoSearch();
}

void CMfcieView::OnGoStartPage()
{
GoHome();
}

void CMfcieView::OnViewStop()
{
Stop();
}

void CMfcieView::OnViewRefresh()
{
Refresh();
}

// these all go to specific web pages, just like Internet Explorer’s help menu
void CMfcieView::OnHelpWebTutorial()
{
CString str;

str.LoadString(IDS_WEB_TUTORIAL);
Navigate2(str, 0, NULL);
}

void CMfcieView::OnHelpOnlineSupport()
{
CString str;

str.LoadString(IDS_ONLINE_SUPPORT);
Navigate2(str, 0, NULL);
}

void CMfcieView::OnHelpMicrosoftOnTheWebBestOfTheWeb()
{
CString str;

str.LoadString(IDS_BEST_OF_THE_WEB);
Navigate2(str, 0, NULL);
}

void CMfcieView::OnHelpMicrosoftOnTheWebFreeStuff()
{
CString str;

str.LoadString(IDS_FREE_STUFF);
Navigate2(str, 0, NULL);
}

void CMfcieView::OnHelpMicrosoftOnTheWebFrequentlyAskedQuestions()
{
CString str;

str.LoadString(IDS_FREQUENTLY_ASKED_QUESTIONS);
Navigate2(str, 0, NULL);
}

void CMfcieView::OnHelpMicrosoftOnTheWebGetFasterInternetAccess()
{
CString str;

str.LoadString(IDS_GET_FASTER_INTERNET_ACCESS);
Navigate2(str, 0, NULL);
}

void CMfcieView::OnHelpMicrosoftOnTheWebMicrosoftHomePage()
{
CString str;

str.LoadString(IDS_MICROSOFT_HOME_PAGE);
Navigate2(str, 0, NULL);
}

void CMfcieView::OnHelpMicrosoftOnTheWebSearchTheWeb()
{
CString str;

str.LoadString(IDS_SEARCH_THE_WEB);
Navigate2(str, 0, NULL);
}

void CMfcieView::OnHelpMicrosoftOnTheWebSendFeedback()
{
CString str;

str.LoadString(IDS_SEND_FEEDBACK);
Navigate2(str, 0, NULL);
}

void CMfcieView::OnHelpMicrosoftOnTheWebInternetStartPage()
{
CString str;

str.LoadString(IDS_INTERNET_START_PAGE);
Navigate2(str, 0, NULL);
}

// these functions control the font size. There is no explicit command in the
// CHtmlView class to do this, but we can do it by using the ExecWB() function.
void CMfcieView::OnViewFontsLargest()
{
COleVariant vaZoomFactor(4l);

ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
&vaZoomFactor, NULL);
}

void CMfcieView::OnViewFontsLarge()
{
COleVariant vaZoomFactor(3l);

ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
&vaZoomFactor, NULL);
}

void CMfcieView::OnViewFontsMedium()
{
COleVariant vaZoomFactor(2l);

ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
&vaZoomFactor, NULL);
}

void CMfcieView::OnViewFontsSmall()
{
COleVariant vaZoomFactor(1l);

ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
&vaZoomFactor, NULL);
}

void CMfcieView::OnViewFontsSmallest()
{
COleVariant vaZoomFactor(0l);

ExecWB(OLECMDID_ZOOM, OLECMDEXECOPT_DONTPROMPTUSER,
&vaZoomFactor, NULL);
}

// This demonstrates how we can use the Navigate2() function to load local files
// including local HTML pages, GIFs, AIFF files, etc.
void CMfcieView::OnFileOpen()
{
CString str;

str.LoadString(IDS_FILETYPES);

CFileDialog fileDlg(TRUE, NULL, NULL, OFN_HIDEREADONLY, str);

if(fileDlg.DoModal() == IDOK)
Navigate2(fileDlg.GetPathName(), 0, NULL);
}

  四、小结

  上面的代码相对较多,对某些函数的使用不清楚的话,请参考MSDN,它包含了高级界面处理、注册表的操作等内容,也许刚开始看起来可能感到有些困难,但是如果读者朋友细细品味的话,一定可以学到一些东西,对今后程序的界面开发有所帮助。
分享到:
评论

相关推荐

    8.IE浏览器操作演示(Visual C++编程 源代码)

    8.IE浏览器操作演示(Visual C++编程 源代码)8.IE浏览器操作演示(Visual C++编程 源代码)8.IE浏览器操作演示(Visual C++编程 源代码)8.IE浏览器操作演示(Visual C++编程 源代码)8.IE浏览器操作演示(Visual ...

    8.如何获取IE浏览器标题内容?(Visual C++编程 源代码)

    8.如何获取IE浏览器标题内容?(Visual C++编程 源代码)8.如何获取IE浏览器标题内容?(Visual C++编程 源代码)8.如何获取IE浏览器标题内容?(Visual C++编程 源代码)8.如何获取IE浏览器标题内容?(Visual C++...

    visual c++编程控制ie浏览器自动刷新,AutoRefresh.rar

    vc++编程控制ie浏览器自动刷新,AutoRefresh.rar

    用Visual C++打造IE浏览器

     IE浏览器作为微软Windows系统捆绑销售的一个浏览工具,用来浏览千姿百态的网页,目前它已经占据了浏览器市场的半壁江山,成为Windows用户不可或缺的工具。首先,它的界面设计的很漂亮,如扁平按纽(按钮上的图像为...

    visual c++开发基于IE内核的浏览器 源代码.zip

    vc开发基于IE内核的浏览器 源代码.zip

    EDA/PLD中的用Visual C++打造IE浏览器

     IE浏览器作为微软Windows系统捆绑销售的一个浏览工具,用来浏览千姿百态的网页,目前它已经占据了浏览器市场的半壁江山,成为Windows用户不可或缺的工具。首先,它的界面设计的很漂亮,如扁平按纽(按钮上的图像为...

    Visual C++程序开发范例宝典 - 第7章

    7.2 IE浏览器设置 实例254 修改IE浏览器标题栏内容 实例255 隐藏IE浏览器的右键关联菜单 实例256 设置IE浏览器的默认主页 实例257 清空上网历史记录 7.3 文件控制 实例258 如何建立文件关联 实例259 控制光驱的自动...

    Visual C++程序开发范例宝典(光盘) 第八部分

    实例196 隐藏IE浏览器的右键关联菜单 实例197 设置IE的默认主页 实例198 清空上网历史记录 7.3 文件控制 实例199 如何建立文件关联 实例200 控制光驱的自动运行功能 7.4 游戏设置 实例201 设置“蜘蛛纸牌”...

    用VC开发IE浏览器插件:IE Toolbar.zip

    用Visual c++开发IE浏览器插件:IE 工具条Toolbar

    Visual C++编程技巧精选500例.pdf

    054 如何获取IE浏览器标题内容? 055 如何取消标题栏的右键系统菜单? 056 如何在标题栏右键菜单中增加菜单项? 057 如何动态增加菜单? 058 如何动态删除菜单? 059 如何启用和禁用菜单命令? 060 如何为菜单添加复选标记...

    Visual C++网络通信编程实用案例精选 配套源码

    软件平台:操作系统为Windows 98/Me/NT/2000/XP(推荐使用Windows 2000/XP),调试环境为Visual C++ 6.0及其以上版本(如果不做说明,则默认为Visual C++ 6.0)。 2.光盘的使用方法及注意事项 将本书的源代码拷入...

    Visual C++ 程序开发范例宝典 源码 光盘 part2

    7.2 IE设置 cc实例195 修改IE标题栏内容 cc实例196 隐藏IE浏览器的右键关联菜单 cc实例197 设置IE的默认主页 cc实例198 清空上网历史记录 7.3 文件控制 cc实例199 如何建立文件关联 cc实例200 控制...

    IEliulanqi.rar_IELUELANQI_IEliulai_IEliulanqi_ieliulan_ie浏览器

    利用Visual c++.net 编写的 IE浏览器操作演示 程序。代码都有注释。对初学者很有帮助。能实现:清空IE历史记录及IE地址栏历史记录;添加IE浏览器收藏夹内容;使用缺省浏览器打开指定网页等。

    Visual C++编程技巧精选集 光盘

    94.如何获取IE浏览器窗口的标题栏文字 95.如何修改IE浏览器的标题栏内容 96.如何禁止标题栏响应鼠标双击事件 97.如何在标题栏右键菜单中新增菜单项 98.如何禁止单文档程序的关闭按钮 99.如何禁止单文档程序的最大化...

    Visual C++程序开发范例宝典(PDF扫描版).part2

     cc实例196 隐藏IE浏览器的右键关联菜单   cc实例197 设置IE的默认主页   cc实例198 清空上网历史记录   7.3 文件控制   cc实例199 如何建立文件关联   cc实例200 控制光驱的自动运行功能   7.4...

    Visual C++程序开发范例宝典(PDF扫描版).part3

     cc实例196 隐藏IE浏览器的右键关联菜单   cc实例197 设置IE的默认主页   cc实例198 清空上网历史记录   7.3 文件控制   cc实例199 如何建立文件关联   cc实例200 控制光驱的自动运行功能   7.4...

    Visual C++网络通信编程实用案例精选_9(全)

    本书是一本介绍利用Visual C++进行网络通信程序开发的书籍,书中精选了大量网络实例,涵盖了本地计算机网络编程,局域网网络通信编程,IE编程,网络通信协议编程,串口通信编程,代理服务器编程和高级网络通信编程。...

    Visual+C++网络通信编程实用案例精选

    l映射网络驱动器【\chap3\Neighbor】 l消息发送程序Net Send【\chap3\Neighbor】 l获取局域网内其他计算机的信息【\chap3\ NeighborInfo】 (4)IE编程实例 简单的浏览器的实现【\chap4\MyBrowser】 删除IE相关历史...

Global site tag (gtag.js) - Google Analytics