MessageBox()遇到麻烦 [英] Trouble with MessageBox()
问题描述
您好,
我有一个项目,其中一个文件是托管应用程序的COM插件。
在该代码中我可以自由使用AfxMessageBox(),或者如果我想要更多的控制
我也可以像这样使用MessageBox():
MessageBox (NULL,文件丢失。,错误,MB_OK);
在同一解决方案中的另一个.cpp文件是我的插件的属性页,主机从它的菜单系统弹出我可以再次使用AfxMessageBox()到我心中的内容但是MessageBox()会抛出编译错误:
''CWnd :: MessageBoxA'':函数不带4个参数。
两个文件中的Intellisense指向winuser.h中的define
我真的想在属性页面中使用MessageBox(),这样我就可以更改对话框标题文本了。
提前感谢你的帮助。
:Ron
在一个案例中,您可能会获得 CWnd: :MessageBox [ ^ ]和其他 Win API :: MessageBox [ ^ ]
如果没有您的代码,很难判断,但尝试将::说明符放在那里,因为它可以解决问题。
在案例2中,您显然是在CWnd
派生类中调用它,因此正确的调用将是:
MessageBox( File Missing。, Erro r,MB_OK);
Hello,
I have a project with one file that is a COM plugin for a hosting application.
In that code I can freely use AfxMessageBox(), or if I want a bit more control
I can also use MessageBox() like so:
MessageBox(NULL,"File Missing.","Error",MB_OK);
In another .cpp file in the same solution is a property page for my plugin that the host pops up from it''s menu system I can again use AfxMessageBox() to my hearts content but MessageBox() throws up the compiler error:
''CWnd::MessageBoxA'' : function does not take 4 arguments.
Intellisense in both file point to the define in winuser.h
I really would like to use MessageBox() in the property page so I can change the dialog title text.
Thanks for all your help in advance.
:Ron
The chances are that in one case you are getting CWnd::MessageBox[^] and in the other Win API ::MessageBox[^]
It''s difficult to tell without your code, but try putting the :: specifier in there as see it it corrects the problem.
In case 2 you are obviously calling it from within yourCWnd
derived class, so the correct call would be:
MessageBox("File Missing.","Error",MB_OK);
as described in the documentation[^].
这篇关于MessageBox()遇到麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!