API: int MessageBox(HWND hWnd, LPCTSTRlpText, LPCTSTRlpCaption, UINTuType);
MSDN描述:
This function creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons.
這個API方法用來創建、顯示、操作一個消息框。它包含可設置的消息內容、標題,還可以添加預定義的圖標、放置按鈕。參數說明:
MSDN描述:
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.
- 輸入參數。指定消息框的父窗口(消息框顯示時,父窗口被禁用)。如果這個參數爲空,說明消息框沒有父窗口,即、沒有窗口會因爲消息框的出現而被禁用。
- 參數類型:HWND類型是結構體指針,結構體成員只有一個int。參考MSND的窗口描述符。
- lpText
- [in] Long pointer to a null-terminated string that contains the message to be displayed.
- 輸入參數。指定消息框的消息內容。
- 參數類型: LPCTSTR 字符串指針。
- 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.
- 輸入參數。指定消息框的標題。默認值是 Error 或 錯誤 。
- 參數類型:LPCTSTR字符串指針。
- 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.
- 輸入參數。指定消息和消息框的顯示風格。可按位組合指定多種風格。具體風格參見MSDN。
- 參數類型:無符號整形。一般傳入的是一組用 || 連接的宏。
返回值
返回0,說明創建、顯示消息框失敗。
返回非0,說明消息框操作成功。具體返回值含義如下:
Value | Description |
---|---|
IDABORT | Abort button was selected.(用戶點擊了中止按鈕) |
IDCANCEL | Cancel button or the close button on the title bar was selected. (用戶點擊了取消按鈕、或者標題欄關閉按鈕、或按下ESC鍵) |
IDIGNORE | Ignore button was selected.(用戶點擊了忽略按鈕) |
IDNO | No button was selected.(用戶點擊了否按鈕) |
IDOK | OK button was selected.(用戶點擊了是按鈕) |
IDRETRY | Retry button was selected.(用戶點擊了重試按鈕) |
IDYES | Yes button was selected.(用戶點擊了確定按鈕) |