📄 mainfrm.cpp
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "InternetEx.h"
#include "MainFrm.h"
#include "InternetExDoc.h"
#include "InternetExView.h"
#include "ModalDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_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_MAP
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
// TODO: add member initialization code here
m_nWindowCount = 0;
m_nDlgCount = 0;
m_strModalDlgInfo.nWidth=0;
m_strModalDlgInfo.nHeight = 0;
m_strModalDlgInfo.nLeft = 0;
m_strModalDlgInfo.nTop = 0;
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
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
}
// TODO: Delete these three lines if you don't want the toolbar to
// be dockable
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
return 0;
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CFrameWnd::PreCreateWindow(cs) )
return FALSE;
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
cs.style &= ~FWS_ADDTOTITLE;
cs.cy = ::GetSystemMetrics(SM_CYSCREEN) - 28;
cs.cx = ::GetSystemMetrics(SM_CXSCREEN);
cs.y = 0;
cs.x = 0;
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
BOOL CMainFrame::CB_IsOurCustomBrowser()
{
//return true because this is obviously our
//custom browser
return true;
}
void CMainFrame::CB_CustomFunction()
{
AfxMessageBox("可以在此做你想做的事情!");
CInternetExView* pView = (CInternetExView*)GetActiveView();
pView->Navigate();
}
void CMainFrame::CB_CustomFunctionWithParams(CString cszString, int nNumber)
{
CString cszParameters;
cszParameters.Format("参数 1: %s\n参数 2: %d", cszString, nNumber);
AfxMessageBox(cszParameters);
CInternetExView* pView = (CInternetExView*)GetActiveView();
pView->Navigate();
}
void CMainFrame::CB_OpenWindow(CString cszURL, int nLeft, int nTop, int nWidth, int nHeight, int nResizable)
{
m_Window[m_nWindowCount].Create(IDD_WINDOW);
m_Window[m_nWindowCount].SetWindowPos(NULL,nLeft, nTop, nWidth, nHeight,NULL);
m_Window[m_nWindowCount].m_cszURL = cszURL;
m_Window[m_nWindowCount].ShowWindow(SW_SHOW);
m_nWindowCount++;
}
void CMainFrame::CB_ShowModalDialog(CString cszURL, int nLeft, int nTop, int nWidth, int nHeight)
{
CModalDlg modaldlg;
m_strModalDlgInfo.cszURL = cszURL;
m_strModalDlgInfo.nWidth = nWidth;
m_strModalDlgInfo.nHeight = nHeight;
m_strModalDlgInfo.nLeft = nLeft;
m_strModalDlgInfo.nTop = nTop;
modaldlg.DoModal();
}
void CMainFrame::CB_ShowModelessDialog(CString cszURL, int nLeft, int nTop, int nWidth, int nHeight)
{
m_Dlg[m_nDlgCount].Create(IDD_MODELESS_DIALOG);
m_Dlg[m_nDlgCount].SetWindowPos(NULL,nLeft, nTop, nWidth, nHeight,NULL);
m_Dlg[m_nDlgCount].m_cszURL = cszURL;
m_Dlg[m_nDlgCount].ShowWindow(SW_SHOW);
m_nDlgCount++;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -