home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / code / various / msg / msgwin.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-02-26  |  7.6 KB  |  245 lines

  1. VERSION 2.00
  2. Begin Form MsgWin 
  3.    BackColor       =   &H0080FFFF&
  4.    BorderStyle     =   0  'None
  5.    ClientHeight    =   1125
  6.    ClientLeft      =   2595
  7.    ClientTop       =   2910
  8.    ClientWidth     =   3855
  9.    ClipControls    =   0   'False
  10.    ControlBox      =   0   'False
  11.    ForeColor       =   &H00000000&
  12.    Height          =   1650
  13.    KeyPreview      =   -1  'True
  14.    Left            =   2535
  15.    LinkTopic       =   "Form1"
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   1125
  19.    ScaleWidth      =   3855
  20.    Tag             =   "MsgWin"
  21.    Top             =   2445
  22.    Width           =   3975
  23.    Begin TextBox Answer 
  24.       Height          =   285
  25.       Left            =   360
  26.       TabIndex        =   3
  27.       Text            =   "Text1"
  28.       Top             =   1005
  29.       Visible         =   0   'False
  30.       Width           =   285
  31.    End
  32.    Begin SSPanel Message 
  33.       BackColor       =   &H0080FFFF&
  34.       BevelOuter      =   0  'None
  35.       BevelWidth      =   2
  36.       ForeColor       =   &H00000000&
  37.       Height          =   1050
  38.       Left            =   0
  39.       Outline         =   -1  'True
  40.       TabIndex        =   0
  41.       Top             =   0
  42.       Width           =   3855
  43.       Begin TextBox Text1 
  44.          Height          =   330
  45.          Left            =   1500
  46.          TabIndex        =   5
  47.          Top             =   525
  48.          Visible         =   0   'False
  49.          Width           =   555
  50.       End
  51.       Begin CommandButton Button2 
  52.          Caption         =   "Command1"
  53.          Height          =   480
  54.          Left            =   2055
  55.          TabIndex        =   2
  56.          Top             =   495
  57.          Visible         =   0   'False
  58.          Width           =   1170
  59.       End
  60.       Begin CommandButton Button1 
  61.          BackColor       =   &H00C0C0C0&
  62.          Caption         =   "Command1"
  63.          Height          =   480
  64.          Left            =   540
  65.          TabIndex        =   1
  66.          Top             =   510
  67.          Visible         =   0   'False
  68.          Width           =   960
  69.       End
  70.       Begin Label Label 
  71.          Alignment       =   2  'Center
  72.          AutoSize        =   -1  'True
  73.          BackStyle       =   0  'Transparent
  74.          Caption         =   "Label1"
  75.          Height          =   195
  76.          Left            =   165
  77.          TabIndex        =   4
  78.          Top             =   120
  79.          Visible         =   0   'False
  80.          Width           =   3630
  81.          WordWrap        =   -1  'True
  82.       End
  83.    End
  84.    Begin Timer Timer1 
  85.       Enabled         =   0   'False
  86.       Interval        =   1500
  87.       Left            =   2655
  88.       Top             =   630
  89.    End
  90. Option Explicit
  91. Sub Button1_Click ()
  92.     Answer.Text = "1"
  93.     MsgWin.Hide
  94. End Sub
  95. Sub Button1_GotFocus ()
  96.     Dim x As Integer, y As Long, Text As String
  97.     Dim Text1 As String
  98.     Dim yplus As Integer
  99.     If Button2.Visible = False Then
  100.         yplus = Label.Height
  101.         Message.Alignment = 6
  102.         Label.Caption = Message.Caption
  103.         Message.Caption = ""
  104.         Label.Visible = True
  105.         Message.Height = Label.Height + (yplus * 3) + Button1.Height
  106.         Button1.Top = Label.Height + yplus
  107.         Button2.Top = Button1.Top
  108.         MsgWin.Height = Message.Height + 2
  109.         y = GetTextExtent(MsgWin.hDC, Button1.Caption, Len(Button1.Caption))
  110.         Text = Hex$(y)
  111.         Text = "&h" + Right$(Text, 4)
  112.         x = Val(Text)
  113.         x = (x * Screen.TwipsPerPixelX) * 1.5
  114.         Button1.Width = x
  115.         y = GetTextExtent(MsgWin.hDC, Button2.Caption, Len(Button2.Caption))
  116.         Text = Hex$(y)
  117.         Text = "&h" + Right$(Text, 4)
  118.         x = Val(Text)
  119.         x = (x * Screen.TwipsPerPixelX) * 1.5
  120.         Button2.Width = x
  121.         Button1.Top = Button1.Top + yplus
  122.         Button2.Top = Button2.Top + yplus
  123.         If Button1.Width < Button1.Height Then
  124.             Button1.Width = Button1.Width * 4 / 3
  125.             Button2.Width = Button2.Width * 4 / 3
  126.         End If
  127.         If Button2.Width < Button2.Height Then
  128.             Button2.Width = Button2.Width * 4 / 3
  129.             Button1.Width = Button1.Width * 4 / 3
  130.         End If
  131.         If Button2.Width < Button1.Width Then
  132.             Button2.Width = Button1.Width
  133.         Else
  134.             Button1.Width = Button2.Width
  135.         End If
  136.         If Button2.Caption = "" Then
  137.             Button1.Left = 1925 - (Button1.Width / 2)
  138.             Exit Sub
  139.         End If
  140.         x = 3854 / 3
  141.         Button1.Left = x - (Button1.Width / 2)
  142.         Button2.Left = (x + x) - (Button2.Width / 2)
  143.         If Button2.Left < (Button1.Left + Button1.Width) Then
  144.             Button1.Left = (3854 / 4) - (Button1.Width / 2)
  145.             Button2.Left = (3854 / 2) + Button1.Left
  146.         End If
  147.         Button2.Visible = True
  148.     End If
  149. End Sub
  150. Sub Button2_Click ()
  151.     Answer.Text = 2
  152.     MsgWin.Hide
  153. End Sub
  154. Sub Form_GotFocus ()
  155.     Dim WinRect As RECT
  156.     Timer1.Enabled = True
  157.     GetWindowRect MsgWin.hWnd, WinRect
  158.     SetCursorPos WinRect.Left + 30, WinRect.Top + 10
  159. End Sub
  160. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  161.     If Timer1.Enabled = True Then
  162.         Dim Text As String * 256
  163.         GetKeyBoardState (Text)
  164.         Text = Left$(Text, KeyCode - 1) + Chr$(0) + Right$(Text, 256 - KeyCode)
  165.         SetKeyboardState (Text)
  166.         KeyCode = 0
  167.         Timer1.Enabled = False
  168.         Timer1.Interval = 1
  169.         Timer1.Enabled = True
  170.     End If
  171. End Sub
  172. Sub Form_Load ()
  173.     Message.Top = 2
  174.     MsgWin.Height = Message.Height + 2
  175.     Message.Left = 2
  176.     MsgWin.Width = Message.Width + 2
  177.     Timer1.Interval = 1500
  178. End Sub
  179. Sub Message_Click ()
  180.     If Timer1.Enabled = True Then MsgWin.Hide
  181. End Sub
  182. Sub Message_DblClick ()
  183.     If Timer1.Enabled = True Then MsgWin.Hide
  184. End Sub
  185. Sub Text1_GotFocus ()
  186.     Dim x As Integer, Text As String
  187.     Dim y As Integer, z As Long
  188.     Text = Text1.Tag
  189.     If Left$(Text, 1) = "A" Then
  190.         If Len(Text) > 1 Then
  191.             x = Val(Right$(Text, Len(Text) - 1))
  192.             Text1.MaxLength = x
  193.             x = (x * 9) / 10
  194.             Text = String$(x, "W")
  195.             z = GetTextExtent(MsgWin.hDC, Text, x)
  196.             Text = Hex$(z)
  197.             Text = "&h" + Right$(Text, 4)
  198.             x = Val(Text) * Screen.TwipsPerPixelX
  199.             If x > MsgWin.Width Then
  200.                 Text1.Width = MsgWin.Width - 60
  201.             Else
  202.                 Text1.Width = x
  203.             End If
  204.             Text1.Left = (MsgWin.Width - Text1.Width) / 2
  205.         End If
  206.     End If
  207.     If Message.Caption <> "" Then
  208.         x = Label.Height
  209.         Timer1.Enabled = False
  210.         Message.Alignment = 6
  211.         Label.Caption = Message.Caption
  212.         Message.Caption = ""
  213.         Label.Visible = True
  214.         Text1.Top = Label.Height + (x * 2)
  215.         Message.Height = Text1.Top + Text1.Height + 30
  216.         MsgWin.Height = Message.Height + 2
  217.     End If
  218. End Sub
  219. Sub Text1_KeyDown (KeyCode As Integer, Shift As Integer)
  220.     If KeyCode = 27 Then
  221.         Text1 = ""
  222.         KeyCode = 0
  223.         MsgWin.Hide
  224.     End If
  225. End Sub
  226. Sub Text1_KeyPress (KeyAscii As Integer)
  227.     If KeyAscii = 13 Then
  228.         KeyAscii = 0
  229.         MsgWin.Hide
  230.         Exit Sub
  231.     End If
  232.     If Text1.Tag = "N" Then
  233.         If KeyAscii >= 48 And KeyAscii <= 57 Then Exit Sub
  234.         If KeyAscii = 8 Then Exit Sub
  235.         KeyAscii = 0
  236.         Exit Sub
  237.     End If
  238. End Sub
  239. Sub Text1_LostFocus ()
  240.     MsgWin.Hide
  241. End Sub
  242. Sub Timer1_Timer ()
  243.     MsgWin.Hide
  244. End Sub
  245.