📄 workspacebar.cpp
字号:
// WorkSpaceBar.cpp : implementation file
//
/////////////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#include "Resource.h"
#include "WorkSpaceBar.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWorkSpaceBar
CWorkSpaceBar::CWorkSpaceBar()
{
NONCLIENTMETRICS ncm;
memset(&ncm, 0, sizeof(NONCLIENTMETRICS));
ncm.cbSize = sizeof(NONCLIENTMETRICS);
VERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
sizeof(NONCLIENTMETRICS), &ncm, 0));
m_Font.CreateFontIndirect(&ncm.lfMessageFont);
}
CWorkSpaceBar::~CWorkSpaceBar()
{
// TODO: add destruction code here.
}
IMPLEMENT_DYNAMIC(CWorkSpaceBar, CCJControlBar)
BEGIN_MESSAGE_MAP(CWorkSpaceBar, CCJControlBar)
//{{AFX_MSG_MAP(CWorkSpaceBar)
ON_WM_CREATE()
ON_WM_SIZE()
ON_WM_RBUTTONDOWN()
//}}AFX_MSG_MAP
ON_MESSAGE(WM_OUTBAR_NOTIFY, OnOutbarNotify)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWorkSpaceBar message handlers
int CWorkSpaceBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CCJControlBar::OnCreate(lpCreateStruct) == -1)
return -1;
DWORD dwStyle =
CGfxOutBarCtrl::fDragItems |
CGfxOutBarCtrl::fEditGroups |
CGfxOutBarCtrl::fEditItems |
CGfxOutBarCtrl::fRemoveGroups |
CGfxOutBarCtrl::fRemoveItems |
CGfxOutBarCtrl::fAddGroups |
CGfxOutBarCtrl::fAnimation;
// Here we create the outbar control; we give as id the parent splitter pane id here
if (!m_wndOutlookBar.Create(WS_CHILD|WS_VISIBLE, CRect(0,0,0,0),
this,IDC_OUTLOOKBAR, dwStyle))
{
TRACE0("Failed to create outlook bar.");
return FALSE;
}
// Tell the control to send message to this window (the mainframe)
// and not to its real parent (the splitter)
m_wndOutlookBar.SetOwner(this);
// Here we create the imagelists for the control
m_ImageSmall.Create (16, 16, TRUE, 2, 1);
m_ImageLarge.Create (32, 32, TRUE, 2, 1);
//----------------加载图标-----------------------------
HICON hIcon = AfxGetApp()->LoadIcon(IDI_ANYSIMULATE);
ASSERT(hIcon);
m_ImageSmall.Add(hIcon);
m_ImageLarge.Add(hIcon);
hIcon = AfxGetApp()->LoadIcon(IDI_ANALYSE);
ASSERT(hIcon);
m_ImageSmall.Add(hIcon);
m_ImageLarge.Add(hIcon);
//-----------------------------------------------------
// and we link them to the control
m_wndOutlookBar.SetImageList(&m_ImageLarge, CGfxOutBarCtrl::fLargeIcon);
m_wndOutlookBar.SetImageList(&m_ImageSmall, CGfxOutBarCtrl::fSmallIcon);
m_wndOutlookBar.SetAnimationTickCount(20);
// m_wndOutlookBar.SetAnimSelHighlight(200);
// Look at function reference for information about linking image list
// Here we can add the folders to the control; we need at least one folder.
// The numbers aside the text are an "lParam" value we can assign to each folder
m_wndOutlookBar.AddFolder(_T("随机模拟"),FOLDER_0);
m_wndOutlookBar.AddFolder(_T("数据分析"),FOLDER_1);
// Here we insert the items; syntax is folder, index, text, image, lParam value for item
m_wndOutlookBar.InsertItem(FOLDER_0, CMD_00, _T("随机模拟"),0,0);
m_wndOutlookBar.InsertItem(FOLDER_1, CMD_00, _T("数据分析"),0, 0);
m_wndOutlookBar.SetSelFolder(0);
return 0;
}
void CWorkSpaceBar::OnSize(UINT nType, int cx, int cy)
{
CCJControlBar::OnSize(nType, cx, cy);
if(m_wndOutlookBar.GetSafeHwnd())
{
m_wndOutlookBar.MoveWindow(0,17,cx+2,cy-17);
}
}
long CWorkSpaceBar::OnOutbarNotify(WPARAM wParam,LPARAM lParam)
{
int nIndex;
int nFolder;
CString str;
char* p;
this->m_pMainFrame=(CMainFrame*)::AfxGetApp()->m_pMainWnd;
switch (wParam)
{
case NM_OB_ITEMCLICK:
// Get the current folder.
nFolder = m_wndOutlookBar.GetSelFolder();
//得到当前选择
nIndex = (int)lParam;
str=m_wndOutlookBar.GetItemText(nIndex);
if(str=="随机模拟")
nIndex=0;
else
{
str=str.Right(str.GetLength()-4);
p=(LPSTR)(LPCTSTR)str;
nIndex=atoi(p);
}
m_pMainFrame->ChangeView(nFolder,nIndex);
//改变输出栏视图
m_pMainFrame->ChangeOutputView(nFolder);
::AfxGetMainWnd()->SetWindowText("超微弱发光聚光腔设计模拟系统");
if(nFolder==1)//数据分析
m_pMainFrame->AnalyseData();
default:
break;
}
return 0;
}
void CWorkSpaceBar::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
GetCursorPos(&point);
CMenu menu;
VERIFY(menu.LoadMenu(IDR_MENU_OUTLOOKBAR));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
CWnd* pWndPopupOwner = this;
while (pWndPopupOwner->GetStyle() & WS_CHILD)
pWndPopupOwner = pWndPopupOwner->GetParent();
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,pWndPopupOwner);
CCJControlBar::OnRButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -