Im trying to zoom the picture after the option buttons have been clicked according to the corresponding crime and the circle function is called to map a circle at the a particular coordinate stored in the database.however, after zooming the circles get disappeared as the coordinates have now changed.im trying to resize picture in the picturebox ,so that even after zoom those coordinates are visible.
Option Explicit
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim r As ADODB.Recordset
Dim x As Double
Dim y As Double
Public Sub ZoomPicture(Picture1 As PictureBox, zoom As Double)
'Dim pic2zoom As StdPicture
'Set pic2zoom = Picture1.Image
'Picture2.Visible = True
'Picture2.Picture = Picture1.Picture
'Picture1.Visible = False
Picture1.AutoRedraw = True
'Picture2.AutoRedraw = True
With Picture1
.Width = .Width * zoom
.Height = .Height * zoom
.PaintPicture .Picture, 0, 0, .ScaleWidth, .ScaleHeight
End With
' Picture2.Picture = Picture1.Picture
' Picture1.Cls
' Picture1.Picture = Picture2.Picture
'
' Picture2.Cls
End Sub
Private Sub cmdzoomin_Click()
ZoomPicture Picture1, 1.1
'Dim pic2zoom As StdPicture
'Set pic2zoom = Picture1.Picture
'Picture1.Width = Picture1.Width * 2
'Picture1.Height = Picture1.Height * 2
'Picture1.PaintPicture pic2zoom, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
'Cls
'x = x*2
'y = Picture1.Height - 300
'Call crime(x * 2, y * 2)
'Picture1.Align
End Sub
Private Sub cmdzoomout_Click()
ZoomPicture Picture1, 0.9
End Sub
Private Sub Form_Load()
HScroll1.Max = Picture1.Width
VScroll1.Max = Picture1.Height
HScroll1.LargeChange = HScroll1.Max / 10
VScroll1.LargeChange = VScroll1.Max / 10
HScroll1.SmallChange = HScroll1.Max / 25
VScroll1.SmallChange = VScroll1.Max / 25
Set cn = New ADODB.Connection
cn.Open "DSN=tn;uid=root;database=tn"
Set rs = New ADODB.Recordset
Set r = New ADODB.Recordset
rs.Open "select *from place", cn, adOpenKeyset, adLockOptimistic, adCmdText
rs.Close
r.Open "select *from socn", cn, adOpenKeyset, adLockOptimistic, adCmdText
End Sub
Private Sub HScroll1_Change()
Picture1.Left = -HScroll1.Value
End Sub
Private Sub opt_crd_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'card fraud' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(0, 128, 255)
Picture1.FillStyle = vbFSSolid
' Picture1.Line (x, y)-(5 / 8, 5 / 8), , B
Picture1.Line (x, y)-(x + 20, y + 20), , B
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_cybrcrim_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'cyber crimes' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(0, 255, 128)
Picture1.FillStyle = vbFSSolid
' Picture1.Line (x, y)-(5 / 8, 5 / 8), , B
Picture1.Line (x, y)-(x + 13, y + 15), , B
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_decoit_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'decoit' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(0, 255, 0)
Picture1.FillStyle = vbFSSolid
Picture1.Circle (x, y), 7
rs.MoveNext
r.MoveNext
Wend
rs.Close
'opt_Click ("decoit")
End Sub
Private Sub opt_drugtr_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'drug trafficking' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(0, 255, 0)
Picture1.FillStyle = vbFSSolid
' Picture1.Line (x, y)-(5 / 8, 5 / 8), , B
Picture1.Circle (x, y), 7
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_eve_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'eve teasing' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(240, 240, 0)
Picture1.FillStyle = vbFSSolid
' Picture1.Line (x, y)-(5 / 8, 5 / 8), , B
Picture1.Line (x, y)-(x + 15, y + 15), , B
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_extortion_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'extortion' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(128, 0, 0)
Picture1.FillStyle = 0
Picture1.Line (x, y)-(x + 13, y + 15), , B
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_ftrafic_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'illegal firearms trafficking' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(255, 0, 0)
Picture1.FillStyle = vbFSSolid
Picture1.Circle (x, y), 7
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_htrafic_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'human trafficking' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(113, 198, 113)
Picture1.FillStyle = vbFSSolid
' Picture1.Line (x, y)-(5 / 8, 5 / 8), , B
Picture1.Circle (x, y), 10
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_kdnap_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'kidnapping' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(128, 0, 128)
'Picture1.FillStyle = 4
Picture1.FillStyle = 0
Picture1.Line (x, y)-(x + 13, y + 15), , B
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_monlondrng_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'money laundering' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(121, 121, 121)
Picture1.FillStyle = vbFSSolid
' Picture1.Line (x, y)-(5 / 8, 5 / 8), , B
Picture1.Line (x, y)-(x + 13, y + 15), , B
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_murder_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'murder' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(0, 0, 255)
Picture1.FillStyle = vbSolid
' Picture1.Line (x, y)-(5 / 8, 5 / 8), , B
Picture1.Circle (x, y), 7
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_propcrim_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'property crimes' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(116, 116, 186)
Picture1.FillStyle = vbFSSolid
' Picture1.Line (x, y)-(5 / 8, 5 / 8), , B
Picture1.Circle (x, y), 5
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_rape_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'rape' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(253, 82, 0)
Picture1.FillStyle = vbFSSolid
' Picture1.Line (x, y)-(5 / 8, 5 / 8), , B
Picture1.Line (x, y)-(x + 20, y + 20), , B
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub opt_robbery_Click()
Dim sql
sql = " select p.coox, p.cooy from place p, socn s where s.crime = 'robbery' and s. sc_o_c = p. place"
rs.Open sql, cn
'found = False
While Not rs.EOF
x = rs.Fields("coox").Value
y = rs.Fields("cooy").Value
Picture1.FillColor = RGB(255, 0, 0)
Picture1.FillStyle = vbFSSolid
Picture1.Circle (x, y), 7
rs.MoveNext
r.MoveNext
Wend
rs.Close
End Sub
Private Sub Picture1_resize()
' Resize the picture.
Picture1.Cls
Picture1.AutoRedraw = True
Picture1.PaintPicture Picture1.Picture, Picture1.ScaleWidth * 1.1, Picture1.ScaleHeight * 1.1
End Sub
Private Sub VScroll1_Change()
Picture1.Top = -VScroll1.Value
End Sub