MessageBox

As you know Delphi™ has several dialog functions MessageDlg or MessageDlgPos and so on but there is no way i know of to specify the caption of a messagebox without using a form with borderstyle bsDialog.Windows has an api function called MessageBox wich allows you to specirfy your own title for the messagebox because Delphi™ is a windows® programming language it can use this function.It can have several buttons but only one icon and you can make it modal to force the users to respond the message first below you'll find a table with possible messageboxes.


Buttons

Flag Meaning
MB_OK The messagebox has one okbutton
MB_OKCANCEL The messagebox has two buttons ok and cancel
MB_RETRYCANCEL The messagebox has two buttons retry and cancel
MB_YESNO The messagebox has two buttons yes and no
MBYESNOCANCEL The messagebox has three buttons yes no and cancel
MB_ABORTRETRYIGNORE abort retry and ignore buttons


Icons

Flag Meaning
MB_ICONEXCLAMATION The warning icon
MB_ICONWARNING Same as the first one
MB_ICONINFORMATION the info icon
MB_ICONASTERISK Information icon
MB_ICONQUESTION In Delphi this is mtConfirmation
MB_ICONERROR the error icon


Return values

Flag Meaning
IDYES the yes button was clicked
IDRETRY the retry button was clicked
IDOK the ok button was clicked
IDNO the no button was clicked
IDIGNORE the ignore button was clicked
IDCANCEL the cancel button was clicked
IDABORT the abort button was clicked

the api function MessageBox has allot more to offer to much to publisch here but if you want to make your messagebox modal so that the user has to respond to the messagebox use the flag MB_APPLMODAl
example to show a messagebox with buttons yes and no and the question icon
MessageBox(0, PChar('don't you think so to ?'), PChar('Hello DelphiVillage is a cool Website he ?'), MB_YESNO + MB_ICONQUESTION); offcource this is Delphi™ code you can see the result below

screenshot


Navigation links

index main page of this website
info file extensions produced by the Delphi ide
ide Delphi ide information
tips Delphi keyboard shortcuts etc
sourcecode Delphi source code
about info about me
books a list of Delphi books
board Delphi programming dscussion board
guestbook let me know you where here in my guestbook
newsgroups a list of Delphi discussion newsgroups
webring wanna join the DelphiVillage webring?
help how to create windows® help files?
components how to build Delphi components?
delphi™ topsites i joined many toplist here is mine
setup how to build a setup program?






Delphi™ is a ® trademark from Borland software company inc.
Windows™ is a ® trademark from Microsoft corporation
DelphiVillage copyright © 2001 Loos Erik all rights reserved