// MainFrm.cpp : implmentation of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "aboutdlg.h"
#include "TaskbarDemoView.h"
#include "MainFrm.h"
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if(CFrameWindowImpl<CMainFrame>::PreTranslateMessage(pMsg))
return TRUE;
if(pMsg->message == _WMTaskbarButtonCreated)
{
//ToDo::TaskbarBtn Created
OnTaskbarCreated();
}
return m_view.PreTranslateMessage(pMsg);
}
BOOL CMainFrame::OnIdle()
{
UIUpdateToolBar();
return FALSE;
}
LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
_WMTaskbarButtonCreated = ::RegisterWindowMessage(L"TaskbarButtonCreated");
::ChangeWindowMessageFilter(_WMTaskbarButtonCreated, MSGFLT_ADD);
m_bProgress = FALSE;
m_nProgress = 0;
// create command bar window
HWND hWndCmdBar = m_CmdBar.Create(m_hWnd, rcDefault, NULL, ATL_SIMPLE_CMDBAR_PANE_STYLE);
// attach menu
m_CmdBar.AttachMenu(GetMenu());
// load command bar images
m_CmdBar.LoadImages(IDR_MAINFRAME);
// remove old menu
SetMenu(NULL);
HWND hWndToolBar = CreateSimpleToolBarCtrl(m_hWnd, IDR_MAINFRAME, FALSE, ATL_SIMPLE_TOOLBAR_PANE_STYLE);
CreateSimpleReBar(ATL_SIMPLE_REBAR_NOBORDER_STYLE);
AddSimpleReBarBand(hWndCmdBar);
AddSimpleReBarBand(hWndToolBar, NULL, TRUE);
CreateSimpleStatusBar();
m_hWndClient = m_view.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
UIAddToolBar(hWndToolBar);
UISetCheck(ID_VIEW_TOOLBAR, 1);
UISetCheck(ID_VIEW_STATUS_BAR, 1);
// register object for message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->AddMessageFilter(this);
pLoop->AddIdleHandler(this);
CMenuHandle menuMain = m_CmdBar.GetMenu();
m_view.SetWindowMenu(menuMain.GetSubMenu(WINDOW_MENU_POSITION));
return 0;
}
LRESULT CMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)
{
// unregister message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->RemoveMessageFilter(this);
pLoop->RemoveIdleHandler(this);
bHandled = FALSE;
return 1;
}
LRESULT CMainFrame::OnFileExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
PostMessage(WM_CLOSE);
return 0;
}
LRESULT CMainFrame::OnFileNew(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CTaskbarDemoView* pView = new CTaskbarDemoView;
pView->Create(m_view, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0);
m_view.AddPage(pView->m_hWnd, _T("Document"));
// TODO: add code to initialize document
return 0;
}
LRESULT CMainFrame::OnViewToolBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
static BOOL bVisible = TRUE; // initially visible
bVisible = !bVisible;
CReBarCtrl rebar = m_hWndToolBar;
int nBandIndex = rebar.IdToIndex(ATL_IDW_BAND_FIRST + 1); // toolbar is 2nd added band
rebar.ShowBand(nBandIndex, bVisible);
UISetCheck(ID_VIEW_TOOLBAR, bVisible);
UpdateLayout();
return 0;
}
LRESULT CMainFrame::OnViewStatusBar(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
BOOL bVisible = !::IsWindowVisible(m_hWndStatusBar);
::ShowWindow(m_hWndStatusBar, bVisible ? SW_SHOWNOACTIVATE : SW_HIDE);
UISetCheck(ID_VIEW_STATUS_BAR, bVisible);
UpdateLayout();
return 0;
}
LRESULT CMainFrame::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
CAboutDlg dlg;
dlg.DoModal();
return 0;
}
LRESULT CMainFrame::OnWindowClose(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
int nActivePage = m_view.GetActivePage();
if(nActivePage != -1)
m_view.RemovePage(nActivePage);
else
::MessageBeep((UINT)-1);
return 0;
}
LRESULT CMainFrame::OnWindowCloseAll(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
m_view.RemoveAllPages();
return 0;
}
LRESULT CMainFrame::OnWindowActivate(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
int nPage = wID - ID_WINDOW_TABFIRST;
m_view.SetActivePage(nPage);
return 0;
}
LRESULT CMainFrame::OnTaskbarCreated()
{
::CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&_pTaskbar));
_pTaskbar->HrInit();
//TabWindow::EnableCustomPreviews(_hwnd);
return S_OK;
}
LRESULT CMainFrame::OnTaskbaropShowthumbnail(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: Add your command handler code here
HICON hicon = ::LoadIcon(NULL, MAKEINTRESOURCE(IDI_SHIELD));
HRESULT hr = _pTaskbar->SetOverlayIcon(m_hWnd, hicon, L"Spelling error");
hr = _pTaskbar->SetProgressState(m_hWnd, TBPF_INDETERMINATE);
return 0;
}
LRESULT CMainFrame::OnTaskbaropShowprogress(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
// TODO: Add your command handler code here
m_bProgress = !m_bProgress;
if(m_bProgress)
{
SetTimer(1, 1000);
}
else
{
KillTimer(1);
_pTaskbar->SetProgressValue(m_hWnd, 0, 10);
}
return 0;
}
LRESULT CMainFrame::OnTimer(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
// TODO: Add your message handler code here and/or call default
if(m_bProgress)
{
_pTaskbar->SetProgressValue(m_hWnd, m_nProgress++, 10);
}
return 0;
}
RandomName
- 粉丝: 3
- 资源: 13
最新资源
- MATLAB经典数学建模代码.zip
- MATLAB实现的各种非线性规划算法.zip
- MATLAB实时交互式语音工具本系列是过时的SP3ARK系列将会更新.zip
- MATLAB实现的一个基本HOG SVM行人检测器.zip
- matlab学位论文绘图辅助工具.zip
- MATLAB同步压缩工具箱.zip
- matlab协同过滤MovieLens数据电影推荐系统.zip
- MATLAB移动机器人导航示例代码.zip
- 反激变器设计 指标: 1输入可调200-1000直流电源 2输出三路直流稳压电源分别为:+15 V 2A、-15 V 0.5A 和+24 V 1A;±15V 输出的稳压精度为 2%,24V 输
- MATLAB应用程序访问ChatGPT API从OpenAI.zip
- MATLAB应用程序对近红外光谱数据进行处理和可视化.zip
- MATLAB中常用的相位检索算法包括ER、HIO、DM、ASR、RAAR.zip
- MATLAB张量工具.zip
- MATLAB与NS3联合仿真.zip
- MATLAB中的深度学习变压器模型.zip
- MATLAB中的快速线性代数.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈