home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / message / msgbox2 / msgedit.frm (.txt) < prev   
Encoding:
Visual Basic Form  |  1995-01-18  |  9.6 KB  |  288 lines

  1. VERSION 2.00
  2. Begin Form MsgEdit 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "MsgBox Editor"
  6.    ClientHeight    =   4152
  7.    ClientLeft      =   1608
  8.    ClientTop       =   1992
  9.    ClientWidth     =   5544
  10.    ForeColor       =   &H00000000&
  11.    Height          =   4800
  12.    Left            =   1560
  13.    LinkMode        =   1  'Source
  14.    LinkTopic       =   "Form2"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   4152
  18.    ScaleWidth      =   5544
  19.    Top             =   1392
  20.    Width           =   5640
  21.    Begin CommandButton Finished 
  22.       Caption         =   "&Finished!"
  23.       FontBold        =   -1  'True
  24.       FontItalic      =   0   'False
  25.       FontName        =   "MS Sans Serif"
  26.       FontSize        =   12
  27.       FontStrikethru  =   0   'False
  28.       FontUnderline   =   0   'False
  29.       Height          =   495
  30.       Left            =   1920
  31.       TabIndex        =   8
  32.       Top             =   3480
  33.       Width           =   1815
  34.    End
  35.    Begin CommandButton MessageClear 
  36.       Caption         =   "C&lear"
  37.       Height          =   495
  38.       Left            =   4680
  39.       TabIndex        =   6
  40.       TabStop         =   0   'False
  41.       Top             =   2040
  42.       Width           =   615
  43.    End
  44.    Begin TextBox MessageEdit 
  45.       Height          =   855
  46.       Left            =   240
  47.       MultiLine       =   -1  'True
  48.       TabIndex        =   5
  49.       Top             =   2040
  50.       Width           =   4215
  51.    End
  52.    Begin CommandButton TitleClear 
  53.       Caption         =   "&Clear"
  54.       Height          =   495
  55.       Left            =   4680
  56.       TabIndex        =   2
  57.       TabStop         =   0   'False
  58.       Top             =   600
  59.       Width           =   615
  60.    End
  61.    Begin TextBox TitleEdit 
  62.       Height          =   375
  63.       Left            =   240
  64.       TabIndex        =   1
  65.       Top             =   600
  66.       Width           =   4215
  67.    End
  68.    Begin Label Label3 
  69.       BackStyle       =   0  'Transparent
  70.       Caption         =   "Use Return to start new line, and Control-Return (or click on OK) to accept text."
  71.       FontBold        =   0   'False
  72.       FontItalic      =   0   'False
  73.       FontName        =   "MS Sans Serif"
  74.       FontSize        =   7.8
  75.       FontStrikethru  =   0   'False
  76.       FontUnderline   =   0   'False
  77.       Height          =   375
  78.       Index           =   1
  79.       Left            =   240
  80.       TabIndex        =   7
  81.       Top             =   3000
  82.       Width           =   4215
  83.    End
  84.    Begin Label Label1 
  85.       BackStyle       =   0  'Transparent
  86.       Caption         =   "Enter MsgBox &Message Here:"
  87.       FontBold        =   -1  'True
  88.       FontItalic      =   0   'False
  89.       FontName        =   "MS Sans Serif"
  90.       FontSize        =   12
  91.       FontStrikethru  =   0   'False
  92.       FontUnderline   =   0   'False
  93.       Height          =   375
  94.       Left            =   360
  95.       TabIndex        =   4
  96.       Top             =   1560
  97.       Width           =   3855
  98.    End
  99.    Begin Label Label3 
  100.       BackStyle       =   0  'Transparent
  101.       Caption         =   "Use Control-Return (or click on OK) to accept text."
  102.       FontBold        =   0   'False
  103.       FontItalic      =   0   'False
  104.       FontName        =   "MS Sans Serif"
  105.       FontSize        =   7.8
  106.       FontStrikethru  =   0   'False
  107.       FontUnderline   =   0   'False
  108.       Height          =   255
  109.       Index           =   0
  110.       Left            =   240
  111.       TabIndex        =   3
  112.       Top             =   1080
  113.       Width           =   4215
  114.    End
  115.    Begin Label Label2 
  116.       BackStyle       =   0  'Transparent
  117.       Caption         =   "Enter MsgBox &Title Here:"
  118.       FontBold        =   -1  'True
  119.       FontItalic      =   0   'False
  120.       FontName        =   "MS Sans Serif"
  121.       FontSize        =   12
  122.       FontStrikethru  =   0   'False
  123.       FontUnderline   =   0   'False
  124.       ForeColor       =   &H00000000&
  125.       Height          =   375
  126.       Left            =   360
  127.       TabIndex        =   0
  128.       Top             =   120
  129.       Width           =   4095
  130.    End
  131.    Begin Menu Hints 
  132.       Caption         =   "&Hints"
  133.       Begin Menu TitleMsg 
  134.          Caption         =   "&Title..."
  135.       End
  136.       Begin Menu MsgMsg 
  137.          Caption         =   "&Message..."
  138.       End
  139.       Begin Menu EditMsg 
  140.          Caption         =   "&Editing..."
  141.       End
  142.       Begin Menu sep 
  143.          Caption         =   "-"
  144.       End
  145.       Begin Menu AboutMsg 
  146.          Caption         =   "&About..."
  147.       End
  148.    End
  149. Option Explicit
  150. Sub AboutMsg_Click ()
  151.     MBAbout.Show 1
  152. End Sub
  153. Function CheckString (TheText As String, TheType As Integer) As Integer
  154.     Dim StrMsg$
  155.     Dim LenMsg$
  156.     Dim WordText$
  157.     CheckString = True
  158.     StrMsg$ = "VB will will truncate this long word at the 255th character.  Try again!"
  159.     LenMsg$ = "VB will only allow 1,024 characters in a message box.  Try again!"
  160.     WordText$ = TheText
  161.     While InStr(WordText$, Chr$(32)) > 0
  162.     If InStr(WordText$, Chr$(32)) > 255 Then
  163.         Call Turn3dOnOff
  164.         MsgBox StrMsg$, 16, "String Error"
  165.         Call Turn3dOnOff
  166.         CheckString = False
  167.     End If
  168.     WordText$ = Mid$(WordText$, InStr(WordText$, Chr$(32)) & 1)
  169.     Wend
  170.     If Len(TheText) > 1024 And TheType = MSG Then
  171.     Call Turn3dOnOff
  172.     MsgBox LenMsg$, 16, "String Error"
  173.     Call Turn3dOnOff
  174.     CheckString = False
  175.     End If
  176. End Function
  177. Sub EditMsg_Click ()
  178.     Dim pstrTheMessage As String
  179.     Dim pstrTheTitle As String
  180.     pstrTheMessage = "Instructions for editing are placed below the edit boxes.  You may embed carriage returns"
  181.     pstrTheMessage = gstrTheMessage & " in the Message section by pressing Return.  You can accept the text by pressing Control-Return in either the Title or"
  182.     pstrTheMessage = gstrTheMessage & " the Message Box. You may also use a mouse to click on the Finished button."
  183.     pstrTheTitle = "Editing"
  184.     Call Turn3dOnOff
  185.     MsgBox pstrTheMessage, 0, pstrTheTitle
  186.     Call Turn3dOnOff
  187. End Sub
  188. Sub Finished_Click ()
  189.     Dim pintTheAnswer As Integer
  190.     ' Check the title to see if it is valid
  191.     pintTheAnswer = CheckString((TitleEdit.Text), TTL)
  192.     If pintTheAnswer Then       ' If titel is ok
  193.       gstrTheTitle = TitleEdit.Text
  194.     Else                        ' If not valid
  195.       TitleEdit.SetFocus
  196.       Exit Sub
  197.     End If
  198.     ' Check the Message to see if it is valid
  199.     pintTheAnswer = CheckString((MessageEdit.Text), MSG)
  200.     If pintTheAnswer Then       ' If Message is ok
  201.       gstrRawMessage = MessageEdit.Text
  202.     Else                        ' If not valid
  203.       MessageEdit.SetFocus
  204.       Exit Sub
  205.     End If
  206.     ' Make shure there is a Message
  207.     If Len(gstrRawMessage) > 0 Then
  208.       MsgEdit.Hide
  209.     Else        ' if not
  210.       Call Turn3dOnOff
  211.       pintTheAnswer = MsgBox("What good's a message box without a message?", 37, "String Error")
  212.       Call Turn3dOnOff
  213.       If pintTheAnswer = 4 Then     ' Retry
  214.         MessageEdit.SetFocus
  215.         Exit Sub
  216.       Else                ' Cancel
  217.         MsgEdit.Hide
  218.       End If
  219.     End If
  220. End Sub
  221. Sub Form_Load ()
  222.   Call CenterOnForm(MsgBxGen, MsgEdit)
  223.   TitleEdit.Text = gstrTheTitle
  224.   MessageEdit.Text = gstrRawMessage
  225. End Sub
  226. Sub MessageClear_Click ()
  227.     MessageEdit.Text = ""
  228. End Sub
  229. Sub MessageEdit_KeyUp (KeyCode As Integer, Shift As Integer)
  230.     Dim eCtrlDown%
  231.     Dim CtrlDown%
  232.     Dim StringState
  233.     Dim AnAnswer
  234.     eCtrlDown% = (Shift And CTRL_MASK) > 0
  235.     If KeyCode = KEY_RETURN Then    ' Display key combinations.
  236.       If CtrlDown% Then
  237.         StringState = CheckString((MessageEdit.Text), MSG)
  238.         If StringState <> False Then
  239.           gstrRawMessage = Left$(MessageEdit.Text, Len(MessageEdit.Text) - 2)
  240.         End If
  241.         If Len(gstrRawMessage) > 0 Then
  242.           Finished.SetFocus
  243.         Else
  244.           Call Turn3dOnOff
  245.           AnAnswer = MsgBox("What good's a message box without a message?", 37, "String Error")
  246.           Call Turn3dOnOff
  247.           If AnAnswer = RETRY Then
  248.             Exit Sub
  249.           Else
  250.             End
  251.           End If
  252.         End If
  253.       End If
  254.     End If
  255. End Sub
  256. Sub MsgMsg_Click ()
  257.     Dim pstrTheMessage As String
  258.     Dim pstrTheTitle As String
  259.     pstrTheMessage = "The message box function/procedure will only accept messages 1,024 characters"
  260.     pstrTheMessage = gstrTheMessage & " long.  Longer messages will be truncated at the 1,024th character.  Words (any series of characters without intervening spaces) will be truncated at the 255th character."
  261.     pstrTheTitle = "The Message"
  262.     Call Turn3dOnOff
  263.     MsgBox pstrTheMessage, 0, pstrTheTitle
  264.     Call Turn3dOnOff
  265. End Sub
  266. Sub TitleClear_Click ()
  267.     TitleEdit.Text = ""
  268. End Sub
  269. Sub TitleEdit_KeyUp (KeyCode As Integer, Shift As Integer)
  270.     Dim CtrlDown%
  271.     CtrlDown% = (Shift And CTRL_MASK) > 0
  272.     If KeyCode = KEY_RETURN Then    ' Display key combinations.
  273.       If CtrlDown% Then
  274.         gstrTheTitle = TitleEdit.Text
  275.         MessageEdit.SetFocus
  276.       End If
  277.     End If
  278. End Sub
  279. Sub TitleMsg_Click ()
  280.     Dim pstrTheMessage As String
  281.     Dim pstrTheTitle As String
  282.     pstrTheMessage = "Any word (series of characters with no intervening spaces) is truncated at the 255th character.  Titles longer than the width of the monitor are not very helpful as messages."
  283.     pstrTheTitle = "The Title"
  284.     Call Turn3dOnOff
  285.     MsgBox pstrTheMessage, 0, pstrTheTitle
  286.     Call Turn3dOnOff
  287. End Sub
  288.