#include "SRCommandBar.h" using namespace SRFramework; SRCommandBar::SRCommandBar(void) { } SRCommandBar::~SRCommandBar(void) { } BOOL SRCommandBar::Create(SRWnd* pWndParent, UINT nBarID) { SHMENUBARINFO mbi; ZeroMemory(&mbi, sizeof(SHMENUBARINFO)); if(!pWndParent) return FALSE; mbi.cbSize = sizeof(SHMENUBARINFO); mbi.hwndParent = pWndParent->GetWindowHandle(); mbi.nToolBarId = nBarID; mbi.hInstRes = SRApp::GetInstanceHandle(); mbi.dwFlags = SHCMBF_HMENU; if(SHCreateMenuBar(&mbi)){ m_hWndCB = mbi.hwndMB; return TRUE; } return FALSE; } INT SRCommandBar::Height() { RECT MenuBarRect; GetWindowRect(m_hWndCB, &MenuBarRect); return MenuBarRect.bottom - MenuBarRect.top; } BOOL SRCommandBar::Show() { if(m_hWndCB) return ::CommandBar_Show(m_hWndCB, TRUE); return FALSE; } BOOL SRCommandBar::Hide() { if(m_hWndCB) return ::CommandBar_Show(m_hWndCB, FALSE); return FALSE; } HMENU SRCommandBar::GetSubMenu(UINT nPos) { TBBUTTON tb = {0}; ::SendMessage(m_hWndCB, TB_GETBUTTON, nPos, (LPARAM)&tb); return (HMENU)::SendMessage(m_hWndCB,SHCMBM_GETSUBMENU, 0, tb.idCommand); } void SRCommandBar::RedrawMenu() { DrawMenuBar(m_hWndCB); }