home *** CD-ROM | disk | FTP | other *** search
- // browseView.cpp : implementation of the CBrowseView class
- //
-
- #include "stdafx.h"
- #include "afxdisp.h"
- #include "browse.h"
-
- #include "browseDoc.h"
- #include "browseView.h"
- #include "MainFrm.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CBrowseView
-
- IMPLEMENT_DYNCREATE(CBrowseView, CView)
-
- BEGIN_MESSAGE_MAP(CBrowseView, CView)
- //{{AFX_MSG_MAP(CBrowseView)
- ON_WM_SHOWWINDOW()
- ON_WM_SIZE()
- ON_WM_CREATE()
- //}}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()
-
- BEGIN_EVENTSINK_MAP(CBrowseView, CView)
- ON_EVENT(CBrowseView, IDC_WBC, 0x71, OnTitleChange, VTS_BSTR)
- ON_EVENT(CBrowseView, IDC_WBC, 0x66, OnStatusTextChange, VTS_BSTR)
- END_EVENTSINK_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CBrowseView construction/destruction
-
- CBrowseView::CBrowseView()
- {
- // TODO: add construction code here
-
- m_pBrowse= NULL;
-
- }
-
- CBrowseView::~CBrowseView()
- {
- }
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CBrowseView drawing
-
- void CBrowseView::OnDraw(CDC* pDC)
- {
- CBrowseDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
-
-
- // TODO: Add your specialized code here and/or call the base class
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CBrowseView printing
-
- BOOL CBrowseView::OnPreparePrinting(CPrintInfo* pInfo)
- {
- // default preparation
- return DoPreparePrinting(pInfo);
- }
-
- void CBrowseView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add extra initialization before printing
- }
-
- void CBrowseView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
- {
- // TODO: add cleanup after printing
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CBrowseView diagnostics
-
- #ifdef _DEBUG
- void CBrowseView::AssertValid() const
- {
- CView::AssertValid();
- }
-
- void CBrowseView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
-
- CBrowseDoc* CBrowseView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBrowseDoc)));
- return (CBrowseDoc*)m_pDocument;
- }
- #endif //_DEBUG
-
- /////////////////////////////////////////////////////////////////////////////
- // CBrowseView message handlers
-
- void CBrowseView::OnShowWindow(BOOL bShow, UINT nStatus)
- {
- CView::OnShowWindow(bShow, nStatus);
-
- // TODO: Add your message handler code here
-
-
- }
-
-
- void CBrowseView::OnSize(UINT nType, int cx, int cy)
- {
- CView::OnSize(nType, cx, cy);
-
- // TODO: Add your message handler code here
-
- if (m_pBrowse) {
- m_pBrowse->SetWidth(cx);
- m_pBrowse->SetHeight(cy);
- }
-
- }
-
- int CBrowseView::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CView::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- // TODO: Add your specialized creation code here
-
- // Define the area where the control will reside.
- CRect rect;
- GetClientRect(&rect);
- //
- // Create the control.
- // IDC_WBC is a unique identifier for the control and was defined
- // using a dummy menu item.
- m_pBrowse= new CWebBrowser;
- ASSERT(m_pBrowse);
- if (!m_pBrowse->Create(NULL,NULL, WS_VISIBLE,rect,this, IDC_WBC)) {
- TRACE("failed to create browser\n");
- return 0;
- }
- // Initialize the first URL.
- COleVariant noArg;
- m_pBrowse->Navigate("www.microsoft.com",&noArg,&noArg,&noArg,&noArg);
-
- return 0;
- }
-
- // Adding an event handler.
- void CBrowseView::OnTitleChange(LPCTSTR Text)
- {
- CString strTitle;
- strTitle.Format("MyBrowser - %s", Text);
- AfxGetMainWnd()->SetWindowText(strTitle);
- }
-
-
- // Need to indirectly call mainframe since the control is
- // a child of this view class, ie events only come to this class.
- void CBrowseView::OnStatusTextChange(LPCTSTR text)
- {
- // Only write to status line if there is a non-zero string.
- // (lstrlen work on either ANSI or UNICODE strings.)
- if (lstrlen(text))
- ((CMainFrame*)AfxGetMainWnd())->Status(text);
- }
-