1 // Written by Christopher E. Miller 2 // See the included license.txt for copyright and license details. 3 4 module dfl.messagebox; 5 6 import core.sys.windows.windows; 7 import dfl.internal.dlib; 8 import dfl.base; 9 10 enum MsgBoxButtons { 11 ABORT_RETRY_IGNORE = MB_ABORTRETRYIGNORE, 12 OK = MB_OK, 13 OK_CANCEL = MB_OKCANCEL, 14 RETRY_CANCEL = MB_RETRYCANCEL, 15 YES_NO = MB_YESNO, 16 YES_NO_CANCEL = MB_YESNOCANCEL, 17 } 18 19 enum MsgBoxIcon { 20 NONE = 0, 21 22 ASTERISK = MB_ICONASTERISK, 23 ERROR = MB_ICONERROR, 24 EXCLAMATION = MB_ICONEXCLAMATION, 25 HAND = MB_ICONHAND, 26 INFORMATION = MB_ICONINFORMATION, 27 QUESTION = MB_ICONQUESTION, 28 STOP = MB_ICONSTOP, 29 WARNING = MB_ICONWARNING, 30 } 31 32 enum MsgBoxDefaultButton { 33 BUTTON1 = MB_DEFBUTTON1, 34 BUTTON2 = MB_DEFBUTTON2, 35 BUTTON3 = MB_DEFBUTTON3, 36 37 // Extra. 38 BUTTON4 = MB_DEFBUTTON4, 39 } 40 41 enum MsgBoxOptions { 42 DEFAULT_DESKTOP_ONLY = MB_DEFAULT_DESKTOP_ONLY, 43 RIGHT_ALIGN = MB_RIGHT, 44 LEFT_ALIGN = MB_RTLREADING, 45 SERVICE_NOTIFICATION = MB_SERVICE_NOTIFICATION, 46 } 47 48 DialogResult msgBox(Dstring txt) { 49 return cast(DialogResult) dfl.internal.utf.messageBox(GetActiveWindow(), txt, "\0", 50 MB_OK); 51 } 52 53 DialogResult msgBox(IWindow owner, Dstring txt) { 54 return cast(DialogResult) dfl.internal.utf.messageBox( 55 owner ? owner.handle : GetActiveWindow(), txt, "\0", MB_OK); 56 } 57 58 DialogResult msgBox(Dstring txt, Dstring caption) { 59 return cast(DialogResult) dfl.internal.utf.messageBox(GetActiveWindow(), txt, caption, 60 MB_OK); 61 } 62 63 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption) { 64 return cast(DialogResult) dfl.internal.utf.messageBox( 65 owner ? owner.handle : GetActiveWindow(), txt, caption, MB_OK); 66 } 67 68 DialogResult msgBox(Dstring txt, Dstring caption, MsgBoxButtons buttons) { 69 return cast(DialogResult) dfl.internal.utf.messageBox(GetActiveWindow(), txt, caption, 70 buttons); 71 } 72 73 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption, MsgBoxButtons buttons) { 74 return cast(DialogResult) dfl.internal.utf.messageBox( 75 owner ? owner.handle : GetActiveWindow(), txt, caption, buttons); 76 } 77 78 DialogResult msgBox(Dstring txt, Dstring caption, MsgBoxButtons buttons, MsgBoxIcon icon) { 79 return cast(DialogResult) dfl.internal.utf.messageBox(GetActiveWindow(), 80 txt, caption, buttons | icon); 81 } 82 83 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption, 84 MsgBoxButtons buttons, MsgBoxIcon icon) { 85 return cast(DialogResult) dfl.internal.utf.messageBox( 86 owner ? owner.handle : GetActiveWindow(), txt, caption, buttons | icon); 87 } 88 89 DialogResult msgBox(Dstring txt, Dstring caption, MsgBoxButtons buttons, 90 MsgBoxIcon icon, MsgBoxDefaultButton defaultButton) { 91 return cast(DialogResult) dfl.internal.utf.messageBox(GetActiveWindow(), 92 txt, caption, buttons | icon | defaultButton); 93 } 94 95 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption, 96 MsgBoxButtons buttons, MsgBoxIcon icon, MsgBoxDefaultButton defaultButton) { 97 return cast(DialogResult) dfl.internal.utf.messageBox( 98 owner ? owner.handle : GetActiveWindow(), txt, caption, buttons | icon | defaultButton); 99 } 100 101 DialogResult msgBox(IWindow owner, Dstring txt, Dstring caption, 102 MsgBoxButtons buttons, MsgBoxIcon icon, MsgBoxDefaultButton defaultButton, MsgBoxOptions options) { 103 return cast(DialogResult) dfl.internal.utf.messageBox( 104 owner ? owner.handle : GetActiveWindow(), txt, caption, 105 buttons | icon | defaultButton | options); 106 } 107 108 deprecated final class MessageBox { 109 private this() { 110 } 111 112 static: 113 deprecated alias show = msgBox; 114 } 115 116 deprecated alias messageBox = msgBox; 117 118 deprecated alias MessageBoxOptions = MsgBoxOptions; 119 deprecated alias MessageBoxDefaultButton = MsgBoxDefaultButton; 120 deprecated alias MessageBoxButtons = MsgBoxButtons; 121 deprecated alias MessageBoxIcon = MsgBoxIcon;