关于MessageBox的问题

Turbo_Dream 2009-04-19 09:07:28
问一个关于MessageBox的问题,我用VS2008创建了一个C++的Windows应用程序,我添加了一个Button按钮,写了单击事件,但是总是无法使用MessageBox,请问是应该怎样使用?

MessageBox.Show("Hello World!");
系统就报错说.Show的左边必须是类,结构,共用
...全文
90 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
ysysbaobei 2009-04-20
  • 打赏
  • 举报
回复
lizhaohu 2009-04-19
  • 打赏
  • 举报
回复
AfxMessageBox(-T"fhg");
  • 打赏
  • 举报
回复
CWnd::MessageBox
int MessageBox( LPCTSTR lpszText, LPCTSTR lpszCaption = NULL, UINT nType = MB_OK );

Return Value

Specifies the outcome of the function. It is 0 if there is not enough memory to create the message box.

Parameters

lpszText

Points to a CString object or null-terminated string containing the message to be displayed.

lpszCaption

Points to a CString object or null-terminated string to be used for the message-box caption. If lpszCaption is NULL, the default caption “Error” is used.

nType

Specifies the contents and behavior of the message box.

  • 打赏
  • 举报
回复
函数原型:int MessageBox(HWND hWnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT UType)是这样的
  • 打赏
  • 举报
回复

#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,PSTR szCmdLine, int iCmdShow){
MessageBox (NULL, TEXT ("Hello World!"), TEXT ("VC++6.0:"), 0)
return 0 ;
}

airtrack 2009-04-19
  • 打赏
  • 举报
回复
MessageBox(hWnd, L"hello world!", L"test", MB_OK);
具体可以查看MSDN
fairchild811 2009-04-19
  • 打赏
  • 举报
回复
如果messagebox是个函数,应该是MessageBox("caption", "text", style)这种样子的吧,afxmessagebox()和cb里的messageboxA都是这样的

如果messagebox是个控件,那也应该是messagebox的一个对象调用show。比如messageBox msgb; msgb.show();
直接用控件名没法调用函数,错误信息就是这个意思
firsthym 2009-04-19
  • 打赏
  • 举报
回复
MessageBox("Hello World!");

65,211

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

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