Use Windows.pkg Use msgbox.pkg Use DTFUNC.PKG Use MessageboxLanguage.pkg Use Dftimer.pkg Use monitor.pkg // // "Message Box 2.02" // Copyright 2014 Davidian Busines Services // Free for use for any purpose, provided as-is // Report bugs/send enhancements to: matthewd@datatechag.com // // new and improved message box replacement "2.0" // 1. Works with new font system in 17.1 (not hardcoded to Microsoft Sans Serif) // 2. Backwards compatible with old 15.0 Message Box replacement, including Help button and Checkbox control // 3. Can be used via struct interface to define more elaborate message boxes, including support for: // A. Multiple sections of text // B. font size/bold/italic/underline formatting of text in each section (17.0+) // C. Multiple checkboxes // D. mini-icons (16x16 bitmaps) // E. Buttons other than Ok/Cancel/Yes/No/Abort/Retry/Fail // 4. Message boxes can appear on the "correct" monitor in multi-monitor setups // // Changes since release 2.0: // added global handle to refer to message box object: ghoMessageBox // add property of message box object pbDisplayOnFocusMonitor to display the dialog on the same monitor as focus object // added hoMonitor member (a handle to a VDF object, not a monitor handle) // implemented code for hMonitor member (this is a handle to a monitor) // fixed StandardButtons function (wasn't returning a value, renamed to mbButtons) // added helper messages to return messagebox and message structs // MessageBoxLanguage.pkg with Dutch labels contributed by Pieter van Dieran, labels // for additional languages should be added to this file. // added property for button width, piButtonWidth, this is initialized to the // constant C_mbButtonWidth defined in MessageBoxLanguage.pkg // // Possible future enhancements: // Set maximum width and wrap text accordingly (defined in struct member .iWidth) // Input dialog (for dates/strings/numbers/etc) // Add other predefined bitmaps // // Changes since release 2.01: // added a timeout property to automatically close the message box by setting the iTimeout member of the // tmbMessageBox struct to the number of milliseconds to keep the message dialog open Define MBR_CHECKED For |CI$01000000 Define MBR_CHECKED2 For |CI$02000000 Define MBR_MASK For |CI$0000000F Define MB_ICONDOWNLOAD For |CI$00000050 Define MB_DEFBUTTONMASK For |CI$00000F00 Struct tmbMessageText String sMessage String sBitmap // "mini-icon" 16x16 icon that will appear to the left of the text section Integer iIndent Integer iFontPointHeight Boolean bBold // bold text Boolean bItalic // italic Boolean bUnderline // underline Boolean bCheckbox // if true, this message is a checkbox Boolean bChecked // default state of checkbox Integer iSpaceAfter // spacing after this message Handle _hoCheckbox // private, handle to checkbox object End_Struct Struct tmbButtons String sLabel // label (not required if a predefined button) Boolean bDefault // set to true for one button Integer iType // return value when this button is clicked, MBR_Yes, MBR_OK, MBR_No, etc. Handle hoObject End_Struct Struct tmbMessageBox String sTitle // title of message box String sBitmap // bitmap to display Integer iBitmap // predefined bitmaps to display Integer iWidth // override calculated width Integer iHelp // help id (if zero, no help button) String sHtmlHelpTopic // Handle hoMonitor // a handle to a dataflex object; the message box will appear on the same monitor as this object Handle hMonitor // a monitor handle tmbMessageText[] Message // 1 or more messages/checkboxes to display tmbButtons[] Button // 1 or more buttons Integer iRetVal // return value of button clicked Integer iTimeout // milliseconds until automatic timeout Integer iButtonWidth // width of buttons (overrides piButtonWidth if set) Integer iButtonHeight End_Struct Struct tmbDeferredCheckbox String sLabel // label for checkbox Integer iY // vertical pos for checkbox Integer iMsgIndex // index into tmbMessageText array for source of checkbox End_Struct Class cmbTextBox is a TextBox // dummy message Procedure Set CurrentButtonState Integer iState End_Procedure End_Class Register_Function piButtonWidth Returns Integer Register_Function piButtonHeight Returns Integer Class cmbButton is a Button Procedure construct_object Property Integer piButtonType_private 0 Forward Send Construct_Object Set Size to (piButtonHeight(Self)) (piButtonWidth(Self)) Set Default_State to False On_Key Key_Right_Arrow Send previous On_Key Key_Left_Arrow Send next End_Procedure Procedure Set piButtonType Integer iType Set piButtonType_private to iType If (iType=-1) Set label to C_$MessageBoxHelp // -1 If (iType=MBR_Ok) Set label to C_$MessageBoxOk // 1 If (iType=MBR_Cancel) Set label to C_$MessageBoxCancel // 2 If (iType=MBR_Abort) Set label to C_$MessageBoxAbort // 3 If (iType=MBR_Retry) Set label to C_$MessageBoxRetry // 4 If (iType=MBR_Ignore) Set label to C_$MessageBoxIgnore // 5 If (iType=MBR_Yes) Set label to C_$MessageBoxYes // 6 If (iType=MBR_No) Set label to C_$MessageBoxNo // 7 End_Procedure Procedure OnClick If (piButtonType_private(Self)>=0) Delegate Send OnClick (piButtonType_private(Self)) Else Send help HELP_CONTEXT_ID End_Procedure End_Class Class cMessageBox_mixin is a cObject Procedure Define_cMessageBox_mixin Property Integer piButtonPressed 0 Property Boolean pbDisplayOnFocusMonitor True Property Integer piButtonWidth C_mbButtonWidth Property Integer piButtonHeight C_mbButtonHeight Property String psMessageText '' Set Size to 89 211 Set Label to C_$MessageBox Set Location to 2 2 Set Border_Style to Border_Normal Set Sysmenu_Icon to False Set Minimize_Icon to False Set Extended_Window_Style to WS_EX_TOOLWINDOW False Set Locate_Mode to CENTER_ON_PARENT Object oBitmap is a BitmapContainer Set Size to 20 22 Set guiSize to 48 48 Set Location to 6 6 Set Bitmap to "info256.bmp/3d" Set Border_Style to Border_None End_Object End_Procedure Procedure Set CurrentButtonState Integer iState End_Procedure // handle positioning: if pbDisplayOnFocusMonitor is true, get the focus object and place the // message box on the same monitor that the focus object is on, OTHERWISE // hoMonitor may contain a Handle to a VDF Object, and put the message on the same monitor as it, OR // if hMonitor <> 0, use that monitor handle (to force messages to appear on secondary display(s) // since the primary display should always be zero) // otherwise, use the CENTER_ON_SCREEN locate mode. Procedure DeterminePosition tmbMessageBox Msg tMONITORINFO MonitorInfo Integer iSize iLoc iY iX Handle hMonitor Integer iRetVal If (pbDisplayOnFocusMonitor(Self) and Msg.hoMonitor=0) Get Focus to Msg.hoMonitor // If (Msg.hoMonitor=0 and Msg.hMonitor=0) Set Locate_Mode to CENTER_ON_SCREEN Else Begin If (msg.hMonitor=0) Begin Get absolute_GuiOrigin of msg.hoMonitor to iLoc Move (MonitorFromPoint(low(iLoc),Hi(iLoc),MONITOR_DEFAULTONPRIMARY)) to hMonitor End Else Move Msg.hMonitor to hMonitor // Move (SizeofType(tMONITORINFO)) to MonitorInfo.cbSize Move (GetMonitorInfo(hMonitor, AddressOf(MonitorInfo))) to iRetVal If (iRetVal) Begin Set Locate_Mode to NO_LOCATE Get GUISize to iSize Move MonitorInfo.rcMonitor.Top to iY Add ((MonitorInfo.rcMonitor.bottom-monitorInfo.rcMonitor.Top)/2) to iY Subtract (Hi(iSize)/2) from iY Move MonitorInfo.rcMonitor.Left to iX Add ((monitorInfo.rcMonitor.right-MonitorInfo.rcMonitor.Left)/2) to iX Subtract (Low(iSize)/2) from iX Set GuiLocation to iY iX Send Adjust_Logicals End End End_Procedure Procedure ShowMessageBox tmbMessageBox ByRef Msg Integer i Handle[] hoObject Get ConstructMessageBox (&Msg) to hoObject #IF (!@ > 181) // Nils. This is no longer needed for more recent DataFlex versions. // In fact, not commenting it out will/can display the message box on the // wrong screen/monitor. Send DeterminePosition Msg #ENDIF Send Popup // get any checkbox values back into the struct For i from 0 to (SizeOfArray(Msg.Message)-1) If (Msg.Message[i]._hoCheckbox<>0) Get checked_state of Msg.Message[i]._hoCheckbox to Msg.Message[i].bChecked Loop // resize the array in case a timer message was added (struct can then be re-used, not sure you would want to do that, but just in case) If (Msg.iTimeout<>0) Move (ResizeArray(Msg.Message,SizeOfArray(Msg.Message)-1)) to Msg.Message // destroy objects For i from 0 to (Sizeofarray(hoObject)-1) Send Destroy to hoObject[i] Loop Get piButtonPressed to Msg.iRetVal End_Procedure // these are the default bitmaps Function IconBitmap Integer iIcon Returns String Move (iIcon iand MB_ICONMASK) to iIcon If (iIcon=MB_ICONEXCLAMATION) Function_Return "warning256.bmp/3d" If (iIcon=MB_ICONHAND) Function_Return "stop256.bmp/3d" If (iIcon=MB_ICONASTERISK) Function_Return "info256.bmp/3d" If (iIcon=MB_ICONQUESTION) Function_Return "question256.bmp/3d" If (iIcon=MB_ICONDOWNLOAD) Function_Return "download256.bmp/3d" End_Function Function ConstructMessageBox tmbMessageBox ByRef Msg Returns Handle[] Boolean bButtonRepos String sCR sText sLabel sMessageText String[] sMsg Integer i iCnt iLine iLineCnt yPos xPos iSize iMaxLength iWidth iFirstButton iFirstxPos iCheckboxCnt xMaxPos xMsgPos iLineWidth iFirstButtonIndex iButtonSpan Integer iLoc Handle hoObj hoFirstButton Handle[] hoObject tmbDeferredCheckbox[] Checkboxes Set private.Current_Action_button to 0 Set piButtonPressed to 0 // possible if Alt+F4 used Move (character(13)) to sCR Move 8 to yPos If (Msg.sBitmap<>'') Set Bitmap of oBitmap to Msg.sBitmap Else If (Msg.ibitmap<>0) Set Bitmap of oBitmap to (IconBitmap(self,Msg.iBitmap)) Set Label to Msg.sTitle Set piButtonWidth to C_mbButtonWidth Set piButtonHeight to C_mbButtonHeight If (Msg.iButtonWidth<>0) Set piButtonWidth to Msg.iButtonWidth If (Msg.iButtonHeight<>0) Set piButtonHeight to Msg.iButtonHeight // // following loop creates textbox/checkbox/bitmap objects for each line of the each message // line breaks should be indicated with the \n sequence If (Msg.iTimeout<>0) Begin Move (SizeOfArray(Msg.Message)) to i Move (SFormat(C_$MessageBoxTimeout,String(Msg.iTimeout/1000))) to Msg.Message[i].sMessage End For i from 0 to (SizeofArray(Msg.Message)-1) Move (Msg.Message[i].sMessage+"\n") to sText Move (Replaces("\n",sText,sCR)) to sText If (msg.message[i].bCheckbox=False) Move (sMessageText+sText) to sMessageText // for copy Ctrl+C Move (ParseString2(sText,sCR)) to sMsg // Move 40 to xMsgPos For iLine from 0 to (SizeOfArray(sMsg)-1) If (Msg.Message[i].bCheckbox and iLine=0) Begin // checkbox object creation is deferred until after the buttons to set up the desired tab order // we remember the settings here and use them after the buttons are created Move (SizeOfArray(Checkboxes)) to iCheckboxCnt Move sMsg[iLine] to Checkboxes[iCheckboxCnt].sLabel Add 8 to yPos Move yPos to checkboxes[iCheckboxCnt].iY Move i to Checkboxes[iCheckboxCnt].iMsgIndex If (hoObj) Get size of hoObj to iSize Move 0 to hoObj Add (Hi(iSize)) to yPos End Else Begin If (Msg.Message[i].sBitmap<>'' and iLine=0) Begin Object oBitmap is a BitmapContainer Set GuiSize to 16 16 Set Location to yPos xMsgPos Set Bitmap to Msg.Message[i].sBitmap Set Border_Style to Border_None Move Self to hoObj End_Object Send Add_Focus to hoObj Self Move hoObj to hoObject[SizeOfArray(hoObject)] Move 54 to xMsgPos End // indent text box position for multi-line checkbox message If (Msg.Message[i].bCheckbox) Move 50 to xMsgPos If (sMsg[iLine]<>'') Begin Object oTextBox is a cmbTextbox #IF (!@>=170) If (Msg.Message[i].iFontPointHeight<>0) Set FontPointHeight to Msg.Message[i].iFontPointHeight If (Msg.Message[i].bBold) Set FontWeight to 800 If (Msg.Message[i].bItalic) Set FontItalics to True If (Msg.Message[i].bUnderline) Set FontUnderline to True #ENDIF Set Auto_Size_State to True Set Transparent_State to True Set Label to sMsg[iLine] Set Location to yPos (xMsgPos+Msg.Message[i].iIndent) Set Justification_Mode to jMode_Left Move Self to hoObj Get size of hoObj to iSize Add (hi(iSize)) to yPos End_Object Send Add_Focus to hoObj Self End Else Begin // blank line, just increase yPos Add (Hi(iSize)) to yPos Move 0 to hoObj End End If (hoObj<>0) Begin // store object in array for destruction later Move hoObj to hoObject[SizeOfArray(hoObject)] // determine longest element so we know how wide to make the dialog Move (Low(iSize)+If(Msg.Message[i].sBitmap<>'',14,0)) to iLineWidth If (iLineWidth>iMaxLength) Move iLineWidth to iMaxLength End Loop Add Msg.Message[i].iSpaceAfter to yPos Loop Set psMessageText to sMessageText Add 8 to yPos // // determine button horizontal positioning Move (SizeOfArray(Msg.Button)) to iCnt If (Msg.iHelp<>0 or Msg.sHtmlHelpTopic<>'') Add 1 to iCnt Move ((iCnt*piButtonWidth(Self))+((iCnt-1)*4)) to iWidth If (iMaxLength<120) Move 120 to iMaxLength If (iWidth>=iMaxLength+80) Move (iWidth+20) to iMaxLength Move (((iMaxLength+80)-iWidth)/2) to xPos Move xPos to iFirstxPos // For i from 0 to (SizeOfArray(Msg.Button)-1) If (Msg.Button[i].bDefault) Begin Move i to iFirstButton Move xPos to iFirstxPos End Add (piButtonWidth(Self)+4) to xPos End // check for minimum dialog height If (yPos<50) Move 50 to yPos // create the buttons: default button first, then the rest in order Move iFirstButton to i Move iFirstxPos to xPos Repeat #IF (!@>=170) Get Create (RefClass(cmbButton)) to hoObj #ELSE Get Create U_cmbButton to hoObj #ENDIF Set Label of hoObj to Msg.Button[i].sLabel Set Location of hoObj to yPos xPos Set piButtonType of hoObj to Msg.Button[i].iType If (iFirstButtonIndex=0) Move (SizeOfArray(hoObject)) to iFirstButtonIndex Move hoObj to hoObject[SizeOfArray(hoObject)] Move hoObj to Msg.Button[i].hoObject If (hoFirstButton=0) Move hoObj to hoFirstButton If (Pos("&",label(hoObj))>0) Send SetupAccelerator hoObj If (xMaxPosSizeOfArray(Msg.Button)-1) Begin Move 0 to i Move (((iMaxLength+80)-iWidth)/2) to xPos End Else Add (piButtonWidth(Self)+4) to xPos Add (piButtonWidth(Self)+4) to iButtonSpan Until (i=iFirstButton) If (Msg.iTimeout<>0) Begin Get Create (RefClass(dfTimer)) to hoObj Set Timeout of hoObj to Msg.itimeout Set timer_object of hoObj to hoFirstButton Set Timer_Active_State of hoObj to True Set Timer_Message of hoObj to msg_keyaction Move hoObj to hoObject[SizeOfArray(hoObject)] End // if a help id was included, create the help button If (msg.iHelp<>0 or Msg.sHtmlHelpTopic<>'') Begin Object oButton is a cmbButton Set piButtonType to -1 Set Location to yPos (xMaxPos+piButtonWidth(Self)+4) Set Help_Id to Msg.iHelp Set psHtmlHelpTopic to Msg.sHtmlHelpTopic Move Self to hoObj Move hoObj to hoObject[SizeOfArray(hoObject)] End_Object If (Pos("&",label(hoObj))>0) Send SetupAccelerator hoObj End For i from 0 to (SizeOfArray(Checkboxes)-1) Object oCheckbox is a Checkbox Set Auto_Size_State to True // Set FontSize to 14 0 Set Label to Checkboxes[i].sLabel Set Location to Checkboxes[i].iY 40 Move Self to hoObj Move Self to Msg.Message[checkboxes[i].iMsgIndex]._hoCheckbox Set Checked_State to Msg.Message[checkboxes[i].iMsgIndex].bChecked Get Size to iSize Move (Low(iSize)+If(Msg.Message[i].sBitmap<>'',14,0)) to iLineWidth If (iLineWidth>iMaxLength) begin Move iLineWidth to iMaxLength Move True to bButtonRepos End On_Key Key_Right_Arrow Send previous On_Key Key_Left_Arrow Send next End_Object Send Add_Focus to hoObj Self Move hoObj to hoObject[SizeOfArray(hoObject)] Loop // if iMaxLength has changed, reposition buttons If (bButtonRepos) Begin Move (((iMaxLength+80)-iButtonSpan)/2) to xPos For i from 0 to (SizeOfArray(Msg.Button)-1) If (Msg.Button[i].bDefault) Begin Move i to iFirstButton Move xPos to iFirstxPos End Add (piButtonWidth(Self)+4) to xPos End Move iFirstButton to i Move iFirstxPos to xPos Repeat Get Location of Msg.Button[i].hoObject to iLoc Get size of Msg.button[i].hoObject to iSize Set Location of Msg.Button[i].hoObject to (Hi(iLoc)) xPos Add 1 to i If (i>SizeOfArray(Msg.Button)-1) Begin Move 0 to i Move (((iMaxLength+80)-iButtonSpan)/2) to xPos End Else Add (piButtonWidth(Self)+4) to xPos Until (i=iFirstButton) End Set size to (yPos+piButtonHeight(Self)+4) (If(Msg.iWidth<>0,Msg.iWidth,iMaxLength+80)) // On_Key key_ctrl+Key_C Send CopyMessageText Function_Return hoObject // return an array of object IDs End_Function Procedure CopyMessageText Direct_Output "clipboard:" Writeln (psMessageText(Self)) Close_Output End_Procedure Procedure OnClick Integer iButton Set piButtonPressed to iButton Send stop_modal_ui End_Procedure Procedure SetupAccelerator Handle hoObj String sLabel Get label of hoObj to sLabel Move (Uppercase(Mid(sLabel,1,Pos("&",sLabel)+1))) to sLabel If (sLabel="A") On_Key Key_A Send KeyAction to hoObj Else If (sLabel="B") On_Key Key_B Send KeyAction to hoObj Else If (sLabel="C") On_Key Key_C Send KeyAction to hoObj Else If (sLabel="D") On_Key Key_D Send KeyAction to hoObj Else if (sLabel="E") On_Key Key_E Send KeyAction to hoObj Else if (sLabel="F") On_Key Key_F Send KeyAction to hoObj Else if (sLabel="G") On_Key Key_G Send KeyAction to hoObj Else if (sLabel="H") On_Key Key_H Send KeyAction to hoObj Else if (sLabel="I") On_Key Key_I Send KeyAction to hoObj Else if (sLabel="J") On_Key Key_J Send KeyAction to hoObj Else if (sLabel="K") On_Key Key_K Send KeyAction to hoObj Else if (sLabel="L") On_Key Key_L Send KeyAction to hoObj Else if (sLabel="M") On_Key Key_M Send KeyAction to hoObj Else if (sLabel="N") On_Key Key_N Send KeyAction to hoObj Else if (sLabel="O") On_Key Key_O Send KeyAction to hoObj Else if (sLabel="P") On_Key Key_P Send KeyAction to hoObj Else if (sLabel="Q") On_Key Key_Q Send KeyAction to hoObj Else if (sLabel="R") On_Key Key_R Send KeyAction to hoObj Else if (sLabel="S") On_Key Key_S Send KeyAction to hoObj Else if (sLabel="T") On_Key Key_T Send KeyAction to hoObj Else if (sLabel="U") On_Key Key_U Send KeyAction to hoObj Else if (sLabel="V") On_Key Key_V Send KeyAction to hoObj Else if (sLabel="W") On_Key Key_W Send KeyAction to hoObj Else if (sLabel="X") On_Key Key_X Send KeyAction to hoObj Else if (sLabel="Y") On_Key Key_Y Send KeyAction to hoObj Else if (sLabel="Z") On_Key Key_Z Send KeyAction to hoObj Else if (sLabel="Z") On_Key Key_Z Send KeyAction to hoObj Else if (sLabel="0") On_Key Key_0 Send KeyAction to hoObj Else if (sLabel="1") On_Key Key_1 Send KeyAction to hoObj Else if (sLabel="2") On_Key Key_2 Send KeyAction to hoObj Else if (sLabel="3") On_Key Key_3 Send KeyAction to hoObj Else if (sLabel="4") On_Key Key_4 Send KeyAction to hoObj Else if (sLabel="5") On_Key Key_5 Send KeyAction to hoObj Else if (sLabel="6") On_Key Key_6 Send KeyAction to hoObj Else if (sLabel="7") On_Key Key_7 Send KeyAction to hoObj Else if (sLabel="8") On_Key Key_8 Send KeyAction to hoObj Else If (sLabel="9") On_Key Key_9 Send KeyAction to hoObj End_Procedure // helper functions that return a tmbButton struct for predefined buttons Function mbOkButton Returns tmbButtons tmbButtons RetVal Move MBR_Ok to RetVal.iType Function_Return RetVal End_Function Function mbCancelButton Returns tmbButtons tmbButtons RetVal Move MBR_Cancel to RetVal.iType Function_Return RetVal End_Function Function mbYesButton Returns tmbButtons tmbButtons RetVal Move MBR_Yes to RetVal.iType Function_Return RetVal End_Function Function mbNoButton Returns tmbButtons tmbButtons RetVal Move MBR_No to RetVal.iType Function_Return RetVal End_Function Function mbAbortButton Returns tmbButtons tmbButtons RetVal Move MBR_Abort to RetVal.iType Function_Return RetVal End_Function Function mbRetryButton Returns tmbButtons tmbButtons RetVal Move MBR_Retry to RetVal.iType Function_Return RetVal End_Function Function mbIgnoreButton Returns tmbButtons tmbButtons RetVal Move MBR_Ignore to RetVal.iType Function_Return RetVal End_Function Function mbButtons Integer iButton1 Integer iButton2 Integer iButton3 Integer iButton4 Returns tmbButtons[] tmbButtons[] RetVal Move iButton1 to RetVal[0].iType If (num_arguments>1) Move iButton2 to RetVal[1].iType If (num_arguments>2) Move iButton3 to RetVal[2].iType If (num_arguments>3) Move iButton4 to RetVal[3].iType Function_Return RetVal End_Function Function mbMessageBox String sMessage String sTitle Integer iBitmap String sBitmap Integer iFontPointHeight Boolean bBold Boolean bItalic Boolean bUnderline Returns tmbMessageBox tmbMessageBox mb Move sMessage to mb.Message[0].sMessage Move sTitle to mb.sTitle If (num_arguments>2) Move iBitmap to mb.iBitmap If (Num_arguments>3) Move sBitmap to mb.sBitmap If (num_arguments>4) Move iFontPointHeight to mb.Message[0].iFontPointHeight If (num_arguments>5) Move bBold to mb.Message[0].bBold If (num_arguments>6) Move bItalic to mb.Message[0].bItalic If (num_arguments>7) Move bUnderline to mb.Message[0].bUnderline Function_Return mb End_Function Function mbMessage String sMessage Boolean bCheckbox Boolean bChecked String sBitmap Integer iFontPointHeight Boolean bBold Boolean bItalic Boolean bUnderline Integer iSpaceAfter Returns tmbMessageText tmbMessageText msg Move sMessage to msg.sMessage Move 4 to msg.iSpaceAfter If (num_arguments>1) Move bCheckbox to msg.bCheckbox If (num_arguments>2) Move bChecked to msg.bChecked If (num_arguments>3) Move sBitmap to msg.sBitmap If (num_arguments>4) Move iFontPointHeight to msg.iFontPointHeight If (num_arguments>5) Move bBold to msg.bBold If (num_arguments>6) Move bItalic to msg.bItalic If (num_arguments>7) Move bUnderline to msg.bUnderline If (num_arguments>8) Move iSpaceAfter to msg.iSpaceAfter Function_Return msg End_Function End_Class Class cMessageBoxPanel is a ModalPanel Procedure construct_object Forward Send Construct_Object Send Define_cMessageBox_mixin End_Procedure Import_Class_Protocol cMessageBox_mixin End_Class // following three classes are experimental // here be dragons Class cMessageBoxTitle is a Container3d Procedure Construct_object Forward Send Construct_Object Set Border_Style to Border_None Set Location to 0 0 Object oTitle is a TextBox Set peAnchors to anTopLeftRight Set Location to 0 0 Set Color to clLtGray End_Object End_Procedure Procedure Set label String Val Integer iSize Set Label of oTitle to Val Delegate Get Size to iSize Set Size to 10 (Low(iSize)) Set Size of oTitle to 10 (Low(iSize)) End_Procedure End_Class Class cMessageBoxContainer is a Container3d Procedure Construct_object Forward Send Construct_Object Set Border_Style to border_none Send Define_cMessageBox_mixin Set Location to 11 0 Set Visible_State to True Set Shadow_State to False Property Handle[] phoObjects End_Procedure Import_Class_Protocol cMessageBox_mixin Procedure RefreshPreview tmbMessageBox ByRef Msg Handle[] hoObject Integer i Get phoObjects to hoObject For i from 0 to (Sizeofarray(hoObject)-1) Send Destroy to hoObject[i] Loop Get ConstructMessageBox (&Msg) to hoObject Set phoObjects to hoObject End_Procedure Procedure Set label String Val Delegate Set Label to Val End_Procedure Procedure Set Size Integer iHeight Integer iWidth Forward Set Size to iHeight iWidth Delegate Set Size to (iHeight+10) iWidth Set Location to 11 0 Send Adjust_Logicals Delegate Send Adjust_Logicals End_Procedure End_Class Class cMessageBoxPreview is a Container3d Procedure construct_object Forward Send Construct_Object Object oTitle is a cMessageBoxTitle End_Object Object oPreviewer is a cMessageBoxContainer End_Object Send Add_Focus to oPreviewer Self End_Procedure Procedure Set label String Val Set Label of oTitle to Val End_Procedure Procedure createButton Send CreateButton to oPreviewer End_Procedure Procedure RefreshPreview tmbMessageBox ByRef Msg Send RefreshPreview to oPreviewer (&Msg) Broadcast Set Visible_State to True End_Procedure End_Class // create the main object that is used to display message boxes Global_Variable Handle ghoMessageBox Object oMessageBox is a cMessageBoxPanel Move Self to ghoMessageBox End_Object // a standard message to access the enhanced message box functionality // by passing a struct Procedure ShowMessageBox tmbMessageBox ByRef Msg Send ShowMessageBox to ghoMessageBox (&Msg) End_Procedure // substitutes for the standard message box procedures/functions // plus some extras (WarningBox, WarningCancelBox, AbortRetryIgnoreBox) Procedure StopBox String sText String sLabel Integer iHelp tmbMessageBox mb If (num_arguments=1) Get StopBox sText to mb If (num_arguments=2) Get StopBox sText sLabel to mb If (num_arguments=3) Get StopBox sText sLabel iHelp to mb Send ShowMessageBox (&mb) End_Procedure Function StopBox String sText String sLabel Integer iHelp String sHtmlHelpTopic Returns tmbMessageBox tmbMessageBox mb Move sText to mb.Message[0].sMessage Move "stop256.bmp/3d" to mb.sBitmap If (num_arguments>=2) Move sLabel to mb.sTitle Else Move C_$MessageBoxStop to mb.sTitle If (num_arguments>=3) Move iHelp to mb.iHelp If (num_arguments>=4) Move sHtmlHelpTopic to mb.sHtmlHelpTopic Get mbOkButton of (oMessageBox(Self)) to mb.Button[0] Function_Return mb End_Function Procedure WarningBox String sText String sLabel Integer iHelp tmbMessageBox mb Move sText to mb.Message[0].sMessage Move "warning256.bmp/3d" to mb.sBitmap If (num_arguments>=2) Move sLabel to mb.sTitle Else Move C_$MessageBoxWarning to mb.sTitle If (num_arguments>=3) Move iHelp to mb.iHelp Get mbOkButton of (oMessageBox(Self)) to mb.Button[0] Send ShowMessageBox to (oMessageBox(Self)) (&mb) End_Procedure Procedure InfoBox String sText String sLabel Integer iHelp tmbMessageBox mb Move sText to mb.Message[0].sMessage Move "info256.bmp/3d" to mb.sBitmap If (num_arguments>=2) Move sLabel to mb.sTitle Else Move C_$MessageBoxInfo to mb.sTitle If (num_arguments>=3) Move iHelp to mb.iHelp Get mbOkButton of (oMessageBox(Self)) to mb.Button[0] Send ShowMessageBox to (oMessageBox(Self)) (&mb) End_Procedure Function WarningCancelBox String sText String sLabel Integer iHelp Returns Integer tmbMessageBox mb Move sText to mb.Message[0].sMessage Move "warning256.bmp/3d" to mb.sBitmap If (num_arguments>=2) Move sLabel to mb.sTitle Else Move C_$MessageBoxWarning to mb.sTitle If (num_arguments>=3) Move iHelp to mb.iHelp Get mbOkButton of (oMessageBox(Self)) to mb.Button[0] Get mbCancelButton of (oMessageBox(Self)) to mb.Button[1] Send ShowMessageBox to (oMessageBox(Self)) (&mb) Function_Return mb.iRetVal End_Function Function YesNoBox String sText String sLabel Integer iDefButton Integer iHelp String sCheckbox Boolean bChecked Returns Integer tmbMessageBox mb Move sText to mb.Message[0].sMessage Get mbYesButton of (oMessageBox(Self)) to mb.Button[0] Get mbNoButton of (oMessageBox(Self)) to mb.Button[1] If (num_arguments>=2) Move sLabel to mb.sTitle Else Move C_$MessageBoxQuestion to mb.sTitle If (num_arguments>=3) Begin If ((iDefButton iand MB_ICONMASK)<>0) Get IconBitmap of (oMessageBox(Self)) (iDefButton iand MB_ICONMASK) to mb.sBitmap Else Move "question256.bmp/3d" to mb.sBitmap Move (iDefButton iand MB_DEFBUTTONMASK) to iDefButton Move (iDefButton=MB_DEFBUTTON1) to mb.Button[0].bDefault Move (iDefButton=MB_DEFBUTTON2) to mb.Button[1].bDefault End If (num_arguments>=4) Move iHelp to mb.iHelp If (num_arguments>=5) Begin Move sCheckbox to mb.Message[1].sMessage Move True to mb.Message[1].bCheckbox If (num_arguments>=6) Move bChecked to mb.Message[1].bChecked End Send ShowMessageBox to (oMessageBox(Self)) (&mb) If (num_arguments>=5 and mb.Message[1].bChecked) Move (MBR_CHECKED ior mb.iRetVal) to mb.iRetVal Function_Return mb.iRetVal End_Function Function mbYesNoCancelBox String sText String sLabel Integer iDefButton Integer iHelp String sCheckbox Boolean bChecked Returns tmbMessageBox tmbMessageBox mb Move sText to mb.Message[0].sMessage Get mbYesButton of (oMessageBox(Self)) to mb.Button[0] Get mbNoButton of (oMessageBox(Self)) to mb.Button[1] Get mbCancelButton of (oMessageBox(Self)) to mb.Button[2] If (num_arguments>=2) Move sLabel to mb.sTitle Else Move C_$MessageBoxQuestion to mb.sTitle If (num_arguments>=3) Begin If ((iDefButton iand MB_ICONMASK)<>0) Get IconBitmap of (oMessageBox(Self)) (iDefButton iand MB_ICONMASK) to mb.sBitmap Else Move "question256.bmp/3d" to mb.sBitmap Move (iDefButton iand MB_DEFBUTTONMASK) to iDefButton Move (iDefButton=MB_DEFBUTTON1) to mb.Button[0].bDefault Move (iDefButton=MB_DEFBUTTON2) to mb.Button[1].bDefault Move (iDefButton=MB_DEFBUTTON3) to mb.Button[2].bDefault End If (num_arguments>=4) Move iHelp to mb.iHelp If (num_arguments>=5) Begin Move sCheckbox to mb.Message[1].sMessage Move True to mb.Message[1].bCheckbox If (num_arguments>=6) Move bChecked to mb.Message[1].bChecked End Function_Return mb End_Function Function YesNoCancelBox String sText String sLabel Integer iDefButton Integer iHelp String sCheckbox Boolean bChecked Returns Integer tmbMessageBox mb If (num_arguments=2) Get mbYesNoCancelBox sText sLabel to mb If (num_arguments=3) Get mbYesNoCancelBox sText sLabel iDefButton to mb If (num_arguments=4) Get mbYesNoCancelBox sText sLabel iDefButton iHelp to mb If (num_arguments=5) Get mbYesNoCancelBox sText sLabel iDefButton iHelp sCheckbox False to mb If (num_arguments=6) Get mbYesNoCancelBox sText sLabel iDefButton iHelp sCheckbox bChecked to mb Send ShowMessageBox to (oMessageBox(Self)) (&mb) If (num_arguments>=5 and mb.Message[1].bChecked) Move (MBR_CHECKED ior mb.iRetVal) to mb.iRetVal Function_Return mb.iRetVal End_Function Function AbortRetryIgnoreBox String sText String sLabel Integer iDefButton Integer iHelp String sCheckbox Boolean bChecked Returns Integer tmbMessageBox mb Move sText to mb.Message[0].sMessage Get mbAbortButton of (oMessageBox(Self)) to mb.Button[0] Get mbRetryButton of (oMessageBox(Self)) to mb.Button[1] Get mbIgnoreButton of (oMessageBox(Self)) to mb.Button[2] If (num_arguments>=2) Move sLabel to mb.sTitle Else Move C_$MessageBoxProblem to mb.sTitle If (num_arguments>=3) Begin If ((iDefButton iand MB_ICONMASK)<>0) Get IconBitmap of (oMessageBox(Self)) (iDefButton iand MB_ICONMASK) to mb.sBitmap Else Move "warning256.bmp/3d" to mb.sBitmap Move (iDefButton iand MB_DEFBUTTONMASK) to iDefButton Move (iDefButton=MB_DEFBUTTON1) to mb.Button[0].bDefault Move (iDefButton=MB_DEFBUTTON2) to mb.Button[1].bDefault Move (iDefButton=MB_DEFBUTTON3) to mb.Button[2].bDefault End If (num_arguments>=4) Move iHelp to mb.iHelp If (num_arguments>=5) Begin Move sCheckbox to mb.Message[1].sMessage Move True to mb.Message[1].bCheckbox If (num_arguments>=6) Move bChecked to mb.Message[1].bChecked End Send ShowMessageBox to (oMessageBox(Self)) (&mb) If (num_arguments>=5 and mb.Message[1].bChecked) Move (MBR_CHECKED ior mb.iRetVal) to mb.iRetVal Function_Return mb.iRetVal End_Function