QA: How to remove New button from command bar?
Vassili Philippov (vasja@spbteam.com), June 29, 2001.
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:
-
http://www.pocketpcdn.com/sections/ui.html
Section: User Interface
-
http://www.pocketpcdn.com/articles/cmdbar_menu.html
QA: How do I get the command bar menu handle?
-
http://www.pocketpcdn.com/articles/second_commandbar.html
QA: How can I implement the second toolbar like the one in Pocket Word?
-
http://www.pocketpcdn.com/articles/updatecommandui.html
QA: Why ON_UPDATE_COMMAND_UI handlers get called again and again?
-
http://www.pocketpcdn.com/articles/dialogbar.html
QA: How can I use a command bar in a dialog?