blacklord
asked on
Coordinates of size changed boxes
Hi.. I have a problem about the coordinates of the form. I draw boxes which made of line objects. Every box is 5x5. When user click on them box fill with a red color. And I get the coordinates of the boxes when user click on them. But when I change the size of the boxes from 5x5 to 8x8, coordinates doenst match the bigger boxes. I couldnt find any any mathematical formula that gives me the new coordinates. Does any one have the same problem?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for your interest.. I figure out how to make it.
https://www.experts-exchange.com/questions/21111443/1-pixel-squares.html
If so, then is this what you are after?
Option Explicit
Private Const boxWidth = 8 ' <--- Just change the value here
Private Sub Form_Load()
Me.AutoRedraw = True
Me.ScaleMode = vbPixels
For i = 1 To Me.Width Step boxWidth
Me.Line (0, i)-(Me.Width, i), , BF
Next i
For i = 1 To Me.Height Step boxWidth
Me.Line (i, 1)-(i, Me.Height), , BF
Next i
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim cX As Integer, cY As Integer
Dim tmpX As Integer, tmpY As Integer
tmpX = Int(X / boxWidth) * boxWidth
tmpY = Int(Y / boxWidth) * boxWidth
cX = tmpX
cY = tmpY
Me.Line (cX, cY)-(cX + boxWidth, cY + boxWidth), vbRed, BF
End Sub
Regards,
Idle_Mind