⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htmlframewnd.cpp

📁 beereader source code
💻 CPP
字号:
// HtmlFrameWnd.cpp : implementation file
//

#include "stdafx.h"
#include "BeeReader.h"
#include "HtmlFrameWnd.h"
#include <afxhtml.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CHtmlFrameWnd

IMPLEMENT_DYNCREATE(CHtmlFrameWnd,CXTFrameWnd)

CHtmlFrameWnd::CHtmlFrameWnd()
{
	m_bCreate = FALSE;
}

CHtmlFrameWnd::~CHtmlFrameWnd()
{
}


BEGIN_MESSAGE_MAP(CHtmlFrameWnd, CXTFrameWnd)
	//{{AFX_MSG_MAP(CHtmlFrameWnd)
	ON_WM_CREATE()
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CHtmlFrameWnd message handlers

BOOL CHtmlFrameWnd::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	// TODO: Add your specialized code here and/or call the base class
	CHtmlView *pview;

	// Create a context.
	CCreateContext context;
	pContext = &context;

	// Assign custom view.
	pContext->m_pNewViewClass = RUNTIME_CLASS(CHtmlView);

	// Create the view.
	pview = (CHtmlView *) CreateView(pContext, AFX_IDW_PANE_FIRST);
	if (pview == NULL)
		return FALSE;

	// Notify the view.
	pview->SendMessage(WM_INITIALUPDATE);
	SetActiveView(pview, FALSE);

	return TRUE;
}

int CHtmlFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CXTFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT|TBSTYLE_LIST, WS_CHILD | WS_VISIBLE | CBRS_TOP
		|CBRS_GRIPPER|CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC,CRect(0,0,0,0),IDC_TOOLBAR3) ||
		!m_wndToolBar.LoadToolBar(IDR_TOOLBAR_BROWSER))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
    m_wndToolBar.SetHeight(25);
	m_imageList.Create(16, 16, ILC_COLOR24|ILC_MASK, 8, 1);
	m_bitmap.LoadBitmap(IDB_BROWSER);
	m_imageList.Add(&m_bitmap, RGB(255,0,255));
	m_wndToolBar.GetToolBarCtrl().SetImageList(&m_imageList);
//	m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(IDR_BACK), _T("后退"));
//  m_wndToolBar.SetButtonText(m_wndToolBar.CommandToIndex(IDR_FORWARD), _T("前进"));

	if (!m_wndComboURL.Create(WS_CHILD|WS_VISIBLE|CBS_DROPDOWN|WS_CLIPCHILDREN,
       CRect(0,0,140,150), &m_wndToolBar, IDR_TB_URL ))
	{
		TRACE0("Failed to create combo box.\n");
		return -1;      // fail to create
	}

    m_wndToolBar.InsertControl(&m_wndComboURL);

	m_wndToolBar.AutoSizeToolbar();
	m_bCreate = TRUE;

	return 0;
}

void CHtmlFrameWnd::OnSize(UINT nType, int cx, int cy) 
{
	CXTFrameWnd::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	if( !m_bCreate ) return;

	CRect rect;
	m_wndToolBar.GetClientRect(&rect);
    CRect rcItem;
	m_wndToolBar.GetItemRect(6,&rcItem);
	
    int w = rect.Width()-rcItem.left-10;
    m_wndComboURL.SetWindowPos(NULL,rcItem.left+5,0, w,150, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS);
}

void CHtmlFrameWnd::Browse(CRSSItem *pItem,CString szURL)
{
	if( pItem )
	   szURL = pItem->GetLink();

	if (szURL.Find(":") == -1) 
	{
		if (szURL.Left(1) == "/")
			szURL = "http:" + szURL;
		else
			szURL = "http://" + szURL;
	}

	int iIndex = m_wndComboURL.AddString(szURL);
	if( iIndex != CB_ERR )
	{
		m_wndComboURL.SetCurSel( iIndex );
		CHtmlView *pView;
		pView = (CHtmlView*)GetActiveView();
		pView->Navigate( szURL );
	}
}

void CHtmlFrameWnd::Browse( CString szRssInfo )
{
	m_wndComboURL.SetCurSel(-1);
	m_wndComboURL.UpdateWindow();
	CHtmlView *pView;
	pView = (CHtmlView*)GetActiveView();
	pView->Navigate( szRssInfo );

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -