[BROWSEUI] -CBandSite: Remove the Close item menu if the band is undeletable. Remove the Show caption menu item if the band doesn't have a caption. Implement showing or hiding the band caption.

svn path=/trunk/; revision=75230
This commit is contained in:
Giannis Adamopoulos 2017-06-29 09:41:00 +00:00
parent 10dc514582
commit 7d2398b6af
2 changed files with 47 additions and 3 deletions

View file

@ -143,6 +143,12 @@ VOID CBandSiteBase::BuildRebarBandInfo(struct BandObject *Band, REBARBANDINFOW *
prbi->fStyle |= RBBS_GRIPPERALWAYS; prbi->fStyle |= RBBS_GRIPPERALWAYS;
} }
if (Band->bHiddenTitle)
{
prbi->fMask |= RBBIM_STYLE;
prbi->fStyle |= RBBS_HIDETITLE;
}
if ((Band->dbi.dwMask & (DBIM_BKCOLOR | DBIM_MODEFLAGS)) == (DBIM_BKCOLOR | DBIM_MODEFLAGS) && if ((Band->dbi.dwMask & (DBIM_BKCOLOR | DBIM_MODEFLAGS)) == (DBIM_BKCOLOR | DBIM_MODEFLAGS) &&
(Band->dbi.dwModeFlags & DBIMF_BKCOLOR)) (Band->dbi.dwModeFlags & DBIMF_BKCOLOR))
{ {
@ -221,6 +227,23 @@ HRESULT CBandSiteBase::UpdateBand(DWORD dwBandID)
return UpdateSingleBand(Band); return UpdateSingleBand(Band);
} }
HRESULT CBandSiteBase::_IsBandDeletable(DWORD dwBandID)
{
CComPtr<IBandSite> pbs;
/* Use QueryInterface so that we get the outer object in case we have one */
HRESULT hr = this->QueryInterface(IID_PPV_ARG(IBandSite, &pbs));
if (FAILED_UNEXPECTEDLY(hr))
return hr;
DWORD dwState;
hr = pbs->QueryBand(dwBandID, NULL, &dwState, NULL, NULL);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
return ((dwState & BSSF_UNDELETEABLE) != 0) ? S_FALSE : S_OK;
}
HRESULT CBandSiteBase::OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plrResult) HRESULT CBandSiteBase::OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plrResult)
{ {
/* Find the index fo the band that was clicked */ /* Find the index fo the band that was clicked */
@ -265,11 +288,26 @@ HRESULT CBandSiteBase::OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
/* Load the static part of the menu */ /* Load the static part of the menu */
HMENU hMenuStatic = LoadMenuW(GetModuleHandleW(L"browseui.dll"), MAKEINTRESOURCEW(IDM_BAND_MENU)); HMENU hMenuStatic = LoadMenuW(GetModuleHandleW(L"browseui.dll"), MAKEINTRESOURCEW(IDM_BAND_MENU));
if (hMenuStatic) if (hMenuStatic)
{
Shell_MergeMenus(hMenu, hMenuStatic, UINT_MAX, 0, UINT_MAX, MM_DONTREMOVESEPS | MM_SUBMENUSHAVEIDS); Shell_MergeMenus(hMenu, hMenuStatic, UINT_MAX, 0, UINT_MAX, MM_DONTREMOVESEPS | MM_SUBMENUSHAVEIDS);
EnableMenuItem(hMenu, IDM_BAND_TITLE, MF_GRAYED); ::DestroyMenu(hMenuStatic);
/* TODO: Show IDM_BAND_TITLE as checked if the band title is shown */
hr = _IsBandDeletable(dwBandID);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
/* Remove the close item if it is not deletable */
if (hr == S_FALSE || (Band->dbi.dwModeFlags & DBIMF_UNDELETEABLE) != 0)
DeleteMenu(hMenu, IDM_BAND_CLOSE, MF_BYCOMMAND);
if ((Band->dbi.dwMask & DBIM_TITLE) == 0)
DeleteMenu(hMenu, IDM_BAND_TITLE, MF_BYCOMMAND);
else
CheckMenuItem(hMenu, IDM_BAND_TITLE, Band->bHiddenTitle ? MF_UNCHECKED : MF_CHECKED);
}
/* TODO: Query the menu of our site */ /* TODO: Query the menu of our site */
@ -285,7 +323,11 @@ HRESULT CBandSiteBase::OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
{ {
if (uCommand == IDM_BAND_TITLE) if (uCommand == IDM_BAND_TITLE)
{ {
/* TODO: Implement showing or hiding the title */ Band->bHiddenTitle = !Band->bHiddenTitle;
hr = UpdateBand(dwBandID);
if (FAILED_UNEXPECTEDLY(hr))
return hr;
} }
else if(uCommand == IDM_BAND_CLOSE) else if(uCommand == IDM_BAND_CLOSE)
{ {

View file

@ -41,6 +41,7 @@ private:
IOleWindow *OleWindow; IOleWindow *OleWindow;
IWinEventHandler *WndEvtHandler; IWinEventHandler *WndEvtHandler;
DESKBANDINFO dbi; DESKBANDINFO dbi;
BOOL bHiddenTitle;
}; };
LONG fBandsCount; LONG fBandsCount;
@ -120,6 +121,7 @@ private:
HRESULT UpdateAllBands(); HRESULT UpdateAllBands();
HRESULT UpdateBand(DWORD dwBandID); HRESULT UpdateBand(DWORD dwBandID);
struct BandObject *GetBandFromHwnd(HWND hwnd); struct BandObject *GetBandFromHwnd(HWND hwnd);
HRESULT _IsBandDeletable(DWORD dwBandID);
HRESULT OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plrResult); HRESULT OnContextMenu(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plrResult);
BEGIN_COM_MAP(CBandSiteBase) BEGIN_COM_MAP(CBandSiteBase)