1// MSGBOX.pkg 2// 3// 08/02/96 JJT - Checks a little harder for a container handle. If object 4// using this is inactive (no handle) we want it to look for 5// its parent handle. Else we get modeless confirm 6// 09/12/96 JJT - Add addition Default button support 7// 8Use VdfBase.pkg 9Use LanguageText.pkg 10Use Dll.pkg 11Use WinUser.pkg 12Use GlobalFunctionsProcedures.pkg 13 14// Buttons required 15#replace MB_OK |CI$00000000 16#replace MB_OKCANCEL |CI$00000001 17#replace MB_ABORTRETRYIGNORE |CI$00000002 18#replace MB_YESNOCANCEL |CI$00000003 19#replace MB_YESNO |CI$00000004 20#replace MB_RETRYCANCEL |CI$00000005 21 22// Icon required 23#replace MB_ICONHAND |CI$00000010 24#replace MB_ICONQUESTION |CI$00000020 25#replace MB_ICONEXCLAMATION |CI$00000030 26#replace MB_ICONASTERISK |CI$00000040 27#replace MB_ICONWARNING MB_ICONEXCLAMATION 28#replace MB_ICONERROR MB_ICONHAND 29#replace MB_ICONINFORMATION MB_ICONASTERISK 30#replace MB_ICONSTOP MB_ICONHAND 31 32// Default to which button 33 34#replace MB_DEFBUTTON1 |CI$00000000 35#replace MB_DEFBUTTON2 |CI$00000100 36#replace MB_DEFBUTTON3 |CI$00000200 37#replace MB_DEFBUTTON4 |CI$00000300 38 39// Modal Type 40#replace MB_APPLMODAL |CI$00000000 41#replace MB_SYSTEMMODAL |CI$00001000 42#replace MB_TASKMODAL |CI$00002000 43 44#replace MB_HELP |CI$00004000 45#replace MB_RIGHT |CI$00080000 46#replace MB_RTLREADING |CI$00100000 47 48#replace MB_NOFOCUS |CI$00008000 49#replace MB_SETFOREGROUND |CI$00010000 50#replace MB_DEFAULT_DESKTOP_ONLY |CI$00020000 51#replace MB_SERVICE_NOTIFICATION |CI$00040000 52 53#replace MB_TYPEMASK |CI$0000000F 54 55#replace MB_USERICON |CI$00000080 56 57#replace MB_ICONMASK |CI$000000F0 58#replace MB_DEFMASK |CI$00000F00 59#replace MB_MODEMASK |CI$00003000 60#replace MB_MISCMASK |CI$0000C000 61 62// Function Return Values 63#REPLACE MBR_Ok 1 64#REPLACE MBR_Cancel 2 65#REPLACE MBR_Abort 3 66#REPLACE MBR_Retry 4 67#REPLACE MBR_Ignore 5 68#REPLACE MBR_Yes 6 69#REPLACE MBR_No 7 70 71External_Function MessageBox "MessageBoxA" User32.dll ; 72 Handle hWndParent ; 73 String sText ; 74 String sCaption ; 75 DWord wType ; 76 Returns Integer 77 78Function Message_Box GLOBAL String sMessage String sCaption ; 79 Integer Btns Integer Icon returns Integer 80 Boolean bEnabled 81 Handle hWnd hwPrnt hwTest hwOwner 82 String IncorrectNewline 83 String szMessage szCaption 84 Pointer lpszMessage lpszCaption 85 integer rval iVoid Obj 86 87 Move (Replaces("\n",sMessage,Character(13))) to sMessage 88 Move (sMessage +character(0)) To szMessage 89 90 Move "" To IncorrectNewline 91 Append IncorrectNewline "\" (Character(13)) 92 Move (Replaces(IncorrectNewline, szMessage, "\n")) To szMessage 93 94 GetAddress of szMessage To lpszMessage 95 Move (OemToAnsi(lpszMessage,lpszMessage)) To iVoid 96 97 Move (sCaption +character(0)) To szCaption 98 GetAddress of szCaption To lpszCaption 99 Move (OemToAnsi(lpszCaption,lpszCaption)) To iVoid 100 101 // 8.3 change. Global methods should not be using self. We will have message boxes use 102 // the focus as a starting point for looking for a container handle. (this was changed for 12.0 - see below) 103 104 105 Get Focus of desktop to Obj // start with the focus 106 Move (gOwnerWindowHandle(Obj)) to hWnd // global function finds the right handle for us 107 // If no main-window, use container_handle of focus. If no window handle, use MB_TASKMODAL. We don't always use this 108 // because it adds the message box to the caption bar. 109 Move (MessageBox (hWnd, szMessage, szCaption, Btns IOR Icon IOR If(hWnd=0,MB_TASKMODAL,0))) To rval 110 Function_Return rVal 111End_Function 112 113Procedure Info_Box GLOBAL String sMessage String sTitle 114 Handle hWnd 115 String sCaption 116 integer rval 117 If Num_Arguments eq 1 Move C_$Information To sCaption 118 Else Move sTitle To sCaption 119 Get Message_Box sMessage sCaption MB_OK MB_ICONINFORMATION to rval 120End_Procedure 121 122Procedure Stop_Box GLOBAL String sMessage String sTitle 123 Handle hWnd 124 String sCaption 125 Integer rval 126 If (Num_Arguments eq 1 or sTitle='') Move C_$Stop To sCaption 127 Else Move sTitle To sCaption 128 Get Message_Box sMessage sCaption MB_OK MB_ICONHAND to rval 129End_Procedure 130 131Function YesNo_Box GLOBAL String sMessage String sTitle Integer DfltBtn ; 132 Returns Integer 133 Handle hWnd 134 String sCaption 135 Integer Dflt 136 Integer rval 137 138 If (Num_Arguments = 1 or sTitle = '') Move C_$Question To sCaption 139 Else Move sTitle To sCaption 140 141 If (Num_Arguments < 3 OR DfltBtn = 0 OR DfltBtn = MB_DEFBUTTON1); 142 Move MB_DEFBUTTON1 to Dflt 143 Else ; 144 Move MB_DEFBUTTON2 to Dflt 145 146 Get Message_Box sMessage sCaption MB_YESNO (MB_ICONQUESTION IOR Dflt) ; 147 to rval 148 149 Function_Return rval 150End_Function 151 152Function YesNoCancel_Box GLOBAL String sMessage String sTitle Integer DfltBtn ; 153 Returns Integer 154 Handle hWnd 155 String sCaption 156 Integer rval 157 Integer Dflt 158 159 If (Num_Arguments = 1 or sTitle = '') Move C_$Question To sCaption 160 Else Move sTitle To sCaption 161 162 If (Num_Arguments < 3 OR DfltBtn = 0 OR DfltBtn = MB_DEFBUTTON1); 163 Move MB_DEFBUTTON1 to Dflt 164 Else If (DfltBtn = 1 OR DfltBtn = MB_DEFBUTTON2); 165 Move MB_DEFBUTTON2 to Dflt 166 Else ; 167 Move MB_DEFBUTTON3 to Dflt 168 169 Get Message_Box sMessage sCaption MB_YESNOCANCEL (MB_ICONQUESTION IOR Dflt) ; 170 to rval 171 172 Function_Return rval 173End_Function