关于菜单的问题!谢谢

asos2002 2002-05-12 05:08:33
我想自己制作菜单 项,使其与 xp 的风格很相似,,,有这方面的介绍文章吗?

我看了一个源代码,,写的太多了,,我急需用的,,一时间我也看不懂啊!

最好哪里有这方面制作自己的菜单的文章 ,,

谢谢
...全文
106 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
weakpig 2002-05-12
  • 打赏
  • 举报
回复
参看http://www.codeproject.com/menu/menuxp2.asp写得很详细
meteor_wr 2002-05-12
  • 打赏
  • 举报
回复
菜单的风格还不是随便可以弄,你想怎样就怎样。
提供一些技巧给你吧:

9.1.1. How do I get a pointer to the menu bar in a MDI app?
QUESTION:

I'm writing a MDI application and I have problems to get a pointer to the actual menu bar. The normal construction doesn't seem to work in MDI:

CMenu *menu;
menu = GetMenu()->GetSubMenu(0);
How can I get a pointer to the menu bar to update the menu?ANSWER:

AfxGetApp()->m_pMainWnd->GetMenu()->GetSubMenu(n);
mlinar@pollux.usc.edu, Mitch Mlinar, 6/8/95

9.1.2. How do I implement a right-mouse popup-menu?
///////////////////////////////////////////////////////////////////
// WM_RBUTTONDOWN handler.
//
// Trap this message and display the button properties popup menu.
// The main frame receives the popup menu messages. This allows the
// status bar to be updated with the help text.
// ///////////////////////////////////////////////////////////////////
void CAppButton::OnRButtonDown(UINT flags, CPoint point)
{
CMenu menu;
CMenu *submenu;
// load the menu
menu.LoadMenu(IDR_LAUNCH);
// get the popup menu
submenu = menu.GetSubMenu(0);
// convert to screen coordinates
ClientToScreen(&point);
// post the menu
submenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y,
AfxGetApp()->m_pMainWnd,NULL);
}
johnm@unipalm.co.uk, programmer.win32, 7/12/95

It's better to use RBUTTONUP instead, however right-clicking on dialog controls doesn't generate RBUTTONUP and RBUTTONDOWN messages.

If it's necessary to treat this situation too, a program have to catch WM_PARENTNOTIFY message in Win3.x and WinNT and WM_CONTEXTMENU in Windows 95. Here's a code:

// May be dialog too:
BEGIN_MESSAGE_MAP(CMyPropertyPage, CPropertyPage)
//{{AFX_MSG_MAP(CMyPropertyPage)
ON_WM_RBUTTONUP()
ON_WM_PARENTNOTIFY()
ON_MESSAGE(WM_CONTEXTMENU, OnContextMenu)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CMyPropertyPage::OnRButtonUp(UINT nFlags, CPoint point)=20
{
PopupMenu (&point);
}

void CMyPropertyPage::OnParentNotify(UINT message, LPARAM lParam)
{
if (message !=3D WM_RBUTTONDOWN)
CPropertyPage::OnParentNotify(message, lParam);
else
{
CPoint pt(LOWORD(lParam),HIWORD(lParam));
PopupMenu (&pt);
}
}

LONG CMyPropertyPage::OnContextMenu (UINT wParam, LONG lParam)
{
CPoint pt(LOWORD(lParam),HIWORD(lParam));
ScreenToClient (&pt);
PopupMenu (&pt);
return 0;
}

//*****************************************************************

void CMyPropertyPage::PopupMenu(CPoint* pt)
{
ASSERT(m_idContextMenu !=3D 0);
ASSERT(nSubMenu >=3D 0);
ClientToScreen (pt);
CMenu FloatingMenu;
VERIFY(FloatingMenu.LoadMenu(ID_POPUP_MENU));
CMenu* pPopupMenu =3D FloatingMenu.GetSubMenu (0);
ASSERT(pPopupMenu !=3D NULL);
pPopupMenu->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON,=20
pt->x, pt->y, this);
}
PaulACost@msn.com - via email, 10/15/95

9.1.3. How do I dynamically change the mainframe menu?
CMenu newMenu;
newMenu.LoadMenu (IDR_MENU1);
AfxGetMainWnd()->SetMenu( &newMenu );
AfxGetMainWnd()->DrawMenuBar();
newMenu.Detach ();
Arun Rao, MSMFC, 6/27/95

9.1.4. How do I 'attach' a menu to a window's creation/destruction?
{Note the original question talked about dialogs, but you can interpolate this code to any kind of window that you want to have change the menu.}

One of the ways to do this is as follows……

Declare a variable CMenu pNewMenu in one of the dialog class.
Handle the WM_INITDIALOG and WM_CLOSE messages in the dialog class as follows.

BOOL CMydlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Load the IDR_MYFRAME menu
pNewMenu = new CMenu;
pNewMenu->LoadMenu(IDR_MYFRAME);
// Set the mainframe menu to mainframe.
((CMainFrame *)AfxGetMainWnd())->SetMenu(pNewMenu);
return TRUE;
}
And

void CMydlg::OnClose()
{
// Detach the previous HMenu handle from the object.
pNewMenu->Detach();
pNewMenu->LoadMenu(IDR_MAINFRAME);
// Restore the mainframe menu.
((CMainFrame *)AfxGetMainWnd())->SetMenu(pNewMenu);
CDialog::OnClose();
}
If there are other methods of closing the dialog (example- By clicking a button in the Dialog), then The code given above in OnClose handler, must be put in the button click handler.

Sanjeev Kumar, MSMFC, 6/23/95

9.1.5. How do I add 'What's this' menus to my application - like Win95 hip apps have?
Here's some steps to get you started->

Put the following menu into a resource script:
IDR_WHAT_IS_THIS_MENU MENU DISCARDABLE
BEGIN
BEGIN
POPUP "a"
BEGIN
MENUITEM "What's this?", ID_WHAT_IS_THIS
END
END
END
Add to your dialog a right-click handler (OnRButtonDown) with menu IDR_WHAT_IS_THIS_MENU. You need to store the point of the last click in some variable - for example
CPoint m_cLastRClickPoint;

and store here the client coordinates of the last right click.
Put the following code into your dialog class (or probably the parent class of all your dialogs):
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
//{{AFX_MSG_MAP(CMyDialog)
// whatever
//}}
ON_COMMAND(ID_WHAT_IS_THIS, OnWhatIsThis)
END_MESSAGE_MAP()

void CMyDialog::OnWhatIsThis()
{
CWnd* pControl = ChildWindowFromPoint (m_cLastRClickPoint);

// if the click wasn't on one of the controls - open help for dialog
if (pControl == NULL || pControl->m_hWnd == m_hWnd)
WinHelp (HID_BASE_RESOURCE + m_nIDHelp, HELP_CONTEXTPOPUP);
else
WinHelp (HID_BASE_CONTROL + pControl->GetDlgCtrlID(), HELP_CONTEXTPOPUP);
}

- and finally add the following lines to the makehelp.bat file:

echo. >>hlp\wr.hm
echo // Controls (IDC_*) >>hlp\wr.hm
makehm IDC_,HIDC_,0x50000 resource.h >>hlp\wr.hm


相关的书籍很多很多,自己好好研究吧。做好了给我发一个哦:)
(题外话:从本次开始 我新增了jQuery EasyUI的专题页面 大家可以关注我的专题页来及时获取最新的EasyUI资源 专题页地址如下http:http://download.csdn.net/album/detail/343 同时也希望转载的那些朋友能保留我资源的说明及出处地址 我花那么多精力制作出来的 你们鼠标点两下就给我转走了还不注明出处 实在是不厚道 本来就是本着分享精神的 为的就是聚集一点人气和提供一个优良的环境来一起学习进步的 请不要抹杀掉我的热情 谢谢 )   时隔4个月之久 EasyUI终于迎来大版本更新了 本次更新内容诸多 除了常规维护外 还新增了3个新组件 都很实用 详细的可以阅读更新说明 里面给了详细的解读 另外 从该版本开始我将会逐步的将EasyUI官方以及第三方较好的插件API整合到API文档当中 并且会对这些插件做一些简单的Demo实现 存放到配套提供的程序包demo文件夹下 以便大家学习和使用 本期文档中将官方提供的所有附加插件的API都整理并存放到Extension节点下了 这些扩展的demo在附带的程序包中已经提供 可以用于参考使用 jQuery EasyUI 1 4版本更新内容: Bug(修复) menu:修复在删除一个菜单项的时候该菜单无法正确自适应高度的问题; datagrid:修复在datagrid宽度太小的时候“fitColumns”方法无法正常工作的问题 Improvement(改进) EasyUI的所有组件已经支持非固定 百分比大小的尺寸设置; menu:添加“showItem” “hideItem”和“resize”方法; menu:基于窗体大小自动调整高度; menu:添加“duration”属性 该属性允许用户自定义隐藏菜单动画的持续时间 以毫秒为单位; validatebox:添加“onBeforeValidate”和“onValidate”事件; combo:从该版本开始combo组件扩展自textbox组件(textbox是1 4中新增的组件); combo:添加“panelMinWidth” “panelMaxWidth” “panelMinHeight”和“panelMaxHeight”属性; searchbox:从该版本开始searchbox组件扩展自textbox组件(textbox是1 4中新增的组件); tree:添加“getRoot”方法 用于返回通过“nodeEl”参数指定的节点的顶部父节点元素 注意:官网的英文API中该函数的说明有误 其说明是none 无参数 实际这里是需要参数的 ; tree:添加“queryParams”属性; datetimebox:添加“spinnerWidth”属性; panel:添加“doLayout”方法 用于控制面板内组件的大小; panel:添加“clear”方法 用于清除面板内的内容; datagrid:允许用户设置百分比宽度的列(该功能真是千呼万唤始出来啊 ); form:添加“ajax” “novalidate”和“queryParams”属性; linkbutton:添加“resize”方法 New Plugin(新组件) textbox:该组件是一个增强的输入字段 它可以让用户非常简单的构建一个表单; datetimespinner:该组件是一个日期和时间的微调组件 它允许我们选择一个特定的日期或时间; filebox:filebox 该组件表单元素中用于上传文件的文件框工具组件 ">(题外话:从本次开始 我新增了jQuery EasyUI的专题页面 大家可以关注我的专题页来及时获取

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧