您的位置:首页 > 其它

The Problem Of Using MessageBox() Of Win32 API

2013-08-05 13:09 330 查看
When we used the API MessageBox() of win32,we found that it required 4 parameters,this was not like that in MFC can recieve 1 parameter.

So,how can we use it?

Here is the introduction in MSDN for C++ 6.0:

int MessageBox(
HWND hWnd,          // handle of owner window
  LPCTSTR lpText,     // address of text in message box
  LPCTSTR lpCaption,  // address of title of message box
  UINT uType          // style of message box
);

Well,we can do this:

MessageBox(NULL,"Hello Win32","Message",MB_OK);//The parameter 1 is NULL means the MessageBox's parent window is desktop.

And,it can be used.

However,if we want to display an integer,how can we do?

Well,we can use the funtion "wsprintf" which is in <windows.h>.

Here is the introduction in MSDN for C++ 6.0:

int wsprintf(
LPTSTR lpOut,    // pointer to buffer for output
  LPCTSTR lpFmt,   // pointer to format-control string
...              // optional arguments
);


And,we can do this:

DWORD dwNum=5201314;

char Buffer[100];

wsprintf(Buffer,"%s",dwNum);

MessageBox(NULL,Buffer,"I Love You",MB_OK);

So,above is the problem of win32's MessageBox,if someone has some advice,please comment,thanks a lot!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐