AfxMessageBox与MessageBox的区别

来源:互联网 发布:sql注入语句登录系统 编辑:程序博客网 时间:2024/05/13 11:53

int  AfxMessageBox(
LPCTSTR lpszText,
UINT nType = MB_OK,
UINT nIDHelp = 0 );

lpszText
Points to a CString object or null-terminated string containing the message to be displayed in the message box.
nType
The style of the message box. Apply any of the message-box styles to the box.  
nIDHelp
The Help-context ID for the message; 0 indicates the application’s default Help context will be used.

 

int  MessageBox(
HWND
hWnd,
LPCTSTR
lpText,
LPCTSTR
lpCaption,
UINT
uType);

hWnd
[in] Handle to the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window.
lpText
[in] Long pointer to a null-terminated string that contains the message to be displayed.
lpCaption
[in] Long pointer to a null-terminated string used for the dialog box title. If this parameter is NULL, the default title “Error” is used.
uType
[in] Specifies a set of bit flags that determine the contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags.

 

1.MessageBox是CWnd的类成员函数。  
  AfxMessageBox是全局API函数。

2.如果使用的是MFC应用程序,两者都可以使用,但用AfxMessageBox更方便。
  如果创建的是SDK,则只能用MessageBox。
  AfxMessageBox是AFX小组为了取代API采取的一种方法。   

3.MessageBox比AfxMessageBox灵活,体现在参数上。因为AfxMessageBox是一个全局函数所以不需要对应一个窗类,同时也不能控制消息框的标题。而MessageBox可以通过参数写明标题内容。

原创粉丝点击