WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Auto Resize Dialog Based on Size of Text


#DefineFunction MsgBox(Title,Text)
   NumLines = ItemCount(Text,"|")
   TextWidth = 1
   For i = 1 To NumLines
      Line = ItemExtract(i,Text,"|")
      Len = StrCharCount(Line)
      If Len>TextWidth Then TextWidth = Len
   Next
   Text = StrReplace(Text,"|",@CRLF)
   FontWidth = 3.5
   TextWidth = Int(TextWidth * FontWidth)
   DialogWidth = TextWidth + 17
   OKXPos = DialogWidth / 2 - 18
   FontHeight = 9
   TextHeight = NumLines * FontHeight
   DialogHeight = TextHeight + 24
   OKYPos = DialogHeight - 18
   MyDialogFormat = `WWWDLGED,6.1`
   MyDialogCaption = Title
   MyDialogX = -1
   MyDialogY = -1
   MyDialogWidth = DialogWidth
   MyDialogHeight = DialogHeight
   MyDialogNumControls = 002
   MyDialogProcedure = `DEFAULT`
   MyDialogFont = `DEFAULT`
   MyDialogTextColor = `DEFAULT`
   MyDialogBackground = `DEFAULT,DEFAULT`
   MyDialogConfig = 0
   MyDialog001 = `%OKXPos%,%OKYPos%,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
   MyDialog002 = `007,005,%TextWidth%,%TextHeight%,VARYTEXT,Text,"",DEFAULT,2,DEFAULT,"Monaco|5632|40|49","0|0|0",DEFAULT`
   ButtonPushed = Dialog("MyDialog")
   Return
#EndFunction

;Set up some data
Contacts = ArrDimension(3,3)
Contacts[0,0] = "John Doe"
Contacts[0,1] = "555-555-0001"
Contacts[0,2] = "john@doe.net"
Contacts[1,0] = "Jane Doe"
Contacts[1,1] = "555-555-0002"
Contacts[1,2] = "jane@doe.net"
Contacts[2,0] = "Jack Doe"
Contacts[2,1] = "555-555-0003"
Contacts[2,2] = "jack@doe.net"
NumLines = ArrInfo(Contacts,1)
MsgText = ""
For i = 0 To NumLines - 1
   MsgText = StrCat(MsgText,StrFix(Contacts[i,0]," ",24),StrFix(Contacts[i,1]," ",15),Contacts[i,2])
   If i<NumLines-1 Then MsgText = StrCat(MsgText,"|") ; MsgBox uses "|" to separate lines
Next

;Test dialog
MsgBox("Contacts",MsgText)

;Set up some data
Contacts = ArrDimension(1,3)
Contacts[0,0] = "John Doe"
Contacts[0,1] = "555-555-0001"
Contacts[0,2] = "john@doe.net"

NumLines = ArrInfo(Contacts,1)
MsgText = ""
For i = 0 To NumLines - 1
   MsgText = StrCat(MsgText,StrFix(Contacts[i,0]," ",24),StrFix(Contacts[i,1]," ",15),Contacts[i,2])
   If i<NumLines-1 Then MsgText = StrCat(MsgText,"|") ; MsgBox uses "|" to separate lines
Next

;Test dialog
MsgBox("Contacts",MsgText)

Article ID:   W16939
File Created: 2007:07:03:14:27:06
Last Updated: 2007:07:03:14:27:06