home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / Advanced_P53335252002.psc / frmSample.frm (.txt) next >
Encoding:
Visual Basic Form  |  2002-02-06  |  8.8 KB  |  214 lines

  1. VERSION 5.00
  2. Begin VB.Form frmSample 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Sample Tips Form"
  5.    ClientHeight    =   3495
  6.    ClientLeft      =   45
  7.    ClientTop       =   435
  8.    ClientWidth     =   5160
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    ScaleHeight     =   3495
  12.    ScaleWidth      =   5160
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.CommandButton cmd4 
  15.       Caption         =   "Balloon 4"
  16.       Height          =   375
  17.       Left            =   3900
  18.       TabIndex        =   9
  19.       Top             =   1440
  20.       Width           =   1155
  21.    End
  22.    Begin VB.CommandButton cmd3 
  23.       Caption         =   "Balloon 3"
  24.       Height          =   375
  25.       Left            =   2640
  26.       TabIndex        =   8
  27.       Top             =   1440
  28.       Width           =   1155
  29.    End
  30.    Begin VB.CommandButton cmd2 
  31.       Caption         =   "Balloon 2"
  32.       Height          =   375
  33.       Left            =   1440
  34.       TabIndex        =   7
  35.       Top             =   1440
  36.       Width           =   1155
  37.    End
  38.    Begin VB.CommandButton cmd1 
  39.       Caption         =   "Balloon 1"
  40.       Height          =   375
  41.       Left            =   180
  42.       TabIndex        =   6
  43.       Top             =   1440
  44.       Width           =   1155
  45.    End
  46.    Begin VB.TextBox txtInformation 
  47.       Height          =   975
  48.       Left            =   120
  49.       Locked          =   -1  'True
  50.       MultiLine       =   -1  'True
  51.       ScrollBars      =   2  'Vertical
  52.       TabIndex        =   4
  53.       Text            =   "frmSample.frx":0000
  54.       Top             =   1920
  55.       Width           =   4935
  56.    End
  57.    Begin VB.CommandButton cmdExample2 
  58.       Caption         =   "&Another Example"
  59.       Height          =   375
  60.       Left            =   3240
  61.       TabIndex        =   2
  62.       Top             =   3000
  63.       Width           =   1695
  64.    End
  65.    Begin VB.CommandButton cmdPopIt 
  66.       Caption         =   "&Pop It Up!"
  67.       Height          =   375
  68.       Left            =   2040
  69.       TabIndex        =   0
  70.       Top             =   360
  71.       Width           =   1215
  72.    End
  73.    Begin VB.Label lblMore 
  74.       Caption         =   "The buttons below will also display some more styles of pop-up balloons. Click them!"
  75.       Height          =   495
  76.       Left            =   120
  77.       TabIndex        =   5
  78.       Top             =   960
  79.       Width           =   4935
  80.    End
  81.    Begin VB.Label lblExample2 
  82.       Caption         =   "For another, more practical example, click:"
  83.       Height          =   255
  84.       Left            =   120
  85.       TabIndex        =   3
  86.       Top             =   3120
  87.       Width           =   3135
  88.    End
  89.    Begin VB.Label lblInformation 
  90.       Caption         =   "Click the button to pop up the sample balloon to see what it looks like:"
  91.       Height          =   255
  92.       Left            =   120
  93.       TabIndex        =   1
  94.       Top             =   120
  95.       Width           =   4935
  96.    End
  97. Attribute VB_Name = "frmSample"
  98. Attribute VB_GlobalNameSpace = False
  99. Attribute VB_Creatable = False
  100. Attribute VB_PredeclaredId = True
  101. Attribute VB_Exposed = False
  102. Private Sub cmd1_Click()
  103. Dim WinRect As RECT
  104. Dim WinPoint As POINTAPI
  105. Dim BalloonXY As BalloonCoords
  106. Call GetWindowRect(cmd1.hWnd, WinRect)
  107. BalloonXY.X = WinRect.Left * Screen.TwipsPerPixelX
  108. BalloonXY.Y = WinRect.Bottom * Screen.TwipsPerPixelY
  109. Dim frmBalloon1 As New frmTip
  110. frmBalloon1.SetBalloon "Balloon One", "This is a balloon! My properties are set " & _
  111.     "so that I have a close button, no icon, and will not automatically close " & _
  112.     "after a certain amount of time. My coordinates are also set so that I " & _
  113.     "display by the ""Balloon 1"" button.", BalloonXY.X, BalloonXY.Y, , True
  114. frmBalloon1.Show , Me
  115. Me.SetFocus
  116. End Sub
  117. Private Sub cmd2_Click()
  118. Dim WinRect As RECT
  119. Dim WinPoint As POINTAPI
  120. Dim BalloonXY As BalloonCoords
  121. Call GetWindowRect(cmd2.hWnd, WinRect)
  122. BalloonXY.X = WinRect.Left * Screen.TwipsPerPixelX
  123. BalloonXY.Y = WinRect.Bottom * Screen.TwipsPerPixelY
  124. Dim frmBalloon2 As New frmTip
  125. frmBalloon2.SetBalloon "Balloon Two", "I am Balloon 2. My properties are set " & _
  126.     "so that I do not display a close (X) button, will auto-close after ten " & _
  127.     "seconds, have a custom height and width, appear next to the ""Balloon 2"" " & _
  128.     "button, and display a 9x-style ""!"" icon", _
  129.     BalloonXY.X, BalloonXY.Y, "!9", , 10000, 2500, 2100
  130. frmBalloon2.Show , Me
  131. Me.SetFocus
  132. End Sub
  133. Private Sub cmd3_Click()
  134. Dim WinRect As RECT
  135. Dim WinPoint As POINTAPI
  136. Dim BalloonXY As BalloonCoords
  137. Call GetWindowRect(cmd1.hWnd, WinRect)
  138. BalloonXY.X = WinRect.Left * Screen.TwipsPerPixelX
  139. BalloonXY.Y = WinRect.Bottom * Screen.TwipsPerPixelY
  140. Dim frmBalloon3 As New frmTip
  141. frmBalloon3.SetBalloon "Balloon Three", "I am the Balloon 3. I am set to auto-" & _
  142.     "close after fifteen seconds, display a close (X) button, show an (XP-style" & _
  143.     ") ""i"" icon, appear lined up with the first button in this row (but be " & _
  144.     "about centered on this form), and show using a custom font, Tahoma.", _
  145.     BalloonXY.X, BalloonXY.Y, "i", True, 15000, , , "Tahoma"
  146. frmBalloon3.Show , Me
  147. Me.SetFocus
  148. End Sub
  149. Private Sub cmd4_Click()
  150. Dim WinRect As RECT
  151. Dim WinPoint As POINTAPI
  152. Dim BalloonXY As BalloonCoords
  153. Call GetWindowRect(cmd1.hWnd, WinRect)
  154. BalloonXY.X = WinRect.Left * Screen.TwipsPerPixelX
  155. BalloonXY.Y = WinRect.Bottom * Screen.TwipsPerPixelY
  156. Dim frmBalloon4 As New frmTip
  157. frmBalloon4.SetBalloon "RTF File In Balloon", "", _
  158.     BalloonXY.X, BalloonXY.Y, "i", _
  159.     True, 30000, 3000, 6000, "Tahoma", App.Path & "\test.rtf"
  160. frmBalloon4.Show , Me
  161. Me.SetFocus
  162. End Sub
  163. Private Sub cmdExample2_Click()
  164. frmSample2.Show
  165. Unload Me
  166. End Sub
  167. Private Sub cmdPopIt_Click()
  168. Dim WinRect As RECT         'These are used to hold some values we
  169. Dim WinPoint As POINTAPI    'get during the API calls, and for
  170. Dim BalloonXY As BalloonCoords 'storing the X and Y coordinates
  171.                             'of the balloon that we pass when showing it
  172. 'This code is used to determine the position of the balloon. We (usually)
  173. 'want it to be displayed near some type of object, and since we need to
  174. 'set the balloon's coordinates relative to the screen, not the form, we
  175. 'need to determine the screen position of the control by which we want to
  176. 'place the balloon so it will show in the right spot.
  177. 'Get coordinates of the object on it that we want to
  178. 'display the ballooon by
  179. Call GetWindowRect(cmdPopIt.hWnd, WinRect) 'When you use this code, replace
  180.                                     'cmdPopIt with whatever control you
  181.                                     'want to place the balloon by.
  182.                                     
  183. 'This is multiplied by TwipsPerPixel because VB works
  184. 'with twips by default, but the API works in pixels. We'll be assigning
  185. 'the X and Y coordinates we get (which will be the coordiate for the lower
  186. 'left-hand corner of the control we chose above) to a BalloonXY (with .X
  187. 'and .Y properties) type object so we can easily use these coordinates
  188. 'later when we call to show the balloon.
  189. 'You can just assign them to two variables or whatever if you like, or
  190. 'just use the "formula" for figuring them directly when you call SetBalloon()
  191. 'instead of calculating them and then holding them in a variable.
  192. BalloonXY.X = WinRect.Left * Screen.TwipsPerPixelX
  193. BalloonXY.Y = WinRect.Bottom * Screen.TwipsPerPixelY
  194. Dim frmPopUpBalloon As New frmTip 'Make a new form based on frmTip
  195. frmPopUpBalloon.SetBalloon "Sample Balloon", "This is a sample balloon to " & _
  196.     "demonstrate the capabilities of the pop-up balloon/tooltips that you can " & _
  197.     "use in your programs! They can include a title, multi-line text, an optional " & _
  198.     "close button, automatiically close after a certain amount of time, " & _
  199.     "an icon, and show in any font!  Don't forget you can click and drag the balloon by its title!", BalloonXY.X, BalloonXY.Y, "i", True, _
  200.      30000, , , "Tahoma"  'These preceeding lines set the properties
  201.                         '(text, etc.) for the balloon
  202. frmPopUpBalloon.Show , Me 'Show the balloon, with me as the owner
  203. Me.SetFocus 'Since the balloon is a window (a form), showing it will
  204.             'take focus away from this form, which it's called from,
  205.             'and we don't want that to happen. We're working around it
  206.             'by giving me focus after showing it. There IS away to show
  207.             'a window without giving it focus via API, but I haven't
  208.             'gotten that to work yet.
  209. End Sub
  210. Private Sub txtInformation_KeyPress(KeyAscii As Integer)
  211. 'Show a balloon if you try to type in the textbox (its Locked property
  212. 'is true, so you can't edit it anyway, but this will tell you if you try)
  213. End Sub
  214.