我新建了一个对话框工程,在对话框中加入一个菜单:File(&F)->New(&N)。子菜单New(&N)的快捷键我已经加上了,但是第一级菜单也就是主菜单File(&F)的快捷键该怎样设置啊?
解决方案 »
- select返回2,但是recv返回0,而且WSAGetlastError()返回0
- 请教大家一个菜鸟的问题,热心的朋友进来看看!
- 分割窗口中的TreeView初始化后启动程序发生错误
- 两个进程共享读写一个文件,文件内容会被破坏吗?
- 对话框CDialog类的的一个对象,用DoModal()弹出后,是否会启动一个线程.
- 请教一个关于友元的问题
- 关于WM_WINDOWPOSCHANGING
- 高手救命!关于InstallShield的问题!来者有分,还可以再加分
- vc与matlab混合编程出现的怪异问题
- 如何通过USB设备路径得到它的盘符信息
- 我通过FindWindow(NULL,"输入网络密码")得到句柄,请问如何输入用户名和密码并且发送确定按扭的消息
- 请教大家关于CRichEditCtrl的WS_HSCROLL
这样就ok了记得输入法要是英文状态阿呵呵
// CMainFrame::OnChangeFileMenu() is a menu command handler for
// CMainFrame class, which in turn is a CFrameWnd-derived class.
// It modifies the File menu by inserting, removing and renaming
// some menu items. Other operations include associating a context
// help id and setting default menu item to the File menu.
// CMainFrame is a CFrameWnd-derived class.
void CMainFrame::OnChangeFileMenu()
{
// Get the menu from the application window.
CMenu* mmenu = GetMenu(); // Look for "File" menu.
int pos = FindMenuItem(mmenu, "&File");
if (pos == -1)
return; // Remove "New" menu item from the File menu.
CMenu* submenu = mmenu->GetSubMenu(pos);
pos = FindMenuItem(submenu, "&New\tCtrl+N");
if (pos > -1)
submenu->RemoveMenu(pos, MF_BYPOSITION); // Look for "Open" menu item from the File menu. Insert a new
// menu item called "Close" right after the "Open" menu item.
// ID_CLOSEFILE is the command id for the "Close" menu item.
pos = FindMenuItem(submenu, "&Open...\tCtrl+O");
if (pos > -1)
submenu->InsertMenu(pos + 1, MF_BYPOSITION, ID_CLOSEFILE, "&Close"); // Rename menu item "Save" to "Save Selection".
pos = FindMenuItem(submenu, "&Save\tCtrl+S");
if (pos > -1)
{
UINT id = submenu->GetMenuItemID(pos);
submenu->ModifyMenu(id, MF_BYCOMMAND, id, "&Save Selection");
} // Associate a context help ID with File menu, if one is not found.
// ID_FILE_CONTEXT_HELPID is the context help ID for the File menu
// that is defined in resource file.
if (submenu->GetMenuContextHelpId() == 0)
submenu->SetMenuContextHelpId(ID_FILE_CONTEXT_HELPID); // Set "Open" menu item as the default menu item for the File menu,
// if one is not found. So, when a user double-clicks the File
// menu, the system sends a command message to the menu's owner
// window and closes the menu as if the File\Open command item had
// been chosen.
if (submenu->GetDefaultItem(GMDI_GOINTOPOPUPS, TRUE) == -1)
{
pos = FindMenuItem(submenu, "&Open...\tCtrl+O");
submenu->SetDefaultItem(pos, TRUE);
}
}// FindMenuItem() will find a menu item string from the specified
// popup menu and returns its position (0-based) in the specified
// popup menu. It returns -1 if no such menu item string is found.
int FindMenuItem(CMenu* Menu, LPCTSTR MenuString)
{
ASSERT(Menu);
ASSERT(::IsMenu(Menu->GetSafeHmenu())); int count = Menu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
CString str;
if (Menu->GetMenuString(i, str, MF_BYPOSITION) &&
(strcmp(str, MenuString) == 0))
return i;
} return -1;
}