mirror of
https://github.com/reactos/reactos.git
synced 2025-04-25 08:00:24 +00:00
[shell32]
- Add an initial stub for CMenuBand that creates a menu bar and fills it with contents. However its still not functional svn path=/trunk/; revision=60690
This commit is contained in:
parent
1a21c35d02
commit
3586cb1635
3 changed files with 378 additions and 52 deletions
|
@ -7,57 +7,368 @@
|
|||
*/
|
||||
|
||||
#include "precomp.h"
|
||||
#include <windowsx.h>
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(CMenuBand);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetBandInfo(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO *pdbi)
|
||||
|
||||
BOOL
|
||||
AllocAndGetMenuString(HMENU hMenu, UINT ItemIDByPosition, WCHAR** String)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
int Length;
|
||||
|
||||
Length = GetMenuStringW(hMenu, ItemIDByPosition, NULL, 0, MF_BYPOSITION);
|
||||
|
||||
if(!Length)
|
||||
return FALSE;
|
||||
|
||||
/* Also allocate space for the terminating NULL character */
|
||||
++Length;
|
||||
*String = (PWSTR)HeapAlloc(GetProcessHeap(), 0, Length * sizeof(WCHAR));
|
||||
|
||||
GetMenuStringW(hMenu, ItemIDByPosition, *String, Length, MF_BYPOSITION);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CMenuStaticToolbar::CMenuStaticToolbar(CMenuBand *menuBand)
|
||||
{
|
||||
m_menuBand = menuBand;
|
||||
|
||||
|
||||
m_menuBand = NULL;
|
||||
m_hwnd = NULL;
|
||||
m_hmenu = NULL;
|
||||
m_hwndOwner = NULL;
|
||||
m_dwMenuFlags = NULL;
|
||||
}
|
||||
|
||||
HRESULT CMenuStaticToolbar::GetMenu(
|
||||
HMENU *phmenu,
|
||||
HWND *phwnd,
|
||||
DWORD *pdwFlags)
|
||||
{
|
||||
*phmenu = m_hmenu;
|
||||
*phwnd = m_hwndOwner;
|
||||
*pdwFlags = m_dwMenuFlags;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
|
||||
HRESULT CMenuStaticToolbar::SetMenu(
|
||||
HMENU hmenu,
|
||||
HWND hwnd,
|
||||
DWORD dwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
if (!hwnd)
|
||||
return E_FAIL;
|
||||
|
||||
m_hmenu = hmenu;
|
||||
m_hwndOwner = hwnd;
|
||||
m_dwMenuFlags = dwFlags;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMenuStaticToolbar::ShowWindow(BOOL fShow)
|
||||
{
|
||||
::ShowWindow(m_hwnd, fShow ? SW_SHOW : SW_HIDE);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMenuStaticToolbar::Close()
|
||||
{
|
||||
DestroyWindow(m_hwnd);
|
||||
m_hwnd = NULL;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMenuStaticToolbar::CreateToolbar(HWND hwndParent, DWORD dwFlags)
|
||||
{
|
||||
HWND hwndToolbar;
|
||||
hwndToolbar = CreateWindowEx(TBSTYLE_EX_DOUBLEBUFFER, TOOLBARCLASSNAMEW, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |
|
||||
WS_CLIPCHILDREN | TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT | TBSTYLE_REGISTERDROP | TBSTYLE_LIST | TBSTYLE_FLAT |
|
||||
CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_TOP, 0, 0, 500, 20, m_hwndOwner, NULL,
|
||||
_AtlBaseModule.GetModuleInstance(), 0);
|
||||
if (hwndToolbar == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
::SetParent(hwndToolbar, hwndParent);
|
||||
|
||||
m_hwnd = hwndToolbar;
|
||||
|
||||
/* Identify the version of the used Common Controls DLL by sending the size of the TBBUTTON structure */
|
||||
SendMessageW(m_hwnd, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
||||
|
||||
if (dwFlags & SMINIT_TOPLEVEL)
|
||||
{
|
||||
/* Hide the placeholders for the button images */
|
||||
SendMessageW(m_hwnd, TB_SETIMAGELIST, 0, 0);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMenuStaticToolbar::FillToolbar()
|
||||
{
|
||||
TBBUTTON tbb = {0};
|
||||
int i;
|
||||
PWSTR MenuString;
|
||||
|
||||
tbb.fsState = TBSTATE_ENABLED;
|
||||
tbb.fsStyle = BTNS_DROPDOWN | BTNS_AUTOSIZE;
|
||||
|
||||
for(i = 0; i < GetMenuItemCount(m_hmenu); i++)
|
||||
{
|
||||
if(!AllocAndGetMenuString(m_hmenu, i, &MenuString))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
tbb.idCommand = i;
|
||||
tbb.iString = (INT_PTR)MenuString;
|
||||
|
||||
SendMessageW(m_hwnd, TB_ADDBUTTONS, 1, (LPARAM)(LPTBBUTTON)&tbb);
|
||||
HeapFree(GetProcessHeap(), 0, MenuString);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CMenuStaticToolbar::GetWindow(HWND *phwnd)
|
||||
{
|
||||
if (!phwnd)
|
||||
return E_FAIL;
|
||||
|
||||
*phwnd = m_hwnd;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
CMenuBand::CMenuBand()
|
||||
{
|
||||
m_site = NULL;
|
||||
m_psmc = NULL;
|
||||
m_staticToolbar = NULL;
|
||||
}
|
||||
|
||||
CMenuBand::~CMenuBand()
|
||||
{
|
||||
if (m_site)
|
||||
m_site->Release();
|
||||
|
||||
if (m_psmc)
|
||||
m_psmc->Release();
|
||||
|
||||
if (m_staticToolbar)
|
||||
delete m_staticToolbar;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::Initialize(
|
||||
IShellMenuCallback *psmc,
|
||||
UINT uId,
|
||||
UINT uIdAncestor,
|
||||
DWORD dwFlags)
|
||||
{
|
||||
if(m_psmc)
|
||||
m_psmc->Release();
|
||||
|
||||
m_psmc = psmc;
|
||||
m_uId = uId;
|
||||
m_uIdAncestor = uIdAncestor;
|
||||
m_dwFlags = dwFlags;
|
||||
|
||||
if (m_psmc)
|
||||
m_psmc->AddRef();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetMenuInfo(
|
||||
IShellMenuCallback **ppsmc,
|
||||
UINT *puId,
|
||||
UINT *puIdAncestor,
|
||||
DWORD *pdwFlags)
|
||||
{
|
||||
*ppsmc = m_psmc;
|
||||
*puId = m_uId;
|
||||
*puIdAncestor = m_uIdAncestor;
|
||||
*pdwFlags = m_dwFlags;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::SetMenu(
|
||||
HMENU hmenu,
|
||||
HWND hwnd,
|
||||
DWORD dwFlags)
|
||||
{
|
||||
if (m_staticToolbar == NULL)
|
||||
m_staticToolbar = new CMenuStaticToolbar(this);
|
||||
|
||||
HRESULT hResult = m_staticToolbar->SetMenu(hmenu, hwnd, dwFlags);
|
||||
if (FAILED(hResult))
|
||||
return hResult;
|
||||
|
||||
if (m_site)
|
||||
{
|
||||
HWND hwndParent;
|
||||
|
||||
hResult = m_site->GetWindow(&hwndParent);
|
||||
if (FAILED(hResult))
|
||||
return hResult;
|
||||
|
||||
hResult = m_staticToolbar->CreateToolbar(hwndParent, m_dwFlags);
|
||||
if (FAILED(hResult))
|
||||
return hResult;
|
||||
|
||||
hResult = m_staticToolbar->FillToolbar();
|
||||
}
|
||||
|
||||
return hResult;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetMenu(
|
||||
HMENU *phmenu,
|
||||
HWND *phwnd,
|
||||
DWORD *pdwFlags)
|
||||
{
|
||||
if (m_staticToolbar == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
return m_staticToolbar->GetMenu(phmenu, phwnd, pdwFlags);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::SetSite(IUnknown *pUnkSite)
|
||||
{
|
||||
HWND hwndParent;
|
||||
HRESULT hResult;
|
||||
|
||||
if (m_site != NULL)
|
||||
m_site->Release();
|
||||
|
||||
if (pUnkSite == NULL)
|
||||
return S_OK;
|
||||
|
||||
hwndParent = NULL;
|
||||
hResult = pUnkSite->QueryInterface(IID_IOleWindow, reinterpret_cast<void **>(&m_site));
|
||||
if (SUCCEEDED(hResult))
|
||||
{
|
||||
m_site->GetWindow(&hwndParent);
|
||||
m_site->Release();
|
||||
}
|
||||
if (!::IsWindow(hwndParent))
|
||||
return E_FAIL;
|
||||
|
||||
if (m_staticToolbar != NULL)
|
||||
{
|
||||
m_staticToolbar->CreateToolbar(hwndParent, m_dwFlags);
|
||||
m_staticToolbar->FillToolbar();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetSite(REFIID riid, PVOID *ppvSite)
|
||||
{
|
||||
if (m_site == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
return m_site->QueryInterface(riid, ppvSite);
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetWindow(
|
||||
HWND *phwnd)
|
||||
{
|
||||
if (m_staticToolbar != NULL)
|
||||
return m_staticToolbar->GetWindow(phwnd);
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetBandInfo(
|
||||
DWORD dwBandID,
|
||||
DWORD dwViewMode,
|
||||
DESKBANDINFO *pdbi)
|
||||
{
|
||||
SIZE size;
|
||||
HWND hwnd;
|
||||
HRESULT hResult;
|
||||
|
||||
/* FIXME */
|
||||
if (m_staticToolbar == NULL)
|
||||
return E_FAIL;
|
||||
hResult = m_staticToolbar->GetWindow(&hwnd);
|
||||
if (FAILED(hResult))
|
||||
return hResult;
|
||||
if (hwnd == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
if (pdbi->dwMask & DBIM_MINSIZE)
|
||||
{
|
||||
SendMessageW( hwnd, TB_GETIDEALSIZE, TRUE, (LPARAM)&size);
|
||||
|
||||
pdbi->ptMinSize.x = 0;
|
||||
pdbi->ptMinSize.y = size.cy;
|
||||
}
|
||||
if (pdbi->dwMask & DBIM_MAXSIZE)
|
||||
{
|
||||
SendMessageW( hwnd, TB_GETMAXSIZE, 0, (LPARAM)&size);
|
||||
|
||||
pdbi->ptMaxSize.x = size.cx;
|
||||
pdbi->ptMaxSize.y = size.cy;
|
||||
}
|
||||
if (pdbi->dwMask & DBIM_INTEGRAL)
|
||||
{
|
||||
pdbi->ptIntegral.x = 0;
|
||||
pdbi->ptIntegral.y = 0;
|
||||
}
|
||||
if (pdbi->dwMask & DBIM_ACTUAL)
|
||||
{
|
||||
SendMessageW( hwnd, TB_GETIDEALSIZE, TRUE, (LPARAM)&size);
|
||||
SendMessageW( hwnd, TB_GETIDEALSIZE, FALSE, (LPARAM)&size);
|
||||
|
||||
pdbi->ptActual.x = size.cx;
|
||||
pdbi->ptActual.y = size.cy;
|
||||
}
|
||||
if (pdbi->dwMask & DBIM_TITLE)
|
||||
wcscpy(pdbi->wszTitle, L"");
|
||||
if (pdbi->dwMask & DBIM_MODEFLAGS)
|
||||
pdbi->dwModeFlags = DBIMF_UNDELETEABLE;
|
||||
if (pdbi->dwMask & DBIM_BKCOLOR)
|
||||
pdbi->crBkgnd = 0;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* IDockingWindow */
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::ShowDW(BOOL fShow)
|
||||
{
|
||||
if (m_staticToolbar != NULL)
|
||||
return m_staticToolbar->ShowWindow(fShow);
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::CloseDW(DWORD dwReserved)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
ShowDW(FALSE);
|
||||
|
||||
if (m_staticToolbar != NULL)
|
||||
return m_staticToolbar->Close();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::ResizeBorderDW(LPCRECT prcBorder, IUnknown *punkToolbarSite, BOOL fReserved)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetWindow(HWND *phwnd)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::ContextSensitiveHelp(BOOL fEnterMode)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::SetSite(IUnknown *pUnkSite)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetSite(REFIID riid, PVOID *ppvSite)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
@ -172,18 +483,6 @@ HRESULT STDMETHODCALLTYPE CMenuBand::TranslateMenuMessage(MSG *pmsg, LRESULT *pl
|
|||
return S_FALSE;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::Initialize(IShellMenuCallback *psmc, UINT uId, UINT uIdAncestor,DWORD dwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetMenuInfo(IShellMenuCallback **ppsmc, UINT *puId, UINT *puIdAncestor, DWORD *pdwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::SetShellFolder(IShellFolder *psf, LPCITEMIDLIST pidlFolder, HKEY hKey, DWORD dwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
@ -196,18 +495,6 @@ HRESULT STDMETHODCALLTYPE CMenuBand::GetShellFolder(DWORD *pdwFlags, LPITEMIDLIS
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CMenuBand::InvalidateItem(LPSMDATA psmd, DWORD dwFlags)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
|
|
|
@ -1,4 +1,30 @@
|
|||
|
||||
class CMenuBand;
|
||||
|
||||
class CMenuStaticToolbar
|
||||
{
|
||||
public:
|
||||
CMenuStaticToolbar(CMenuBand *menuBand);
|
||||
|
||||
HRESULT CreateToolbar(HWND hwndParent, DWORD dwFlags);
|
||||
HRESULT FillToolbar();
|
||||
HRESULT GetWindow(HWND *phwnd);
|
||||
HRESULT SetMenu(HMENU hmenu, HWND hwnd, DWORD dwFlags);
|
||||
HRESULT GetMenu(HMENU *phmenu, HWND *phwnd, DWORD *pdwFlags);
|
||||
HRESULT ShowWindow(BOOL fShow);
|
||||
HRESULT Close();
|
||||
|
||||
private:
|
||||
|
||||
static const UINT WM_USER_SHOWPOPUPMENU = WM_USER + 1;
|
||||
|
||||
CMenuBand *m_menuBand;
|
||||
HWND m_hwnd;
|
||||
HMENU m_hmenu;
|
||||
HWND m_hwndOwner;
|
||||
DWORD m_dwMenuFlags;
|
||||
};
|
||||
|
||||
class CMenuBand :
|
||||
public CComCoClass<CMenuBand, &CLSID_MenuBand>,
|
||||
public CComObjectRootEx<CComMultiThreadModelNoCS>,
|
||||
|
@ -14,6 +40,19 @@ class CMenuBand :
|
|||
public IWinEventHandler,
|
||||
public IShellMenuAcc
|
||||
{
|
||||
public:
|
||||
CMenuBand();
|
||||
~CMenuBand();
|
||||
|
||||
private:
|
||||
|
||||
IOleWindow *m_site;
|
||||
CMenuStaticToolbar *m_staticToolbar;
|
||||
|
||||
IShellMenuCallback *m_psmc;
|
||||
UINT m_uId;
|
||||
UINT m_uIdAncestor;
|
||||
DWORD m_dwFlags;
|
||||
public :
|
||||
|
||||
// *** IDeskBand methods ***
|
||||
|
@ -103,19 +142,18 @@ DECLARE_NOT_AGGREGATABLE(CMenuBand)
|
|||
DECLARE_PROTECT_FINAL_CONSTRUCT()
|
||||
|
||||
BEGIN_COM_MAP(CMenuBand)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IMenuPopup, IMenuPopup)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IMenuBand, IMenuBand)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IDeskBar, IMenuPopup)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IShellMenu, IShellMenu)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IOleCommandTarget, IOleCommandTarget)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IOleWindow, IDeskBand)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IDeskBar, IDeskBar)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IObjectWithSite, IObjectWithSite)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IInputObject, IInputObject)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IPersistStream, IPersistStream)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersist)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IPersist, IPersistStream)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IServiceProvider, IServiceProvider)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IMenuPopup, IMenuPopup)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IMenuBand, IMenuBand)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IShellMenu2, IShellMenu2)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IWinEventHandler, IWinEventHandler)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <ndk/rtlfuncs.h>
|
||||
#include <fmifs/fmifs.h>
|
||||
#include <sddl.h>
|
||||
#include <commoncontrols.h>
|
||||
|
||||
#include <tchar.h>
|
||||
#include <strsafe.h>
|
||||
|
|
Loading…
Reference in a new issue