home *** CD-ROM | disk | FTP | other *** search
/ CD Shareware Magazine 1999 April / CD_Shareware_Magazine_31.iso / Free / Prg / imagemapmaker.exe / frmMain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-07-02  |  11.6 KB  |  355 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
  3. Begin VB.Form frmMain 
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "Image Map Maker"
  6.    ClientHeight    =   4188
  7.    ClientLeft      =   2364
  8.    ClientTop       =   1488
  9.    ClientWidth     =   5520
  10.    DrawMode        =   7  'Invert
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   349
  13.    ScaleMode       =   3  'Pixel
  14.    ScaleWidth      =   460
  15.    Begin VB.PictureBox picContainScroller 
  16.       Appearance      =   0  'Flat
  17.       BackColor       =   &H00C0C0C0&
  18.       BorderStyle     =   0  'None
  19.       ForeColor       =   &H80000008&
  20.       Height          =   252
  21.       Left            =   120
  22.       ScaleHeight     =   1.05
  23.       ScaleMode       =   4  'Character
  24.       ScaleWidth      =   44.1
  25.       TabIndex        =   2
  26.       Top             =   0
  27.       Visible         =   0   'False
  28.       Width           =   5292
  29.       Begin VB.PictureBox picScroller 
  30.          Appearance      =   0  'Flat
  31.          AutoSize        =   -1  'True
  32.          BackColor       =   &H00C0C0C0&
  33.          BorderStyle     =   0  'None
  34.          ForeColor       =   &H80000008&
  35.          Height          =   252
  36.          Left            =   0
  37.          ScaleHeight     =   1.05
  38.          ScaleMode       =   4  'Character
  39.          ScaleWidth      =   30.1
  40.          TabIndex        =   3
  41.          Top             =   0
  42.          Width           =   3612
  43.          Begin VB.Label lblScroller 
  44.             AutoSize        =   -1  'True
  45.             BeginProperty Font 
  46.                Name            =   "MS Sans Serif"
  47.                Size            =   7.8
  48.                Charset         =   161
  49.                Weight          =   700
  50.                Underline       =   0   'False
  51.                Italic          =   0   'False
  52.                Strikethrough   =   0   'False
  53.             EndProperty
  54.             ForeColor       =   &H00FF0000&
  55.             Height          =   192
  56.             Left            =   0
  57.             TabIndex        =   4
  58.             Top             =   0
  59.             Width           =   60
  60.          End
  61.       End
  62.    End
  63.    Begin VB.PictureBox picContainer 
  64.       Appearance      =   0  'Flat
  65.       BackColor       =   &H00C0C0C0&
  66.       BorderStyle     =   0  'None
  67.       ForeColor       =   &H80000008&
  68.       Height          =   3612
  69.       Left            =   120
  70.       ScaleHeight     =   301
  71.       ScaleMode       =   3  'Pixel
  72.       ScaleWidth      =   441
  73.       TabIndex        =   0
  74.       Top             =   240
  75.       Width           =   5292
  76.       Begin VB.Timer Timer2 
  77.          Interval        =   1
  78.          Left            =   1200
  79.          Top             =   1320
  80.       End
  81.       Begin VB.HScrollBar hsb1 
  82.          Height          =   252
  83.          LargeChange     =   15
  84.          Left            =   0
  85.          SmallChange     =   5
  86.          TabIndex        =   6
  87.          Top             =   3360
  88.          Visible         =   0   'False
  89.          Width           =   5052
  90.       End
  91.       Begin VB.VScrollBar vsb1 
  92.          Height          =   3372
  93.          LargeChange     =   15
  94.          Left            =   5040
  95.          SmallChange     =   5
  96.          TabIndex        =   5
  97.          Top             =   0
  98.          Visible         =   0   'False
  99.          Width           =   252
  100.       End
  101.       Begin VB.Timer Timer1 
  102.          Interval        =   100
  103.          Left            =   2520
  104.          Top             =   1920
  105.       End
  106.       Begin VB.PictureBox picImage 
  107.          Appearance      =   0  'Flat
  108.          AutoSize        =   -1  'True
  109.          BackColor       =   &H80000005&
  110.          BorderStyle     =   0  'None
  111.          ForeColor       =   &H80000008&
  112.          Height          =   852
  113.          Left            =   0
  114.          ScaleHeight     =   71
  115.          ScaleMode       =   3  'Pixel
  116.          ScaleWidth      =   121
  117.          TabIndex        =   1
  118.          Top             =   0
  119.          Visible         =   0   'False
  120.          Width           =   1452
  121.       End
  122.    End
  123.    Begin MSComDlg.CommonDialog dlgOpen 
  124.       Left            =   3720
  125.       Top             =   720
  126.       _ExtentX        =   677
  127.       _ExtentY        =   677
  128.       _Version        =   327681
  129.       CancelError     =   -1  'True
  130.       Filter          =   "Picture files|*.gif;*.bmp;*.jpg;*.ico"
  131.    End
  132.    Begin VB.Label Label1 
  133.       AutoSize        =   -1  'True
  134.       Height          =   192
  135.       Left            =   120
  136.       TabIndex        =   7
  137.       Top             =   3912
  138.       Width           =   36
  139.    End
  140.    Begin VB.Menu mnuFile 
  141.       Caption         =   "File"
  142.       Begin VB.Menu mnuNewImageMap 
  143.          Caption         =   "New Image Map"
  144.       End
  145.       Begin VB.Menu mnuLine 
  146.          Caption         =   "-"
  147.       End
  148.       Begin VB.Menu mnuExit 
  149.          Caption         =   "Exit"
  150.       End
  151.    End
  152.    Begin VB.Menu mnuTools 
  153.       Caption         =   "Tools"
  154.       Begin VB.Menu mnuNewRegion 
  155.          Caption         =   "New Region"
  156.       End
  157.       Begin VB.Menu mnuGetHTML 
  158.          Caption         =   "Get HTML code"
  159.       End
  160.    End
  161.    Begin VB.Menu mnuHelp 
  162.       Caption         =   "Help"
  163.    End
  164. Attribute VB_Name = "frmMain"
  165. Attribute VB_GlobalNameSpace = False
  166. Attribute VB_Creatable = False
  167. Attribute VB_PredeclaredId = True
  168. Attribute VB_Exposed = False
  169. 'Image Map Maker
  170. 'by Theo Kandiliotis ionikh@hol.gr
  171. 'Built as an entry for Visual Basic Explorer's
  172. 'June contest.
  173. '(http://www.vbexplorer.com/)
  174. 'The coordinates of the point where the user
  175. 'clicks when starting a new region.
  176. Dim StartX, StartY As Integer
  177. 'Determines if a region is being drawn
  178. Public DrawRegion As Boolean
  179. 'Used with StartX,StartY these coordinates determine
  180. 'a new rectangular region
  181. Dim LastX, LastY As Integer
  182. 'Determines if the user is about to draw a new region
  183. Dim NewRegion As Boolean
  184. 'An integer used in a little animation effect
  185. 'that makes sure that the regions already drawn
  186. 'show up well on pictures of all colors
  187. Dim Col As Integer
  188. Private Sub mnuExit_Click()
  189. For Each frm In Forms
  190. Unload frm
  191. End Sub
  192. Private Sub mnuGetHTML_Click()
  193. 'If the user hasn't drawn any regions,then there's
  194. 'no HTML to generate
  195. If NofRegions = 0 Then Exit Sub
  196. 'Input a name for the <MAP NAME= tag
  197. mapname = InputBox("Give a name for the image map: " & vbCrLf & "(for the <MAP NAME=" & Chr(34) & "..." & Chr(34) & "> tag)", "Image map name")
  198. If Trim(mapname) = "" Then Beep: Exit Sub
  199. 'Generate the HTML code
  200. HTML = "<!-- Image map HTML code created with  I m a g e   M a p   M a k e r  by Theodore Kandiliotis , ionikh@hol.gr , http://www.geocities.com/SiliconValley/Network/5045  -->" & vbCrLf & _
  201. "<MAP NAME=" & Chr(34) & mapname & Chr(34) & ">" & vbcrlr
  202. For i = 1 To NofRegions
  203. HTML = HTML & vbCrLf & "<AREA SHAPE=" & Chr(34) & "RECT" & Chr(34) & _
  204. " COORDS=" & Chr(34)
  205. For ii = 1 To 4
  206. HTML = HTML & Region(i, ii)
  207. If ii <> 4 Then HTML = HTML & ","
  208. HTML = HTML & Chr(34) & " HREF=" & Chr(34) & Region(i, 5) & Chr(34) & _
  209. " FRAME=" & Chr(34) & Region(i, 6) & Chr(34) & ">"
  210. HTML = HTML & vbCrLf & "<IMG SRC=" & Chr(34) & dlgOpen.FileTitle & Chr(34) & " USEMAP=" & Chr(34) & "#" & mapname & Chr(34) & " BORDER=" & Chr(34) & "0" & Chr(34) & ">" & vbCrLf
  211. HTML = HTML & "</MAP>" & vbCrLf & "<!-- End of Image map HTML code created with  I m a g e   M a p   M a k e r -->"
  212. 'Show the HTML code
  213. frmHTML.txtHTML = HTML
  214. frmHTML.txtHTML.Visible = True
  215. frmHTML.Show vbModal
  216. End Sub
  217. Private Sub mnuHelp_Click()
  218. 'Show the help file
  219. ChDir App.Path
  220. Shell "NOTEPAD Read_Me.TXT", vbNormalFocus
  221. End Sub
  222. Private Sub mnuNewImageMap_Click()
  223. 'Ininialize everything for a new image map
  224. NofRegions = 0
  225. 'Hide the scrollbars
  226. vsb1.Visible = False
  227. hsb1.Visible = False
  228. On Error GoTo ErrorHandler
  229. 'Allow the user to select an image
  230. dlgOpen.ShowOpen
  231. picImage.Cls
  232. picImage.Picture = LoadPicture(dlgOpen.filename)
  233. 'Check if the scrollbars should be shown
  234. If picImage.Width > picContainer.Width Then
  235. hsb1.Max = picImage.Width
  236. hsb1.Visible = True
  237. End If
  238. If picImage.Height > picContainer.Height Then
  239. vsb1.Max = picImage.Height
  240. vsb1.Visible = True
  241. End If
  242. 'Show the image so that the user can start
  243. 'drawing the regions
  244. picImage.Visible = True
  245. ErrorHandler:
  246. Exit Sub
  247. End Sub
  248. Private Sub mnuNewRegion_Click()
  249. 'Initialize things for a new clickable region
  250. 'on the current image map
  251. NewRegion = True
  252. 'Show the scrolling message
  253. lblScroller.Caption = "Click on the spot where you want the upper-left edge of the region to be . Then move the mouse and click on the lower-right edge."
  254. picScroller.Width = lblScroller.Width
  255. picScroller.Left = picContainScroller.ScaleWidth
  256. Timer1.Enabled = True
  257. picContainScroller.Visible = True
  258. End Sub
  259. Private Sub picImage_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  260. 'If the user is currently drawing a new region...
  261. Select Case DrawRegion
  262.  Case True
  263.  If NewRegion = False Then Exit Sub
  264. '...draw a rectangular that moves along with
  265. 'the mouse pointer...
  266.  picImage.PaintPicture picImage.Picture, 0, 0
  267.  picImage.Line (StartX, StartY)-(X, Y), , B
  268. '...and show the coordinates in a the label on the
  269. 'bottom of the form
  270.  coordinates = "(" & StartX & "," & StartY & ") - (" & picImage.CurrentX & "," & picImage.CurrentY & ")"
  271.  Label1.Caption = coordinates
  272. End Select
  273. End Sub
  274. Private Sub picImage_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  275. 'If the user hasn't clicked NEW REGION from the menu,
  276. 'then he can't start a new region
  277. If NewRegion = False Then Exit Sub
  278. 'Check if the user has already determined one of
  279. 'the two edges of the rectangular region
  280. Select Case DrawRegion
  281. 'If not,the pixel where this MouseDown event
  282. 'fired ,will be the first of the two pixels that will
  283. 'determine the new rectangular region
  284. Case False
  285. StartX = X
  286. StartY = Y
  287. DrawRegion = True
  288. Case True
  289. 'If he has,then the pixel where this event fired,
  290. 'settles the rectangular region,so now the user
  291. 'has to input information for the other arguments
  292. 'of the <AREA SHAPE="rect" COORDS="xx,xx,xx,xx" tag:
  293. '1.the URL where the clickable region will lead to
  294. '2.the frame where the new HTML file will load in
  295. DrawRegion = False
  296. lblScroller.Caption = ""
  297. Timer1.Enabled = False
  298. NofRegions = NofRegions + 1
  299. Region(NofRegions, 1) = StartX
  300. Region(NofRegions, 2) = StartY
  301. Region(NofRegions, 3) = X
  302. Region(NofRegions, 4) = Y
  303. 'Show the form where the rest of the information
  304. 'is inputed
  305. frmSettings.Show vbModal
  306. NewRegion = False
  307. End Select
  308. End Sub
  309. Private Sub Timer1_Timer()
  310. 'Scroll the message
  311. picScroller.Left = picScroller.Left - 1
  312. If picScroller.Left = 0 Then picScroller.Left = picContainScroller.ScaleWidth
  313. End Sub
  314. Private Sub Timer2_Timer()
  315. 'If there are any regions draw,change their color
  316. 'gradually ,from white to black.
  317. 'This is done to make sure that they are visible
  318. 'on every picture,with either dark or light colors
  319. If NofRegions = 0 Then Exit Sub
  320. Col = Col + 1
  321. If Col = 7 Then Col = 0
  322. Select Case Col
  323. Case 1
  324. Coll = &HFFFFFF
  325. Case 2
  326. Coll = &HE0E0E0
  327. Case 3
  328. Coll = &HC0C0C0
  329. Case 4
  330. Coll = &H808080
  331. Case 5
  332. Coll = &H404040
  333. Case 6
  334. Coll = vbBlack
  335. End Select
  336. For i = 1 To NofRegions
  337. picImage.Line (Region(i, 1), Region(i, 2))-(Region(i, 3), Region(i, 4)), Coll, B
  338. End Sub
  339. Private Sub hsb1_Change()
  340. 'Scroll the image horizontally
  341. hsb1_Scroll
  342. End Sub
  343. Private Sub hsb1_Scroll()
  344. 'Scroll the image vertically
  345. picImage.Left = -hsb1.Value
  346. End Sub
  347. Private Sub vsb1_Change()
  348. 'Scroll the image vertically
  349. vsb1_Scroll
  350. End Sub
  351. Private Sub vsb1_Scroll()
  352. 'Scroll the image vertically
  353. picImage.Top = -vsb1.Value
  354. End Sub
  355.