📄 uiframewnd.cpp
字号:
//*******************************************************************************
// COPYRIGHT NOTES
// ---------------
// You may use this source code, compile or redistribute it as part of your application
// for free. You cannot redistribute it as a part of a software development
// library without the agreement of the author. If the sources are
// distributed along with the application, you should leave the original
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES at your own risk.
//
// For the latest updates to this code, check this site:
// http://www.masmex.com
// after Sept 2000
//
// Copyright(C) 2000 Philip Oldaker <email: philip@masmex.com>
//*******************************************************************************
#include "stdafx.h"
#include "UIFrameWnd.h"
#include "UIApp.h"
#include "UIres.h"
#include "UIMessages.h"
#include "WindowPlacement.h"
#include "IEShellTreeView.h"
#include "IEShellListView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static UINT nMsgMouseWheel =
(((::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 4)) ||
(!(::GetVersion() & 0x80000000) && LOBYTE(LOWORD(::GetVersion()) == 3)))
? ::RegisterWindowMessage(MSH_MOUSEWHEEL) : 0;
LPCTSTR CUIFrameWnd::szMainFrame = _T("MainFrame");
IMPLEMENT_DYNAMIC(CUIFrameWnd, CFrameWnd)
CUIFrameWnd::CUIFrameWnd() : m_IDToolbar(0),m_pwndCoolBar(NULL)
{
m_bReportCtrl = false;
}
CUIFrameWnd::~CUIFrameWnd()
{
delete m_pwndCoolBar;
}
void CUIFrameWnd::RestoreWindow(UINT nCmdShow)
{
// Load window placement from profile
CWindowPlacement wp;
if (!wp.Restore(CUIFrameWnd::szMainFrame, this))
{
ShowWindow(nCmdShow);
}
}
CUIStatusBar &CUIFrameWnd::GetStatusBar()
{
return m_wndStatusBar;
}
CReallyCoolBar &CUIFrameWnd::GetCoolBar()
{
ASSERT(m_pwndCoolBar);
return *m_pwndCoolBar;
}
void CUIFrameWnd::CreateCoolBar()
{
if (m_pwndCoolBar == NULL)
m_pwndCoolBar = new CReallyCoolBar;
}
CCoolMenuManager &CUIFrameWnd::GetMenuManager()
{
return m_menuManager;
}
BEGIN_MESSAGE_MAP(CUIFrameWnd, CFrameWnd)
//{{AFX_MSG_MAP(CUIFrameWnd)
ON_WM_INITMENUPOPUP()
ON_WM_MENUSELECT()
ON_WM_CREATE()
ON_WM_CLOSE()
ON_WM_MOUSEWHEEL()
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(nMsgMouseWheel, OnRegisteredMouseWheel)
ON_MESSAGE(WM_APP_CB_IE_SET_EDIT_TEXT,OnCBIESetEditText)
ON_MESSAGE(WM_APP_CB_IE_POPULATE,OnCBIEPopulate)
ON_MESSAGE(WM_APP_CB_IE_SEL_CHANGE,OnCBIESelChange)
ON_MESSAGE(WM_APP_CB_IE_HIT_ENTER,OnCBIEHitEnter)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUIFrameWnd message handlers
BOOL CUIFrameWnd::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
CWinApp *pApp = AfxGetApp();
if (pApp->IsKindOf(RUNTIME_CLASS(CUIApp)))
{
if (((CUIApp*)pApp)->IsMyClassRegistered())
{
cs.lpszClass = ((CUIApp*)pApp)->GetMyClass();
TRACE(_T("Setting to window class %s in CUIFrameWnd\n"),cs.lpszClass);
}
}
if (cs.lpszClass == NULL)
{
cs.lpszClass = AfxRegisterWndClass(
CS_DBLCLKS,
NULL,
NULL,
NULL);
ASSERT(cs.lpszClass);
}
CWindowPlacement wp;
if (wp.GetProfileWP(szMainFrame))
{
CRect rc(wp.rcNormalPosition);
cs.x = rc.left;
cs.y = rc.top;
cs.cx = rc.Width();
cs.cy = rc.Height();
}
return CFrameWnd::PreCreateWindow(cs);
}
void CUIFrameWnd::OnClose()
{
// TODO: Add your message handler code here and/or call default
CWindowPlacement wp;
wp.Save(szMainFrame,this);
CFrameWnd::OnClose();
}
void CUIFrameWnd::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
{
CFrameWnd::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
// store width of first pane and its style
if (GetStatusBar().m_nStatusPane1Width == -1 && GetStatusBar().m_bMenuSelect)
{
UINT nStatusPane1Style;
GetStatusBar().GetPaneInfo(0, GetStatusBar().m_nStatusPane1ID,
nStatusPane1Style, GetStatusBar().m_nStatusPane1Width);
GetStatusBar().SetPaneInfo(0, GetStatusBar().m_nStatusPane1ID,
SBPS_NOBORDERS|SBPS_STRETCH, 16384);
}
}
int CUIFrameWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// if not tool bar set no point in continuing
ASSERT(m_IDToolbar > 0);
if (m_IDToolbar == 0)
return 0;
if (!GetStatusBar().Create(this))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
GetStatusBar().AddPane(ID_SEPARATOR,TRUE);
GetStatusBar().SetPanes(FALSE);
CreateCoolBar();
ASSERT(m_pwndCoolBar);
if (m_pwndCoolBar == NULL)
return -1;
CReallyCoolBar& cb = GetCoolBar();
ASSERT(m_IDToolbar > 0);
cb.SetToolBarID(m_IDToolbar);
VERIFY(cb.Create(this,
WS_CHILD|WS_VISIBLE|WS_BORDER|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|
RBS_TOOLTIPS|RBS_BANDBORDERS|RBS_VARHEIGHT));
cb.SetColors(GetSysColor(COLOR_BTNTEXT),GetSysColor(COLOR_3DFACE));
// install/load cool menus
GetMenuManager().Install(this);
GetMenuManager().LoadToolbar(m_IDToolbar);
if (cb.IsKindOf(RUNTIME_CLASS(CWebBrowserCoolBar)))
GetMenuManager().LoadToolbar(IDB_HOTTOOLBAR);
if (m_bReportCtrl)
{
if (!m_wndFieldChooser.Create(this, IDD_FIELDCHOOSER,
CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY|CBRS_HIDE_INPLACE, ID_VIEW_FIELDCHOOSER))
return -1; // fail to create
EnableDocking(CBRS_ALIGN_ANY);
m_wndFieldChooser.EnableDocking(0);
m_wndFieldChooser.SetWindowText(_T("Field Chooser"));
FloatControlBar(&m_wndFieldChooser, CPoint(100, GetSystemMetrics(SM_CYSCREEN) / 3));
ShowControlBar(&m_wndFieldChooser, FALSE, FALSE);
}
return 0;
}
void CUIFrameWnd::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu)
{
CFrameWnd::OnMenuSelect(nItemID, nFlags, hSysMenu);
// Restore first pane of the statusbar?
if (nFlags == 0xFFFF && hSysMenu == 0 && GetStatusBar().m_nStatusPane1Width != -1)
{
GetStatusBar().m_bMenuSelect = FALSE;
GetStatusBar().SetPaneInfo(0, GetStatusBar().m_nStatusPane1ID, GetStatusBar().m_nStatusPane1Style, GetStatusBar().m_nStatusPane1Width);
GetStatusBar().m_nStatusPane1Width = -1; // Set it to illegal value
}
else
{
GetStatusBar().m_bMenuSelect = TRUE;
}
}
void CUIFrameWnd::GetMessageString( UINT nID, CString& rMessage ) const
{
CFrameWnd::GetMessageString(nID,rMessage);
CUIFrameWnd *pThis = const_cast<CUIFrameWnd*>(this);
if (pThis->GetStatusBar().IsPanes())
pThis->GetStatusBar().SetPaneText(0,rMessage);
}
BOOL CUIFrameWnd::PreTranslateMessage(MSG* pMsg)
{
return m_pwndCoolBar && m_pwndCoolBar->m_wndMenuBar.TranslateFrameMessage(pMsg) ?
TRUE : CFrameWnd::PreTranslateMessage(pMsg);
}
////////////////////////////////////////////////////////////////
// CReallyCoolBar
//
IMPLEMENT_DYNAMIC(CReallyCoolBar, CCoolBar)
IMPLEMENT_DYNAMIC(CWebBrowserCoolBar, CCoolBar)
////////////////
// This is the virtual function you have to override to add bands
//
BOOL CReallyCoolBar::OnCreateBands()
{
//////////////////
// Create menu bar
CMenuBar& mb = m_wndMenuBar;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -