如何捕获菜单项以显示对话框 [英] How to capture menu item to display dialogue box

查看:76
本文介绍了如何捕获菜单项以显示对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想将对话框链接到菜单栏项目.

例如:当我单击该消息菜单项时,我将其菜单项作为消息",则必须显示有关的对话框.

如何使用VC ++ 6.0 MFC向导SDI应用程序实现此目标.
谁能帮助我做到这一点


谢谢您

Hi,

I want to link dialogue box to menu bar item.

For Ex:I have menu item as Message when i click on that message menu item the concerned dialogue box has to be displayed.

How can I achieve this using VC++ 6.0 MFC Wizard SDI application.
Can any one help me to do this


Thanks u alot

推荐答案

您不会说是使用MFC还是直接使用Win32,但是无论哪种情况,您都可以在要添加的位置添加代码以运行对话框捕获菜单引发的命令值.例如在Win32中,在您的WndProc函数中执行以下操作:
在MFC上的Menuitem MouseDown事件中
You do not say whether you are using MFC or straight Win32, but in either case you add the code to run the dialog at the point where you capture the command value raised by the menu. For example in Win32 do it in your WndProc function like this:
LRESULT CALLBACK WndProc(HWND		hWnd,
			 UINT		uMessage,
			 WPARAM		wParam,
			 LPARAM		lParam
			 )
{
    switch (uMessage)
    {
	case WM_COMMAND:
            if (wParam == IDM_MENUCOMMAND)
            {
                // show your dialog here
            }

	case WM_DESTROY:
	    PostQuitMessage(0);
            return 0;
	
    }
	
    return DefWindowProc(hWnd, uMessage, wParam, lParam);
}


,添加代码...

Dlg.DoModal(); //Dlg是所需的DlgBox类的对象
in MFC on Menuitem MouseDown event, add code...

Dlg.DoModal(); //Dlg is object of your required DlgBox Class


从SDI-> [^ ]


这篇关于如何捕获菜单项以显示对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆