home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / grafik / zzhot / zzhdemo.frm < prev    next >
Text File  |  1994-08-31  |  12KB  |  407 lines

  1. VERSION 2.00
  2. Begin Form MainForm 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "ZZHOT.VBX  Demo"
  6.    ClientHeight    =   5910
  7.    ClientLeft      =   645
  8.    ClientTop       =   1755
  9.    ClientWidth     =   7680
  10.    FontBold        =   -1  'True
  11.    FontItalic      =   0   'False
  12.    FontName        =   "Arial"
  13.    FontSize        =   8.25
  14.    FontStrikethru  =   0   'False
  15.    FontUnderline   =   0   'False
  16.    Height          =   6600
  17.    Icon            =   ZZHDEMO.FRX:0000
  18.    Left            =   585
  19.    LinkTopic       =   "Form1"
  20.    MaxButton       =   0   'False
  21.    ScaleHeight     =   5910
  22.    ScaleWidth      =   7680
  23.    Top             =   1125
  24.    Width           =   7800
  25.    Begin PictureBox Pic1 
  26.       BorderStyle     =   0  'None
  27.       Height          =   5955
  28.       Left            =   -25
  29.       Picture         =   ZZHDEMO.FRX:0302
  30.       ScaleHeight     =   397
  31.       ScaleMode       =   3  'Pixel
  32.       ScaleWidth      =   517
  33.       TabIndex        =   0
  34.       Top             =   0
  35.       Width           =   7755
  36.       Begin TextBox TB 
  37.          BackColor       =   &H00C0C0C0&
  38.          FontBold        =   -1  'True
  39.          FontItalic      =   0   'False
  40.          FontName        =   "Arial"
  41.          FontSize        =   8.25
  42.          FontStrikethru  =   0   'False
  43.          FontUnderline   =   0   'False
  44.          ForeColor       =   &H00000000&
  45.          Height          =   1845
  46.          Left            =   30
  47.          MultiLine       =   -1  'True
  48.          ScrollBars      =   2  'Vertical
  49.          TabIndex        =   2
  50.          Top             =   3000
  51.          Visible         =   0   'False
  52.          Width           =   7695
  53.       End
  54.       Begin ZZHOT Pic1ZZ 
  55.          CursorIndex     =   14  'Help Arrow
  56.          hCursor         =   0
  57.          HiLiteHsID      =   0
  58.          HSFileName      =   ""
  59.          Left            =   6120
  60.          OutlineHotSpots =   0   'False
  61.          Top             =   4620
  62.       End
  63.       Begin Label Prompt 
  64.          Alignment       =   2  'Center
  65.          BackColor       =   &H00FFC0C0&
  66.          BackStyle       =   0  'Transparent
  67.          FontBold        =   -1  'True
  68.          FontItalic      =   0   'False
  69.          FontName        =   "Arial"
  70.          FontSize        =   12
  71.          FontStrikethru  =   0   'False
  72.          FontUnderline   =   0   'False
  73.          ForeColor       =   &H00000000&
  74.          Height          =   360
  75.          Left            =   2880
  76.          TabIndex        =   1
  77.          Top             =   45
  78.          Width           =   2970
  79.       End
  80.    End
  81.    Begin Menu mnuFile 
  82.       Caption         =   "&File"
  83.       Begin Menu mnuFileGood 
  84.          Caption         =   "&LoadGoodFile"
  85.       End
  86.       Begin Menu mnuFileBad 
  87.          Caption         =   "Test&BadFile"
  88.       End
  89.       Begin Menu mnuFileExit 
  90.          Caption         =   "E&xit"
  91.       End
  92.    End
  93.    Begin Menu mnuDemo 
  94.       Caption         =   "&Demo"
  95.       Begin Menu mnuDemoFind 
  96.          Caption         =   "&Find"
  97.       End
  98.       Begin Menu mnuDemoNone 
  99.          Caption         =   "HiLite Mode &None"
  100.       End
  101.       Begin Menu mnuDemoDown 
  102.          Caption         =   "HiLite Mode Mouse&Down"
  103.       End
  104.       Begin Menu mnuDemoOver 
  105.          Caption         =   "HiLite Mode Mouse&Over"
  106.       End
  107.    End
  108. End
  109. Option Explicit
  110. Dim LastID%
  111.  
  112. Sub clearchks ()
  113. mnuDemoDown.Checked = False
  114. mnuDemoNone.Checked = False
  115. mnuDemoOver.Checked = False
  116.  
  117. End Sub
  118.  
  119. Sub Form_Activate ()
  120. Call LoadGoodFile(Pic1ZZ)
  121.  
  122.  
  123. End Sub
  124.  
  125. Sub Form_Load ()
  126. crlf$ = Chr$(13) & Chr$(10) 'useful
  127.  
  128. ourpath$ = app.Path
  129. If Right$(ourpath, 1) <> "\" Then ourpath = ourpath & "\" 'cuz it ain't there on root
  130. TextFile$ = ourpath$ & "country.txt" 'for display text
  131.  
  132. If Not FillTextArray%() Then 'Fill up the text array with the country stuff
  133.   DoMsgBox "Due to an error reading the text file, part of the demo will not work."
  134. End If
  135.  
  136. End Sub
  137.  
  138. Sub Form_Unload (Cancel As Integer)
  139. Dim ret%
  140. If CursorLock Then
  141.   ret% = UnClipCursor(0&)
  142.   CursorLock = False
  143. End If
  144. 'just to be real safe
  145.  
  146. End
  147. End Sub
  148.  
  149. Sub mnuDemoDown_Click ()
  150. On Error Resume Next
  151.  
  152. Pic1ZZ.HiLiteMode = 1   'set the mode
  153. clearchks 'clear all chks
  154. mnuDemoDown.Checked = True 'and set this one
  155. End Sub
  156.  
  157. Sub mnuDemoFind_Click ()
  158. 'find an entered item
  159. 'we just popup an input box, obviously a "real" app
  160. 'would do something more elegant.
  161. On Error Resume Next
  162. Dim userIn$, hsid%, theTag$, taglen%, ret%, hrgn%
  163. Dim xoff%, yoff%, xc%, yc%
  164. Dim offRect As RECT
  165. Dim theRect As RECT
  166. 'figure out our offset for things that return in screen coordinates
  167. ret% = GetWindowRect%(pic1.hWnd, offRect)
  168. xoff% = offRect.left
  169. yoff% = offRect.top
  170.  
  171. theTag$ = Space$(255) 'pad with spaces
  172. 'get the TextPanel out of the way
  173. 'TextPanel.WindowState = 1
  174. MainForm!TB.Visible = False
  175. userIn$ = UCase$(InputBox("Enter a country name to find.", , "Germany"))
  176. mnuDemoNone_Click 'make sure we set hilite mode to zero
  177.  
  178. 'Note, for the loop range below, one could use the RegionCount property.
  179. 'BUT, remember that the Hot Spot Editor does not enforce contiguous HsIDs
  180. 'so it is up to you to make sure they are by using Renumber HsID's in the
  181. 'editor, just prior to saving.  The method below of using the constants
  182. 'generated by the editor is generally preferred.  Of course, this looping
  183. 'also requires contiguous HsID's  but the range is explicit.
  184.  
  185. For hsid% = SPAIN To LOGO  'search through all HsID's
  186.   ret% = ZZ_GetHsIDTag%(Pic1ZZ, hsid%, theTag$, taglen%) 'get the tag of this HsID
  187.   If ret% Then  'if valid
  188.     If UCase$(Left$(theTag$, taglen%)) = userIn$ Then   'compare
  189.       hrgn% = ZZ_GetHrgn%(Pic1ZZ, hsid) 'get the rgn handle
  190.       ret = GetRgnBox(hrgn%, theRect) 'get the surrounding box
  191.       theRect.top = theRect.top + yoff%   'it's relative to screen
  192.       theRect.left = theRect.left + xoff%
  193.       theRect.Bottom = theRect.Bottom + yoff%
  194.       theRect.Right = theRect.Right + xoff%
  195.       xc% = (theRect.Right + (theRect.left - theRect.Right) \ 2)  'find center of box
  196.       yc% = (theRect.top + (theRect.Bottom - theRect.top) \ 2)
  197.       Call SetCursorPos(xc%, yc%)  'move the cursor
  198.  
  199.       CursorLock% = True  'set the flag so we know we've clipped it
  200.        ret = ClipCursor(theRect)  'don't forget to release it sometime
  201.       ret = DeleteObject(hrgn) '!!! DELETE THE HRGN WE GOT FROM ZZ_GETHRGN!!!
  202.       Exit For
  203.     End If
  204.   End If
  205. Next
  206. If Not CursorLock Then Beep  'didn't find it
  207.  
  208. End Sub
  209.  
  210. Sub mnuDemoNone_Click ()
  211. On Error Resume Next
  212. Pic1ZZ.HiLiteMode = 0 'set the mode
  213. clearchks 'clear em out
  214. mnuDemoNone.Checked = True 'and chk this one
  215.  
  216. End Sub
  217.  
  218. Sub mnuDemoOver_Click ()
  219. On Error Resume Next
  220. Pic1ZZ.HiLiteMode = 2 'set the mode
  221. clearchks  'clear em all
  222. mnuDemoOver.Checked = True 'set this one
  223.  
  224. End Sub
  225.  
  226. Sub mnuFileBad_Click ()
  227. Dim ret%
  228. ret% = TestBadFile(Pic1ZZ)
  229.  
  230. End Sub
  231.  
  232. Sub mnuFileExit_Click ()
  233. Call StopThisProgram
  234. End Sub
  235.  
  236. Sub mnuFileGood_Click ()
  237. Call LoadGoodFile(Pic1ZZ)
  238.  
  239. End Sub
  240.  
  241. Sub Pic1_Click ()
  242. On Error Resume Next
  243. Dim ret%
  244. 'make sure the cursor gets unlocked if it is
  245. If CursorLock Then
  246.   ret% = UnClipCursor(&H0&)
  247.   CursorLock = False
  248. End If
  249.  TB.Visible = False
  250. End Sub
  251.  
  252. Sub Pic1_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
  253. On Error Resume Next
  254. If LastID% <> -1 Then
  255.   Prompt.Caption = ""
  256.   Prompt.Refresh 'this is necessary to force the update on the
  257.   'caption property if the mouse keeps moving across the ocean
  258. End If
  259. LastID% = -1
  260.  
  261.  
  262. End Sub
  263.  
  264. Sub Pic1ZZ_Click (hsid As Integer, HsIDTag As String)
  265. ' This demonstrates the use of the hCursor property
  266.  
  267. ' there's lots of ways to get a cursor handle
  268. ' I'll use the laziest way for this demo
  269.  
  270. Static cur%
  271. On Error Resume Next
  272. If hsid <> LOGO Then Exit Sub
  273. 'just do it on the LOGO for demo purposes
  274.  
  275. cur% = Not cur%
  276. If cur% Then
  277.   Pic1ZZ.hCursor = LoadCursor(APINULL, IDC_ICON)
  278.                         'no need to destroy sys cursor
  279.   DoMsgBox "Click on the Logo again to revert the cursors"
  280. Else
  281.   Pic1ZZ.hCursor = 0 ' zero means use the cursor index
  282.  
  283. End If
  284.  
  285. End Sub
  286.  
  287. Sub Pic1ZZ_MouseDown (Button As Integer, Shift As Integer, X As Integer, Y As Integer, relX As Integer, relY As Integer, hsid As Integer, HsIDTag As String)
  288.  
  289. 'here's a good example of where we need the mouse down
  290. 'because we want to release the cursor before we
  291. 'put up the msgbox in the mouseup event.  Otherwise,
  292. 'the user couldn't get to the OK button
  293. On Error Resume Next
  294. Dim ret%
  295. If CursorLock Then
  296.   ret% = UnClipCursor(0&)
  297.   CursorLock = False
  298. End If
  299.  
  300. End Sub
  301.  
  302. Sub Pic1ZZ_MouseOver (hsid As Integer, HsIDTag As String)
  303. 'NOTES:
  304. 'Normally you probably won't be changing the stupid
  305. 'cursor for each hot spot region.  This is just
  306. 'to demonstrate that you can if you want/need to.
  307. 'Actually, we now, exit before that, left it in for illustration purposes.
  308.  
  309. 'You can just set the curor index at design time
  310. 'or run init time and leave it alone and then
  311. 'you'll have the same cursor on each region.
  312. On Error Resume Next
  313. If hsid% = LastID% Then Exit Sub
  314.  
  315. 'If hsid% <> LastID% Then
  316.   Prompt.Caption = HsIDTag
  317.   Prompt.Refresh 'keeps it snappy
  318. 'End If
  319. LastID% = hsid%
  320.  
  321. '----------- this block substitutes for Select Case below
  322. If hsid% = LOGO Then
  323.   Pic1ZZ.CursorIndex = 12
  324. ElseIf Pic1ZZ.CursorIndex <> 14 Then
  325.   Pic1ZZ.CursorIndex = 14
  326. End If
  327.  
  328. Exit Sub '! remove this line to illustrate lots of cursor changes.
  329. '----------end of block substitute
  330.  
  331. ' the code below illustrates the extreme of changing the
  332. 'cursor for just about each region on the pic.
  333. 'you can try it to check worse case performance.
  334.  
  335. Select Case hsid
  336.   Case FORMERLY_YUGOSLAVIA
  337.     Pic1ZZ.CursorIndex = 16
  338.   Case FRANCE
  339.     Pic1ZZ.CursorIndex = 27
  340.   Case SPAIN
  341.     Pic1ZZ.CursorIndex = 21
  342.   Case ICELAND
  343.     Pic1ZZ.CursorIndex = 7
  344.   Case NORWAY
  345.     Pic1ZZ.CursorIndex = 24
  346.   Case SWITZERLAND
  347.     Pic1ZZ.CursorIndex = 25
  348.   Case LUXEMBOURG
  349.      Pic1ZZ.CursorIndex = 8
  350.   Case SWEDEN
  351.      Pic1ZZ.CursorIndex = 1
  352.   Case GERMANY
  353.      Pic1ZZ.CursorIndex = 2
  354.   Case POLAND
  355.      Pic1ZZ.CursorIndex = 3
  356.   Case SCOTLAND
  357.      Pic1ZZ.CursorIndex = 11
  358.   Case WALES
  359.      Pic1ZZ.CursorIndex = 23
  360.   Case ENGLAND
  361.      Pic1ZZ.CursorIndex = 20
  362.   Case IRELAND
  363.      Pic1ZZ.CursorIndex = 19
  364.   Case LOGO
  365.      Pic1ZZ.CursorIndex = 5
  366.   Case GULL
  367.      Pic1ZZ.CursorIndex = 30
  368.   Case COMPASS
  369.      Pic1ZZ.CursorIndex = 11
  370.  
  371.   Case Else
  372.     Pic1ZZ.CursorIndex = 14
  373. End Select
  374. End Sub
  375.  
  376. Sub Pic1ZZ_MouseUp (Button As Integer, Shift As Integer, X As Integer, Y As Integer, relX As Integer, relY As Integer, hsid As Integer, HsIDTag As String)
  377.  
  378. Dim COMPASS$
  379. On Error Resume Next
  380. Select Case hsid
  381.   Case SPAIN To BULGARIA
  382.     
  383.     Call ShowText(hsid%, HsIDTag$)
  384.   Case LOGO
  385.     'do nothing here
  386.   Case Else
  387.     'TextPanel.WindowState = 1
  388.     MainForm!TB.Visible = False
  389.   If relX > 0 And relY > 0 Then
  390.     COMPASS$ = "North-West"
  391.   ElseIf relX > 0 And relY < 0 Then
  392.     COMPASS$ = "South-West"
  393.   ElseIf relX < 0 And relY > 0 Then
  394.     COMPASS$ = "North-East"
  395.   Else
  396.     COMPASS$ = "South-East"
  397.     'NOTE- this is not always true because if there
  398.     'is no ref point defined it'll still show up here
  399.     'but that's a problem with this VB code and not
  400.     'with the VBX.
  401.   End If
  402.   DoMsgBox "Just to demonstrate the RefPt feature, you clicked " & COMPASS$ & " of the reference point on the " & HsIDTag$
  403. End Select
  404.  
  405. End Sub
  406.  
  407.