IEView.cpp
上传用户:huashan618
上传日期:2013-03-26
资源大小:261k
文件大小:5k
- // IEView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "IEView.h"
- #include "resource.h"
- #include "..\PPExplorer.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- #include "..\myframewnd.h"
- #include ".ieview.h"
- /////////////////////////////////////////////////////////////////////////////
- // CIEView
- extern CMyFrameWnd* g_frame;
- extern CPPExplorerApp theApp;
- IMPLEMENT_DYNCREATE(CIEView, CHtmlView)
- CIEView::CIEView()
- {
- //{{AFX_DATA_INIT(CIEView)
- // m_showStatus=FALSE;
- //}}AFX_DATA_INIT
- }
- CIEView::~CIEView()
- {
- }
- void CIEView::DoDataExchange(CDataExchange* pDX)
- {
- CHtmlView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CIEView)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CIEView, CHtmlView)
- //{{AFX_MSG_MAP(CIEView)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- ON_WM_CREATE()
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CIEView diagnostics
- #ifdef _DEBUG
- void CIEView::AssertValid() const
- {
- CHtmlView::AssertValid();
- }
- void CIEView::Dump(CDumpContext& dc) const
- {
- CHtmlView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CIEView message handlers
- void CIEView::OnInitialUpdate()
- {
- //TODO: This code navigates to a popular spot on the web.
- //Change the code to go where you'd like.
- //Navigate2(_T("http://www.microsoft.com/visualc/"),NULL,NULL);
- //主动调整大小
- GoHome();
- }
- BOOL CIEView::PreCreateWindow(CREATESTRUCT& cs)
- {
- cs.style=WS_CHILD|WS_VISIBLE|WS_BORDER;
- return CHtmlView::PreCreateWindow(cs);
- }
- void CIEView::OnTitleChange(LPCTSTR lpszText)
- {
- SetTabItemText(lpszText);
- m_strTitle=lpszText;
- CHtmlView::OnTitleChange(lpszText);
- }
- void CIEView::OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags, LPCTSTR lpszTargetFrameName, CByteArray& baPostedData, LPCTSTR lpszHeaders, BOOL* pbCancel)
- {
- CRect rc;
- GetParent()->GetClientRect(&rc);
- SendMessage(WM_SIZE,SIZE_MAXSHOW,MAKELPARAM(rc.Width(),rc.Height()));
- if(m_bActivedWnd && IsWindowVisible())
- {
- g_frame->SetAddressBarText(GetLocationURL());
- m_strTitle=lpszURL;
- }
- if(!GetStatusBar())
- {
- //MessageBox("aaa");
- }
- CHtmlView::OnBeforeNavigate2(lpszURL, nFlags, lpszTargetFrameName, baPostedData, lpszHeaders, pbCancel);
- }
- void CIEView::OnNavigateComplete2(LPCTSTR strURL)
- {
- g_frame->AddHistory(strURL,m_strTitle);
- if(m_bActivedWnd && IsWindowVisible())
- {
- g_frame->SetAddressBarText(GetLocationURL());
- COleVariant vaZoomFactor;
- ExecWB(OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,NULL,&vaZoomFactor);
- }
- CHtmlView::OnNavigateComplete2(strURL);
- }
- //获取系统传来的创建一新窗口的消息,在本系统中,增加一新的TAB窗口
- void CIEView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
- {
- // TODO: Add your specialized code here and/or call the base class
- Cancel=FALSE;
- LRESULT pResult=theApp.m_pMainWnd->SendMessage(WM_NEW_IEVIEW);//g_frame->SendMessage(WM_NEW_IEVIEW);//AfxGetMainWnd()->SendMessage(WM_NEW_IEVIEW);
- if(!pResult)
- {
- AfxMessageBox("所创建的新窗口不存在!");
- return;
- }g_frame->SetAddressBarText(GetLocationURL());
- CWnd* pWnd=(CWnd*)pResult;
- ASSERT(pWnd->IsKindOf(RUNTIME_CLASS(CIEView)));
- *ppDisp=((CIEView*)pWnd)->GetApplication();
- //CHtmlView::OnNewWindow2(ppDisp, Cancel);
- }
- BOOL CIEView::SetTabItemText(LPCTSTR lpszItem)
- {
- g_frame->SetTabCtrlTitle(lpszItem);
- return TRUE;
- }
- void CIEView::ReadUrlDocument(LPCTSTR lpszUrl)
- {
- Navigate2(lpszUrl,NULL,NULL);
- }
- void CIEView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
- {
- // TODO: Add your specialized code here and/or call the base class
- /* if(bActivate && IsWindowVisible())
- {
- SetUrlAddress(GetLocationURL());
- ((CMainFrame*)AfxGetMainWnd())->SetWindowTextX(m_strTitle);
- COleVariant vaZoomFactor;
- ExecWB(OLECMDID_ZOOM,OLECMDEXECOPT_DONTPROMPTUSER,NULL,&vaZoomFactor);
- ((CMainFrame*)AfxGetMainWnd())->SetFontSizeVal(vaZoomFactor.intVal*10+1);
- EnableFrameButton();
- }
- m_bActivedWnd=bActivate;*/
- CHtmlView::OnActivateView(bActivate, pActivateView, pDeactiveView);
- }
- void CIEView::OnDocumentComplete(LPCTSTR lpszURL)
- {
- CHtmlView::OnDocumentComplete(lpszURL);
- }
- CString CIEView::GetTitle()
- {
- return m_strTitle;
- }
- //通知程序,WEB浏览器命令的激活状态已修改
- void CIEView::OnCommandStateChange(long nCommand, BOOL bEnable)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(nCommand==1)//前进
- {
- m_bEnableGoForward=bEnable;
- }
- if(nCommand==2)//后退
- {
- m_bEnableGoBack=bEnable;
- }
- if(m_bActivedWnd && IsWindowVisible())
- {
- EnableFrameButton();
- }
- CHtmlView::OnCommandStateChange(nCommand, bEnable);
- }
- void CIEView::EnableFrameButton()
- {
- g_frame->EnableGoBack(m_bEnableGoBack);
- g_frame->EnableGoForward(m_bEnableGoForward);
- }
- void CIEView::OnStatusTextChange(LPCTSTR lpszText)
- {
- CHtmlView::OnStatusTextChange(lpszText);
- ::PostMessage(m_hostwnd,WM_STATUS_MESSAGE,0,(LPARAM)lpszText);
- }
- int CIEView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CHtmlView::OnCreate(lpCreateStruct) == -1)
- return -1;
- m_hostwnd=lpCreateStruct->hwndParent;
- return 0;
- }