Re: Ui_msg_box() Codes
This thread has inspired me to make my own custom message box xdialog tool.
I like the ui_msg_box() function, but I�m always wanting to tweak it and I can�t. I would like to change the font or the back ground color and I don�t think I can do that. So I find myself constantly designing different ui_dlg_box()s.
So for the simple run of the mill quickey ui_dlg_box, I have now created a crude tool to get me started with the typical ui_dlg_box that I usually start with. There are a number of areas that I plan on adding enhancements, but for now I thought I would give it to the board for feedback.
It could use some lookups for the color, style and font. My code isn't the prettiest, but it does appear to work.
The button width does automatically adjusts for longer text.
Pressing �OK� will copy the code to the clipboard. I haven�t figures out how to have it paste into a script. The other feature I would like to incorporate would be the appropriate ui_beep sound with each image.
Again, this is my macro for making a simple xdialog for a message or to control the flow of a script. Many on this board have been very generous with their time and have helped me so much that I hope someone can get some use out of this.
Ron
This thread has inspired me to make my own custom message box xdialog tool.
I like the ui_msg_box() function, but I�m always wanting to tweak it and I can�t. I would like to change the font or the back ground color and I don�t think I can do that. So I find myself constantly designing different ui_dlg_box()s.
So for the simple run of the mill quickey ui_dlg_box, I have now created a crude tool to get me started with the typical ui_dlg_box that I usually start with. There are a number of areas that I plan on adding enhancements, but for now I thought I would give it to the board for feedback.
It could use some lookups for the color, style and font. My code isn't the prettiest, but it does appear to work.
The button width does automatically adjusts for longer text.
Pressing �OK� will copy the code to the clipboard. I haven�t figures out how to have it paste into a script. The other feature I would like to incorporate would be the appropriate ui_beep sound with each image.
Again, this is my macro for making a simple xdialog for a message or to control the flow of a script. Many on this board have been very generous with their time and have helped me so much that I hope someone can get some use out of this.
Ron
Code:
'Date Created: 02-Oct-2011 11:35:46 AM 'Last Updated: 02-Oct-2011 11:35:46 AM 'Created By : Ron 'Updated By : Ron 'Create an XDialog dialog box to prompt for parameters. DIM SHARED vTitle as C DIM SHARED vUnit as C DIM SHARED vSize as C DIM SHARED vMargin as C DIM SHARED vFont as C DIM SHARED vMsg as C DIM SHARED vBut1 as C DIM SHARED vBut2 as C DIM SHARED vBut3 as C DIM SHARED vButDefault as C DIM SHARED vButWth as C DIM SHARED vHeight as C DIM SHARED vButJusify as C DIM SHARED vSymbol as C DIM SHARED vAccent as C DIM SHARED vColor as C DIM SHARED vWinStyle as C DIM SHARED vXdialog as C DIM SHARED varC_result as C vTitle = "Title" vUnit = "F" vSize = ".3" vMargin = "4,4" vFont = "Arial,10" vMsg = "Message Text" vBut1 = "OK" vBut2 = "Cancel" vButDefault = "First" vButWth = "12" vHeight = "1.5" vButJusify = "Left" vSymbol = "None" vAccent = "Off White" vColor = "Blue White" vWinStyle = "Gradient Horizontal" ok_button_label = "&OK" cancel_button_label = "&Cancel" varC_result = ui_dlg_box("Build a Custom Message Box",<<%dlg% {xmargin=4,4}{ysize=.3}{font=arial,10,b};; {region} Title:| {font=arial,10} [.60vTitle];;; {font=arial,10,b} Units:| {font=arial,10} [.5vUnit] {font=arial,10,b} Ysize: {font=arial,10} [.6vSize] {font=arial,10,b} Xmargin: {font=arial,10} [.10vMargin];;; {font=arial,10,b} Font:| {font=arial,10} [.40vFont];;; {endregion}; {region}{font=arial,10,b} Color:| {font=arial,10} [.50vColor]; {font=arial,10,b} Accent Color:| {font=arial,10} [.50vAccent]; {font=arial,10,b} Windows Style:| {font=arial,10} [.50vWinStyle];;; {endregion}; {font=arial,10,b} Message: {font=arial,10} [%mw%.80,3vMsg];;; {font=arial,10,b} Button 1: {font=arial,10} [.40vBut1!x]; {font=arial,10,b} Button 2: {font=arial,10} [.40vBut2!x]; {font=arial,10,b} Button 3: {font=arial,10} [.40vBut3!x];;; {font=arial,10,b} {region}Default Button:{font=arial,10}{endregion} {region} (vButDefault:First) (vButDefault:Second) (vButDefault:Third){endregion}; ; {region} {font=arial,10,b} Button Width:{font=arial,10} | [.6vButWth]; {font=arial,10,b} Button Height:{font=arial,10} | [.6vHeight] {endregion};;; {region}{font=arial,10,b}Button Alignment:{font=arial,10}{endregion} {region} (vButJusify:Left) (vButJusify:Center) (vButJusify:Right){endregion};;; {region}{font=arial,10,b}Image:{font=arial,10}{endregion} {region} (vSymbol:None) (vSymbol:Error) (vSymbol:Information) (vSymbol:Question) (vSymbol:Warning){endregion}; ; {endregion};; {region} <*12,1.5=ok_button_label!OK> <12,1.5=cancel_button_label!CANCEL> {endregion}; %dlg%,<<%code% IF a_dlg_button = "x" THEN a_dlg_button = "" 'get max button length button_temp = vBut1+","+vBut2+","+vBut3 btn_length = max_str_length(button_temp, ",") IF btn_length > 12 vButWth = btn_length +4 ELSE vButWth = 12 END IF END IF %code%) IF varC_result = "OK" THEN goto keepgoing ELSE END END IF keepgoing: IF vSymbol <> "none" THEN vSymbol = "{image=$sys_"+vSymbol+"}" END IF dim shared vrows as C IF vSymbol="none" THEN vrows="2" ELSE vrows="3" END IF dim Shared vtextlength as C vTextLength = alltrim(str((len(vMsg)+10))) IF val(vtextlength) < 25 THEN vtextlength = "25" ELSE IF val(vtextlength) > 75 vtextlength = "80" vrows = "3" END IF vXdialog = "DIM SHARED vDlg_Title as C"+crlf()+\ "DIM SHARED vMsg as C"+crlf()+\ "vMsg="+s_quote(vmsg)+crlf()+\ "DIM SHARED varC_result as C"+crlf()+\ "DIM XDialogStyle as P"+crlf()+\ "XDialogStyle.AccentColor = "+s_quote(vAccent)+crlf()+\ "XDialogStyle.Color = "+s_quote(vColor) +crlf()+\ "vDlg_Title="+s_quote(vTitle)+crlf()+\ "dlg_text = <<%dlg%"+crlf()+\ "{Windowstyle="+vWinStyle+"}"+crlf()+\ "{ysize="+vSize+"}"+"{units="+vUnit+"}"+"{xmargin="+vMargin+"}"+"{font="+vFont+"};"+crlf()+\ if(vSymbol="none","",vSymbol+"{sp}{sp}{sp}")+crlf()+\ "{text=%H=R%"+vtextlength+","+vrows+"vMsg};"+crlf()+\ "{justify=center,"+vButJusify+"}"+crlf()+\ "<"+if(vButDefault="First","*","")+vButWth+","+vHeight+vBut1+"> " +crlf()+\ if(vBut2="",""," <"+if(vButDefault="Second","*","")+vButWth+","+vHeight+vBut2+"> " +crlf())+\ if(vBut3="",""," <"+if(vButDefault="Third","*","")+vButWth+","+vHeight+vBut3+"> " +crlf())+\ "%dlg%"+crlf()+\ "varC_result=ui_dlg_box(vdlg_title, dlg_text, <<%code%"+crlf()+\ "%"+"code%)"+crlf(2)+\ "IF varC_result = "+quote(vBut1)+" THEN"+crlf()+\ " goto keepgoing"+crlf()+\ "ELSE"+crlf()+\ " END"+crlf()+\ "END IF"+crlf(2)+\ "keepgoing:" ui_msg_box("",vXdialog) clipboard.Clear_Data() clipboard.Set_Data(vXdialog)
Comment