home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / code / various / msg / msgwin.txt < prev   
Encoding:
Text File  |  1995-02-27  |  4.8 KB  |  185 lines

  1. Option Explicit
  2.  
  3. Sub Button1_Click ()
  4.     Answer.Text = "1"
  5.     MsgWin.Hide
  6. End Sub
  7.  
  8. Sub Button1_GotFocus ()
  9.     Dim x As Integer, y As Long, Text As String
  10.     Dim Text1 As String
  11.     Dim yplus As Integer
  12.  
  13.  
  14.     If Button2.Visible = False Then
  15.         yplus = Label.Height
  16.         Message.Alignment = 6
  17.         Label.Caption = Message.Caption
  18.         Message.Caption = ""
  19.         Label.Visible = True
  20.         Message.Height = Label.Height + (yplus * 3) + Button1.Height
  21.         Button1.Top = Label.Height + yplus
  22.         Button2.Top = Button1.Top
  23.  
  24.         MsgWin.Height = Message.Height + 2
  25.         y = GetTextExtent(MsgWin.hDC, Button1.Caption, Len(Button1.Caption))
  26.         Text = Hex$(y)
  27.         Text = "&h" + Right$(Text, 4)
  28.         x = Val(Text)
  29.         x = (x * Screen.TwipsPerPixelX) * 1.5
  30.         Button1.Width = x
  31.         y = GetTextExtent(MsgWin.hDC, Button2.Caption, Len(Button2.Caption))
  32.         Text = Hex$(y)
  33.         Text = "&h" + Right$(Text, 4)
  34.         x = Val(Text)
  35.         x = (x * Screen.TwipsPerPixelX) * 1.5
  36.         Button2.Width = x
  37.         Button1.Top = Button1.Top + yplus
  38.         Button2.Top = Button2.Top + yplus
  39.         If Button1.Width < Button1.Height Then
  40.             Button1.Width = Button1.Width * 4 / 3
  41.             Button2.Width = Button2.Width * 4 / 3
  42.         End If
  43.         If Button2.Width < Button2.Height Then
  44.             Button2.Width = Button2.Width * 4 / 3
  45.             Button1.Width = Button1.Width * 4 / 3
  46.         End If
  47.         If Button2.Width < Button1.Width Then
  48.             Button2.Width = Button1.Width
  49.         Else
  50.             Button1.Width = Button2.Width
  51.         End If
  52.         If Button2.Caption = "" Then
  53.             Button1.Left = 1925 - (Button1.Width / 2)
  54.             Exit Sub
  55.         End If
  56.         x = 3854 / 3
  57.         Button1.Left = x - (Button1.Width / 2)
  58.         Button2.Left = (x + x) - (Button2.Width / 2)
  59.         If Button2.Left < (Button1.Left + Button1.Width) Then
  60.             Button1.Left = (3854 / 4) - (Button1.Width / 2)
  61.             Button2.Left = (3854 / 2) + Button1.Left
  62.         End If
  63.         Button2.Visible = True
  64.     End If
  65.  
  66. End Sub
  67.  
  68. Sub Button2_Click ()
  69.     Answer.Text = 2
  70.     MsgWin.Hide
  71. End Sub
  72.  
  73. Sub Form_GotFocus ()
  74.     Dim WinRect As RECT
  75.  
  76.     Timer1.Enabled = True
  77.     GetWindowRect MsgWin.hWnd, WinRect
  78.     SetCursorPos WinRect.Left + 30, WinRect.Top + 10
  79.  
  80. End Sub
  81.  
  82. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  83.     If Timer1.Enabled = True Then
  84.         Dim Text As String * 256
  85.         GetKeyBoardState (Text)
  86.         Text = Left$(Text, KeyCode - 1) + Chr$(0) + Right$(Text, 256 - KeyCode)
  87.         SetKeyboardState (Text)
  88.         KeyCode = 0
  89.         Timer1.Enabled = False
  90.         Timer1.Interval = 1
  91.         Timer1.Enabled = True
  92.     End If
  93. End Sub
  94.  
  95. Sub Form_Load ()
  96.     Message.Top = 2
  97.     MsgWin.Height = Message.Height + 2
  98.     Message.Left = 2
  99.     MsgWin.Width = Message.Width + 2
  100.     Timer1.Interval = 1500
  101. End Sub
  102.  
  103. Sub Message_Click ()
  104.     If Timer1.Enabled = True Then MsgWin.Hide
  105. End Sub
  106.  
  107. Sub Message_DblClick ()
  108.     If Timer1.Enabled = True Then MsgWin.Hide
  109. End Sub
  110.  
  111. Sub Text1_GotFocus ()
  112.     Dim x As Integer, Text As String
  113.     Dim y As Integer, z As Long
  114.     Text = Text1.Tag
  115.     If Left$(Text, 1) = "A" Then
  116.         If Len(Text) > 1 Then
  117.             x = Val(Right$(Text, Len(Text) - 1))
  118.             Text1.MaxLength = x
  119.             x = (x * 9) / 10
  120.             Text = String$(x, "W")
  121.             z = GetTextExtent(MsgWin.hDC, Text, x)
  122.             Text = Hex$(z)
  123.             Text = "&h" + Right$(Text, 4)
  124.             x = Val(Text) * Screen.TwipsPerPixelX
  125.             If x > MsgWin.Width Then
  126.                 Text1.Width = MsgWin.Width - 60
  127.             Else
  128.                 Text1.Width = x
  129.             End If
  130.             Text1.Left = (MsgWin.Width - Text1.Width) / 2
  131.         End If
  132.     End If
  133.  
  134.     If Message.Caption <> "" Then
  135.         x = Label.Height
  136.         Timer1.Enabled = False
  137.         Message.Alignment = 6
  138.         Label.Caption = Message.Caption
  139.         Message.Caption = ""
  140.         Label.Visible = True
  141.         Text1.Top = Label.Height + (x * 2)
  142.         Message.Height = Text1.Top + Text1.Height + 30
  143.         MsgWin.Height = Message.Height + 2
  144.     End If
  145.     
  146.  
  147.  
  148. End Sub
  149.  
  150. Sub Text1_KeyDown (KeyCode As Integer, Shift As Integer)
  151.     If KeyCode = 27 Then
  152.         Text1 = ""
  153.         KeyCode = 0
  154.         MsgWin.Hide
  155.     End If
  156. End Sub
  157.  
  158. Sub Text1_KeyPress (KeyAscii As Integer)
  159.     If KeyAscii = 13 Then
  160.         KeyAscii = 0
  161.         MsgWin.Hide
  162.         Exit Sub
  163.     End If
  164.  
  165.     If Text1.Tag = "N" Then
  166.         If KeyAscii >= 48 And KeyAscii <= 57 Then Exit Sub
  167.         If KeyAscii = 8 Then Exit Sub
  168.         KeyAscii = 0
  169.         Exit Sub
  170.     End If
  171.  
  172.  
  173.  
  174. End Sub
  175.  
  176. Sub Text1_LostFocus ()
  177.     MsgWin.Hide
  178. End Sub
  179.  
  180. Sub Timer1_Timer ()
  181.     
  182.     MsgWin.Hide
  183. End Sub
  184.  
  185.