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