home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / rga / rga1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-12-05  |  4.1 KB  |  116 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "I Love WinApps!"
  4.    ClientHeight    =   3960
  5.    ClientLeft      =   990
  6.    ClientTop       =   1950
  7.    ClientWidth     =   6525
  8.    Height          =   4650
  9.    Icon            =   RGA1.FRX:0000
  10.    Left            =   930
  11.    LinkMode        =   1  'Source
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3960
  14.    ScaleWidth      =   6525
  15.    Top             =   1320
  16.    Width           =   6645
  17.    Begin Menu FileMenuNull 
  18.       Caption         =   "&File"
  19.       Begin Menu FileMenuAbout 
  20.          Caption         =   "&About"
  21.          Shortcut        =   {F1}
  22.       End
  23.       Begin Menu FileMenuFiller1 
  24.          Caption         =   "-"
  25.       End
  26.       Begin Menu FileMenuExit 
  27.          Caption         =   "E&xit"
  28.       End
  29.    End
  30. ' This has variables germane to multiple procedures in the
  31. ' form. Otherwise, Visual Basic would have each form having
  32. ' its own variables.
  33. Dim FirstTimeThrough As Integer
  34. Dim ResizeOnly As Integer
  35. Sub FileMenuAbout_Click ()
  36. ' This runs when the user requests "File, About":
  37. ' Build a message.
  38.     A$ = "The " + Chr$(34) + ILWA$ + Chr$(34) + " Program" + Chr$(13) + Chr$(10) + "by Charles L. Perrin"
  39. ' Display the message.
  40.     MsgBox A$, 64, ILWA$
  41. End Sub
  42. Sub FileMenuExit_Click ()
  43. ' This executes when the user does the Exit request:
  44.     End
  45. ' and that's all, folks!
  46. End Sub
  47. Sub Form_Click ()
  48. ' This is invoked every time a mouse click is in the window.
  49.     Dim FontMax, FontNo, THW, THH As Integer
  50. ' Clear the screen.
  51.     Cls
  52. ' Don't switch fonts if we're only redrawing.
  53.     If Not (ResizeOnly) Then
  54. ' Is not the first time through?
  55.         If Not (FirstTimeThrough) Then
  56. ' Get number of fonts currently defined for the screen.
  57. ' (The number of screen fonts can change on the fly!)
  58.             FontMax = Screen.FontCount
  59. ' This begins a loop that obtains candidate fonts, and
  60. ' throws out the ones that aren't text!
  61.             Do
  62. ' Come up with a random font number.
  63.                 FontNo = Int(FontMax * Rnd(1))
  64. ' Get the font name.
  65.                 ProposedFontName$ = Screen.Fonts(FontNo)
  66. ' Convert the font name to upper case for matching ease.
  67.                 ProposedFontUC$ = UCase$(ProposedFontName$)
  68. ' I'm not going to let this loop exit on three cases:
  69. '   DINGBAT fonts, SYMBOL fonts, or the DIGITAL (Clock) font.
  70.             Loop Until ((InStr(ProposedFontUC$, "DINGBAT") = 0) And (InStr(ProposedFontUC$, "SYMBOL") = 0) And (ProposedFontUC$ <> "DIGITAL"))
  71. ' Set the font name to the proposed font name.
  72.             FontName = ProposedFontName$
  73. ' Or, is this the first time through?
  74.         Else
  75. ' First time through - use the first font (SYSTEM, usually).
  76.             FontName = Screen.Fonts(0)
  77.         End If
  78.     End If
  79. ' Set the font size to 12 points.
  80.     FontSize = 12
  81. ' Determine half the text width.
  82.     THW = TextWidth(ILWA$) / 2
  83. ' Determine half the text height.
  84.     THH = TextHeight(ILWA$) / 2
  85. ' Set the X, Y screen position to center the text.
  86.     CurrentX = ScaleWidth / 2 - THW
  87.     CurrentY = ScaleHeight / 2 - THH
  88. ' Print the text "I Love WinApps!"
  89.     Print ILWA$
  90. ' Indicate that the resize is finished.
  91.     ResizeOnly = False
  92. ' Indicate that this isn't the first time through.
  93.     FirstTimeThrough = False
  94. End Sub
  95. Sub Form_Load ()
  96. ' This gets executed when the module loads:
  97. ' Seed the random number generator.
  98.     Randomize
  99. ' Indicate that the form is to automatically redraw.
  100.     AutoRedraw = True
  101. ' Indicate that this is the first time through.
  102.     FirstTimeThrough = True
  103. ' Simulate the initial click to bring up the text.
  104.     Form_Click
  105. End Sub
  106. Sub Form_Resize ()
  107. ' This gets entered if the user's been playing with that
  108. ' big fat border and resizing this puppy!
  109. ' Clear the screen.
  110.     Cls
  111. ' Indicate that only a resize operation is to take place.
  112.     ResizeOnly = True
  113. ' Simulate a form click and let that finish the job!
  114.     Form_Click
  115. End Sub
  116.