mirror of
https://github.com/reactos/reactos.git
synced 2024-07-04 19:54:58 +00:00
[BROWSEUI] -CBandSite: Implement the context menu of the rebar. It queries the IContextMenu if the band and appends to it a static menu part that can show or hide the title and close the toolbar. Showing or hiding the title isn't implemented yet.
svn path=/trunk/; revision=75216
This commit is contained in:
parent
20bbfa5624
commit
9e4da13034
|
@ -87,6 +87,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -105,6 +105,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -105,6 +105,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -89,6 +89,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -105,6 +105,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -89,6 +89,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -87,6 +87,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -105,6 +105,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -95,6 +95,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -89,6 +89,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -89,6 +89,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -89,6 +89,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -106,6 +106,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -89,6 +89,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -89,6 +89,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -107,6 +107,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -107,6 +107,12 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
IDM_BAND_MENU MENUEX
|
||||
BEGIN
|
||||
MENUITEM "Sho&w title", IDM_BAND_TITLE
|
||||
MENUITEM "&Close toolbar", IDM_BAND_CLOSE
|
||||
END
|
||||
|
||||
/* Dialogs */
|
||||
|
||||
IDD_PROGRESS_DLG DIALOGEX 0, 0, 260, 85
|
||||
|
|
|
@ -60,6 +60,10 @@
|
|||
#define IDM_TASKBAR_TOOLBARS_QUICKLAUNCH 4
|
||||
#define IDM_TASKBAR_TOOLBARS_NEW 1
|
||||
|
||||
#define IDM_BAND_MENU 269
|
||||
#define IDM_BAND_TITLE 0xA200
|
||||
#define IDM_BAND_CLOSE 0xA201
|
||||
|
||||
/* Random id for band close button, feel free to change it */
|
||||
#define IDM_BASEBAR_CLOSE 0xA200
|
||||
|
||||
|
|
|
@ -221,6 +221,83 @@ HRESULT CBandSiteBase::UpdateBand(DWORD dwBandID)
|
|||
return UpdateSingleBand(Band);
|
||||
}
|
||||
|
||||
HRESULT CBandSiteBase::OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plrResult)
|
||||
{
|
||||
/* Find the index fo the band that was clicked */
|
||||
int x = GET_X_LPARAM(lParam);
|
||||
int y = GET_Y_LPARAM(lParam);
|
||||
|
||||
RBHITTESTINFO htInfo = {{x, y}};
|
||||
ScreenToClient(fRebarWindow, &htInfo.pt);
|
||||
int iBand = SendMessageW(fRebarWindow, RB_HITTEST, 0, (LPARAM)&htInfo);
|
||||
if (iBand < 0)
|
||||
{
|
||||
/* FIXME: what to do here? */
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* Now get the id of the band that was clicked */
|
||||
REBARBANDINFOW bandInfo = {sizeof(bandInfo), RBBIM_ID};
|
||||
SendMessageW(fRebarWindow, RB_GETBANDINFOW, htInfo.iBand, (LPARAM)&bandInfo);
|
||||
|
||||
/* Finally get the band */
|
||||
DWORD dwBandID = bandInfo.wID;
|
||||
struct BandObject *Band = GetBandByID(dwBandID);
|
||||
if (Band == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
HMENU hMenu = CreatePopupMenu();
|
||||
if (hMenu == NULL)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
/* Try to load the menu of the band */
|
||||
UINT idBandLast = 0;
|
||||
CComPtr<IContextMenu> pcm;
|
||||
HRESULT hr = Band->DeskBand->QueryInterface(IID_PPV_ARG(IContextMenu, &pcm));
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
hr = pcm->QueryContextMenu(hMenu, 0, 0, UINT_MAX, CMF_NORMAL);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
idBandLast = HRESULT_CODE(hr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Load the static part of the menu */
|
||||
HMENU hMenuStatic = LoadMenuW(GetModuleHandleW(L"browseui.dll"), MAKEINTRESOURCEW(IDM_BAND_MENU));
|
||||
if (hMenuStatic)
|
||||
Shell_MergeMenus(hMenu, hMenuStatic, UINT_MAX, 0, UINT_MAX, MM_DONTREMOVESEPS | MM_SUBMENUSHAVEIDS);
|
||||
|
||||
EnableMenuItem(hMenu, IDM_BAND_TITLE, MF_GRAYED);
|
||||
/* TODO: Show IDM_BAND_TITLE as checked if the band title is shown */
|
||||
|
||||
/* TODO: Query the menu of our site */
|
||||
|
||||
UINT uCommand = ::TrackPopupMenuEx(hMenu, TPM_RETURNCMD, x, y, fRebarWindow, NULL);
|
||||
if (uCommand < idBandLast)
|
||||
{
|
||||
CMINVOKECOMMANDINFO cmi = { sizeof(cmi), 0, fRebarWindow, MAKEINTRESOURCEA(uCommand)};
|
||||
hr = pcm->InvokeCommand(&cmi);
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uCommand == IDM_BAND_TITLE)
|
||||
{
|
||||
/* TODO: Implement showing or hiding the title */
|
||||
}
|
||||
else if(uCommand == IDM_BAND_CLOSE)
|
||||
{
|
||||
hr = RemoveBand(dwBandID);
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
struct CBandSiteBase::BandObject *CBandSiteBase::GetBandFromHwnd(HWND hwnd)
|
||||
{
|
||||
HRESULT hRet;
|
||||
|
@ -567,6 +644,15 @@ HRESULT STDMETHODCALLTYPE CBandSiteBase::OnWinEvent(HWND hWnd, UINT uMsg, WPARAM
|
|||
if (fRebarWindow == NULL)
|
||||
return E_FAIL;
|
||||
|
||||
if (uMsg == WM_CONTEXTMENU)
|
||||
{
|
||||
HRESULT hr = OnContextMenu(hWnd, uMsg, wParam, lParam, plrResult);
|
||||
if (FAILED_UNEXPECTEDLY(hr))
|
||||
return hr;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (hWnd == fRebarWindow)
|
||||
{
|
||||
/* FIXME: Just send the message? */
|
||||
|
|
|
@ -120,6 +120,7 @@ private:
|
|||
HRESULT UpdateAllBands();
|
||||
HRESULT UpdateBand(DWORD dwBandID);
|
||||
struct BandObject *GetBandFromHwnd(HWND hwnd);
|
||||
HRESULT OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plrResult);
|
||||
|
||||
BEGIN_COM_MAP(CBandSiteBase)
|
||||
COM_INTERFACE_ENTRY_IID(IID_IBandSite, IBandSite)
|
||||
|
|
|
@ -33,4 +33,7 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(browseui);
|
||||
|
||||
#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
|
||||
#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
|
||||
|
||||
#endif /* _BROWSEUI_PCH_ */
|
||||
|
|
Loading…
Reference in a new issue