Application.messagebox除了MB_ICONERROR,MB_ICONQUESTION之外,还有哪些?(带图标的)

Dhammacakkhu 2002-04-28 04:05:44
如上
...全文
430 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
webnumen 2002-04-29
  • 打赏
  • 举报
回复
tmd
webnumen 2002-04-29
  • 打赏
  • 举报
回复
TMD,tnn
nne998 2002-04-28
  • 打赏
  • 举报
回复
Return Values
The return value is zero if there is not enough memory to create the message box.

If the function succeeds, the return value is one of the following menu-item values returned by the dialog box:

Value Meaning
IDABORT Abort button was selected.
IDCANCEL Cancel button was selected.
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.


If a message box has a Cancel button, the function returns the IDCANCEL value if either the esc key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing esc has no effect.

Remarks
When you use a system-modal message box to indicate that the system is low on memory, the strings pointed to by the lpText and lpCaption parameters should not be taken from a resource file, because an attempt to load the resource may fail.

When an application calls MessageBox and specifies the MB_ICONHAND and MB_SYSTEMMODAL flags for the uType parameter, the system displays the resulting message box regardless of available memory. When these flags are specified, the system limits the length of the message box text to three lines. The system does not automatically break the lines to fit in the message box, however, so the message string must contain carriage returns to break the lines at the appropriate places.

If you create a message box while a dialog box is present, use the handle of the dialog box as the hWnd parameter. The hWnd parameter should not identify a child window, such as a control in a dialog box.

Windows 95: The system can support a maximum of 16,364 window handles.

Windows CE: Windows CE does not support the following styles for the uType parameter:

MB_SYSTEMMODAL

MB_TASKMODAL

MB_HELP

MB_RIGHT

MB_RTLREADING

MB_DEFAULT_DESKTOP_ONLY

MB_SERVICE_NOTIFICATION

MB_USERICON.

The following return values are not supported:

IDCLOSE

IDHELP

QuickInfo
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Requires version 1.0 or later.
Header: Declared in winuser.h.
Import Library: Use user32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows and Windows NT.

See Also
Dialog Boxes Overview, Dialog Box Functions,FlashWindow,MessageBeep, MessageBoxEx, MessageBoxIndirect, SetForegroundWindow


nne998 2002-04-28
  • 打赏
  • 举报
回复
MessageBox
The MessageBox 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.

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
);

Parameters
hWnd
Identifies the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window.
lpText
Pointer to a null-terminated string containing the message to be displayed.
lpCaption
Pointer to a null-terminated string used for the dialog box title. If this parameter is NULL, the default title Error is used.
uType
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.
Specify one of the following flags to indicate the buttons contained in the message box: Flag Meaning
MB_ABORTRETRYIGNORE The message box contains three push buttons: Abort, Retry, and Ignore.
MB_OK The message box contains one push button: OK. This is the default.
MB_OKCANCEL The message box contains two push buttons: OK and Cancel.
MB_RETRYCANCEL The message box contains two push buttons: Retry and Cancel.
MB_YESNO The message box contains two push buttons: Yes and No.
MB_YESNOCANCEL The message box contains three push buttons: Yes, No, and Cancel.



Specify one of the following flags to display an icon in the message box: Flag Meaning
MB_ICONEXCLAMATION,
MB_ICONWARNING
An exclamation-point icon appears in the message box.
MB_ICONINFORMATION, MB_ICONASTERISK
An icon consisting of a lowercase letter i in a circle appears in the message box.
MB_ICONQUESTION A question-mark icon appears in the message box.
MB_ICONSTOP,
MB_ICONERROR,
MB_ICONHAND
A stop-sign icon appears in the message box.



Specify one of the following flags to indicate the default button: Flag Meaning
MB_DEFBUTTON1 The first button is the default button.
MB_DEFBUTTON1 is the default unless MB_DEFBUTTON2, MB_DEFBUTTON3, or MB_DEFBUTTON4 is specified.

MB_DEFBUTTON2 The second button is the default button.
MB_DEFBUTTON3 The third button is the default button.
MB_DEFBUTTON4 The fourth button is the default button.



Specify one of the following flags to indicate the modality of the dialog box: Flag Meaning
MB_APPLMODAL The user must respond to the message box before continuing work in the window identified by the hWnd parameter. However, the user can move to the windows of other threads and work in those windows.
Depending on the hierarchy of windows in the application, the user may be able to move to other windows within the thread. All child windows of the parent of the message box are automatically disabled, but popup windows are not.

MB_APPLMODAL is the default if neither MB_SYSTEMMODAL nor MB_TASKMODAL is specified.

MB_SYSTEMMODAL Same as MB_APPLMODAL except that the message box has the WS_EX_TOPMOST style. Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention (for example, running out of memory). This flag has no effect on the user's ability to interact with windows other than those associated with hWnd.
MB_TASKMODAL Same as MB_APPLMODAL except that all the top-level windows belonging to the current thread are disabled if the hWnd parameter is NULL. Use this flag when the calling application or library does not have a window handle available but still needs to prevent input to other windows in the calling thread without suspending other threads.



In addition, you can specify the following flags:

MB_DEFAULT_DESKTOP_ONLY
The desktop currently receiving input must be a default desktop; otherwise, the function fails. A default desktop is one an application runs on after the user has logged on.
MB_HELP
Adds a Help button to the message box. Choosing the Help button or pressing F1 generates a Help event.
MB_RIGHT
The text is right-justified.
MB_RTLREADING
Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems.
MB_SETFOREGROUND
The message box becomes the foreground window. Internally, the system calls the SetForegroundWindow function for the message box.
MB_TOPMOST
The message box is created with the WS_EX_TOPMOST window style.
MB_SERVICE_NOTIFICATION
Windows NT: The caller is a service notifying the user of an event. The function displays a message box on the current active desktop, even if there is no user logged on to the computer.
If this flag is set, the hWnd parameter must be NULL. This is so the message box can appear on a desktop other than the desktop corresponding to the hWnd.

For Windows NT version 4.0, the value of MB_SERVICE_NOTIFICATION has changed. See WINUSER.H for the old and new values. Windows NT 4.0 provides backward compatibility for pre-existing services by mapping the old value to the new value in the implementation of MessageBox and MessageBoxEx. This mapping is only done for executables that have a version number, as set by the linker, less than 4.0.

To build a service that uses MB_SERVICE_NOTIFICATION, and can run on both Windows NT 3.x and Windows NT 4.0, you have two choices. At link-time, specify a version number less than 4.0; or

2. At link-time, specify version 4.0. At run-time, use the GetVersionEx function to check the system version. Then when running on Windows NT 3.x, use MB_SERVICE_NOTIFICATION_NT3X; and on Windows NT 4.0, use MB_SERVICE_NOTIFICATION.



MB_SERVICE_NOTIFICATION_NT3X
Windows NT: This value corresponds to the value defined for MB_SERVICE_NOTIFICATION for Windows NT version 3.51.
Dhammacakkhu 2002-04-28
  • 打赏
  • 举报
回复
ok
搜索以前贴子找到了
renzhm 2002-04-28
  • 打赏
  • 举报
回复
MB_ICONSTOP,MB_ICONWARNING,MB_ICONINFORMATION

Search help,ok?
Dhammacakkhu 2002-04-28
  • 打赏
  • 举报
回复
呵呵,立即给分的
luoyyh9 2002-04-28
  • 打赏
  • 举报
回复
一定要给分啊
Dhammacakkhu 2002-04-28
  • 打赏
  • 举报
回复
这个我也知道,我要的是带图标的
dreamfan 2002-04-28
  • 打赏
  • 举报
回复
MB_ABORTRETRYIGNORE The message box contains three push buttons: Abort, Retry, and Ignore.
MB_OK The message box contains one push button: OK. This is the default.
MB_OKCANCEL The message box contains two push buttons: OK and Cancel.
MB_RETRYCANCEL The message box contains two push buttons: Retry and Cancel.
MB_YESNO The message box contains two push buttons: Yes and No.
MB_YESNOCANCEL The message box contains three push buttons: Yes, No, and Cancel.

MessageBox returns 0 if there isn’t enough memory to create the message box. Otherwise it returns one of the following values:

Value Numeric value Meaning

IDOK 1 The user chose the OK button.
IDCANCEL 2 The user chose the Cancel button.
IDABORT 3 The user chose the Abort button.
IDRETRY 4 The user chose the Retry button.
IDIGNORE 5 The user chose the Ignore button.
IDYES 6 The user chose the Yes button.
IDNO 7 The user chose the No button.
unit TreeViewFunctions; interface uses Windows, Messages, SysUtils, Variants, Classes, ComCtrls, Controls, Forms, FileCtrl, StrUtils, Masks, Vcl.OleCtrls, SHDocVw, IOUtils; procedure SaveTreeViewExplandState(TreeView: TTreeView; FileName: string); procedure LoadTreeViewExplandState(TreeView: TTreeView; FileName: string); function ExtractNewFolderPath(FileName: string; NewText: string): string; procedure HideHideHorizontalScrollBar(TreeView: TTreeView); function IsEmptyDir(sDir: String): Boolean; function AttachMentsExists(FileName: String): Boolean; procedure SetIcons(TreeView: TTreeView; list: TStringList); procedure EnumText(s: string; aItem: TTreeNode); function AttachmentsFolder(FileName: String): string; function ExtractNodeFullPath(TreeView: TTreeView): string; function Get_node_path(node: TTreeNode): string; function ExtractTreeViewFileName(RootPath: string; TreeView: TTreeView): string; /// /// Node.Selected := true; Node.Focused := true; /// /// /// Node.Selected := true; Node.Focused := true; /// /// /// Node.Selected := true; Node.Focused := true; /// function OpenFile(Path: string; RichEdit: TRichEdit; TreeView: TTreeView) : Boolean; overload; function OpenFile(Path: string; Webbrowser: TWebbrowser; TreeView: TTreeView) : Boolean; overload; procedure GetDirectories(Tree: TTreeView; Directory: string; Item: TTreeNode; IncludeFiles: Boolean); procedure DirToTreeView(Tree: TTreeView; Directory: string; Root: TTreeNode; IncludeFiles: Boolean; FileExt: string); procedure QSetPerpoty(TreeView: TTreeView); function ItemExist(Text: string; TreeView: TTreeView): Boolean; function RemoveDirs(folderPath: string): Boolean; function __RenameFile(OldName: string; Title: string): Boolean; function RenameFolder(filePath: string; Title: string): Boolean; var list: TStringList; implementation { // "D:\C++Builder学习大全中文版\index.htm" // "D:\C++Builder学习大全中文版\" // "index_files" // "D:\C++Builder学习大全中文版\index_files" var s, s1, s2: string; begin s := 'D:\C++Builder学习大全中文版\index.htm'; s1:=ExtractNewFolderPath(s,'_files'); s2 := ExtractNewFolderPath(s, '_AttachMents'); Memo1.lines.Add(s); Memo1.Lines.Add(s1); Memo1.lines.Add(s2); end; } function ExtractNewFolderPath(FileName: string; NewText: string): string; var _filesFolder: string; // "D:\C++Builder学习大全中文版\" _filesFolderName: string; // "index_files" _filesFolderPath: String; begin _filesFolder := ExtractFilePath(FileName); _filesFolderName := ChangeFileExt(ExtractFileName(FileName), '') + NewText; _filesFolderPath := _filesFolder + _filesFolderName; Result := _filesFolderPath; end; { SaveTreeViewExplandState(TreeView1,'TreeView.txt'); } procedure SaveTreeViewExplandState(TreeView: TTreeView; FileName: string); var list: TStringList; i: Integer; begin list := TStringList.Create; With TreeView do begin for i := 0 to Items.Count - 1 do begin if Items.Item[i].Expanded then list.Add(IntToStr(i)); end; list.Add(IntToStr(Selected.AbsoluteIndex)); end; list.SaveToFile(FileName); list.free; end; { LoadTreeViewExplandState(TreeView1, 'abc.txt'); } procedure LoadTreeViewExplandState(TreeView: TTreeView; FileName: string); var list: TStringList; i: Integer; node: TTreeNode; begin list := TStringList.Create; with list do begin list.LoadFromFile(FileName); for i := 0 to Count - 2 do // 最后一行放的是最后选中的那个节点索引 begin TreeView.Items[StrToInt(list[i])].Expand(False); end; node := TreeView.Items[StrToInt(list[Count - 1])]; TreeView.Select(TreeView.Items[StrToInt(list[Count - 1])], []); // node.Selected := True; // node.Focused := True; TreeView.SetFocus; TreeView.Focused; free; end; end; { FUNCTION ulong ShowScrollBar(ulong hwnd,ulong wBar,ulong bShow) LIBRARY "user32.dll" constant long SB_HORZ = 0 constant long SB_VERT = 1 constant long SB_BOTH = 3 } procedure HideHideHorizontalScrollBar(TreeView: TTreeView); begin // no responed NEW FORM TEST // ShowScrollBar(TreeView.Handle,SB_HORZ,False); end; // procedure // begin // { 当拖拽的高度不够的时候自动滚动滚动条 } // with TreeView1 do // begin // if (Y < 15) then // SendMessage(Handle, WM_VSCROLL, SB_LINEUP, 0) // else if (Height - Y < 15) then // SendMessage(Handle, WM_VSCROLL, SB_LINEDOWN, 0); // end; // end; { 返回 附件文件夹 "D:\C++Builder学习大全中文版\新建文本文档.htm" D:\C++Builder学习大全中文版\新建文本文档_Attachments } function AttachmentsFolder(FileName: String): string; begin Result := ExtractFilePath(FileName) + ChangeFileExt(ExtractFileName(FileName), '') + '_Attachments'; end; function AttachMentsExists(FileName: String): Boolean; var f: string; begin f := ExtractFilePath(FileName) + ChangeFileExt(ExtractFileName(FileName), '') + '_Attachments'; Result := DirectoryExists(f); end; procedure EnumText(s: string; aItem: TTreeNode); var node: TTreeNode; str: string; begin node := aItem; while node nil do begin if s = '' then str := node.Text else str := s + '\' + node.Text; list.Add(str); /// ////////////////////////// if node.HasChildren then EnumText(str, node.getFirstChild); node := node.getNextSibling; end; end; function IsEmptyDir(sDir: String): Boolean; var sr: TSearchRec; begin Result := True; if Copy(sDir, Length(sDir) - 1, 1) '\' then sDir := sDir + '\'; if FindFirst(sDir + '*.*', faAnyFile, sr) = 0 then repeat if (sr.Name '.') and (sr.Name '..') then begin Result := False; break; end; until FindNext(sr) 0; FindClose(sr); end; { 是文件 夹的设置为1 是文件 的设置为 2 } procedure SetIcons(TreeView: TTreeView; list: TStringList); var i: Integer; begin with TreeView do begin for i := 0 to Items.Count - 1 do begin if DirectoryExists(list.Strings[i]) then begin Items[i].ImageIndex := 0; Items[i].SelectedIndex := 0; Items[i].StateIndex := 0; end; if FileExists(list.Strings[i]) then begin Items[i].ImageIndex := 1; Items[i].SelectedIndex := 1; Items[i].StateIndex := 1; end; if (AttachMentsExists(list.Strings[i])) then if not IsEmptyDir(AttachmentsFolder(list.Strings[i])) then begin // Form1.Memo1.LINES.Add( AttachmentsFolder(list.Strings[i])); Items[i].ImageIndex := 2; Items[i].SelectedIndex := 2; Items[i].StateIndex := 2; end; end; end; end; procedure QSetPerpoty(TreeView: TTreeView); begin with TreeView do begin // Align := alBottom; // Anchors := [akLeft, akTop, akBottom, akRight]; Items.Clear; // BorderStyle := bsNone; Cursor := crHandPoint; ReadOnly := True; ShowHint := True; RowSelect := True; ShowButtons := True; ShowRoot := True; ShowLines := False; SortType := stText; HideSelection := False; RightClickSelect := True; DragMode := dmAutomatic; // Color := RGB(238, 243, 246); end; end; { 实际重命名 C:\windows\test.txt C:\windows\csadsajas.txt MoveFile(PChar('C:\1.txt'),PChar('C:\ABC.txt')); if not __RenameFile('C:\tree.txt','TreeView') then Application.MessageBox('重命名文件失败','重命名',MB_ICONERROR); } { 重命名文件 } function __RenameFile(OldName: string; Title: string): Boolean; var NewName: string; begin NewName := Format('%s%s%s', [ExtractFilePath(OldName), Title, ExtractFileExt(OldName)]); Result := MoveFile(PChar(OldName), PChar(NewName)); end; // 重命名文件夹 // RenameFolder('C:\1\','2'); // MoveFile('C:\1','C:\2'); // MoveFile('C:\1\','C:\2\'); function RenameFolder(filePath: string; Title: string): Boolean; var s, s1: string; begin // filePath:='C:\Windows\System32\'; // s = ExtractFileDir(filepath) = 'C:\Windows\System32' s := ExtractFileDir(filePath); // s1 = ExtractFileDir(s) = 'C:\Windows' // s1 ='C:\Windows' +'\'+ titles s1 := ExtractFileDir(s) + '\' + Title; Result := MoveFile(PChar(s), PChar(s1)); end; { IOUtils } function RemoveDirs(folderPath: string): Boolean; begin Result := False; if TDirectory.IsEmpty(folderPath) then begin TDirectory.Delete(folderPath); Result := True; end else begin if Application.MessageBox('确定要删除这个文件夹吗? 删除后无法恢复!', '提示', MB_ICONQUESTION + MB_YESNO) = ID_YES then begin TDirectory.Delete(folderPath, True); Result := True; end; end; // if TDirectory.Exists(folderPath) then // begin // Application.MessageBox('删除文件失败'+#13#10+'文件正确被使用?','错误',MB_ICONERROR+MB_OK); // Result:=False; // end; end; { if not ItemExist('Edit1.Text',TreeView1) then TreeView1.Items.AddChild(Treeview1.Selected,'Edit1.Text'); } function ItemExist(Text: string; TreeView: TTreeView): Boolean; var i: Integer; begin Result := False; if (Trim(Text) '') then begin for i := 0 to TreeView.Items.Count - 1 do if Trim(Text) = Trim(TreeView.Items[i].Text) then begin Result := True; Exit; end; end; Result := False; end; // ------------------------------------------------------------------------------ { TreeView获得选中的完整路径 aaaa\ssss\bbbb } function ExtractNodeFullPath(TreeView: TTreeView): string; var Path: string; Parent: TTreeNode; // Node: TTreeNode; begin Path := TreeView.Selected.Text; Parent := TreeView.Selected.Parent; while Parent nil do begin Path := Parent.Text + '\' + Path; Parent := Parent.Parent; end; Result := Path; end; function Get_node_path(node: TTreeNode): string; var Path: string; TreeNode: TTreeNode; begin Path := node.Text; TreeNode := node.Parent; while TreeNode nil do begin Path := TreeNode.Text + '\' + Path; TreeNode := TreeNode.Parent; end; Result := Path; end; { 获得文件完整路径 C:\abc\int.cpp } function ExtractTreeViewFileName(RootPath: string; TreeView: TTreeView): string; var FileName: string; begin Result := ''; if TreeView.Selected = nil then Exit; FileName := RootPath + ExtractNodeFullPath(TreeView); // 当前选中的文件名 if not FileExists(FileName) then Exit; Result := FileName; end; { 用RICHEDIT打开TREEVIEW中的文件 } function OpenFile(Path: string; RichEdit: TRichEdit; TreeView: TTreeView) : Boolean; overload; var FileName: string; begin Result := False; FileName := ExtractTreeViewFileName(Path, TreeView); if FileExists(FileName) then begin RichEdit.Lines.LoadFromFile(FileName); Result := True; end end; function OpenFile(Path: string; Webbrowser: TWebbrowser; TreeView: TTreeView) : Boolean; overload; var FileName: string; begin Result := False; FileName := ExtractTreeViewFileName(Path, TreeView); if FileExists(FileName) then begin Webbrowser.Navigate(FileName); Result := True; end end; { 将1个目录里面所有的文件添加到TREEVIEW中 GetDirectories(TreeView1, 'D:\DATA', nil, True); } procedure GetDirectories(Tree: TTreeView; Directory: string; Item: TTreeNode; IncludeFiles: Boolean); var SearchRec: TSearchRec; ItemTemp: TTreeNode; begin Tree.Items.BeginUpdate; if Directory[Length(Directory)] '\' then Directory := Directory + '\'; if FindFirst(Directory + '*.*', faDirectory, SearchRec) = 0 then begin repeat if (SearchRec.Attr and faDirectory = faDirectory) and (SearchRec.Name[1] '.') then begin if (SearchRec.Attr and faDirectory > 0) then Item := Tree.Items.AddChild(Item, SearchRec.Name); ItemTemp := Item.Parent; GetDirectories(Tree, Directory + SearchRec.Name, Item, IncludeFiles); Item := ItemTemp; end else if IncludeFiles then if SearchRec.Name[1] '.' then Tree.Items.AddChild(Item, SearchRec.Name); until FindNext(SearchRec) 0; FindClose(SearchRec); Tree.Items.EndUpdate; end; end; { 将1个目录里面所有的文件添加到TREEVIEW中 DirToTreeView(TreeView1,'D:\Data\',nil,True,'.cpp'); } procedure DirToTreeView(Tree: TTreeView; Directory: string; Root: TTreeNode; IncludeFiles: Boolean; FileExt: string); var SearchRec: TSearchRec; Node1: TTreeNode; begin with Tree.Items do begin BeginUpdate; if Directory[Length(Directory)] '\' then Directory := Directory + '\'; if FindFirst(Directory + '*.*', faDirectory, SearchRec) = 0 then begin Application.ProcessMessages; repeat { 添加文件夹 } if (SearchRec.Attr and faDirectory = faDirectory) and (SearchRec.Name[1] '.') then begin if SameText(RightStr(SearchRec.Name, 12), '_AttachMents') then // 不添加 _AttachMents这个文件夹 Continue; if (SearchRec.Attr and faDirectory > 0) then Root := AddChild(Root, SearchRec.Name); Node1 := Root.Parent; DirToTreeView(Tree, Directory + SearchRec.Name, Root, IncludeFiles, FileExt); Root := Node1; end else if IncludeFiles then { 添加文件 } if SearchRec.Name[1] '.' then { .TXT .txt .TxT .tXT 为一样的 } if SameText(RightStr(SearchRec.Name, 4), FileExt) then { 只添加 .CPP格式文件 } AddChild(Root, SearchRec.Name); until FindNext(SearchRec) 0; FindClose(SearchRec) end; EndUpdate; end; end; end.

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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