QA: How to remove New button from command bar?
By Vassili Philippov, June 29, 2001.
Print version
Question
How to remove "New" button from the command bar? When I create a new applicationusing
"Single Document with Doc List" template I have "New" button in the command bar. But I
don't need it because my application is only a viewer and doesn't allow editing.
Answer
You could use SHCreateMenuBar function to create new menu for the command bar.
Source code
The following code removes "New" button from document list's command bar.
void CMainFrame::OnCreateDocList(DLNHDR* pNotifyStruct, LRESULT* result)
{
CCeDocList* pDocList = (CCeDocList*)FromHandle(pNotifyStruct->nmhdr.hwndFrom);
ASSERT_KINDOF(CCeDocList, pDocList);
CCeCommandBar* pDocListCB = pDocList->GetCommandBar();
ASSERT(pDocListCB != NULL);
pDocListCB->InsertMenuBar(IDM_DOCLIST);
pDocListCB->SendMessage(TB_SETTOOLTIPS, (WPARAM)(1), (LPARAM)(m_ToolTipsTable));
CFrameWnd::OnCreateDocList(pNotifyStruct, result);
//Here we change menu. We set it again and so remove "New" button
SHMENUBARINFO smb;
smb.cbSize = sizeof(SHMENUBARINFO);
smb.hwndParent = pDocListCB->GetSafeHwnd();
smb.dwFlags = 0;
smb.nToolBarId = IDM_DOCLIST;
smb.hInstRes = ::AfxGetInstanceHandle();
smb.nBmpId = 0;
smb.cBmpImages = 0;
BOOL bResult = SHCreateMenuBar(&smb);
}
Related resources:
Discuss
Discuss this article.
Here you can write your comments and read comments of other developers.
|