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