就类似多文档应用程序框架的“窗口”菜单是如何实现的?(新建一个窗口,对应窗口下的菜单就多一项)
解决方案 »
- WSAECONNRESET
- 如何开发类似VC框架的应用程序?
- 打开图像
- 用wininet提交表单的问题
- 在对话框中创建工具栏?
- 请问怎么获得tab顺序中的上一个窗口对象?
- 不明白,为什么MCI播放AVI或MPG文件时,在播放的窗口上移动MOUSE,主窗口收不到消息
- 高手请进,参与者有分!请问我的视图(单文档的view)改变大小如何让他的框架(CMainFrame)与它相匹配
- MFC中能否使用CoInitializeEx(NULL, COINIT_MULTITHREADED)?
- CClientDC对象生命期结束后,会引发窗口重绘吗
- 怎样将一个vb程序的picture控件句柄传递给vc编的dll...
- 关于IE toolbar的问题 (苦等)要多少分都给你
{
// 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;
}