Screen and Picturebox X, Y relationship - Need Help
I have a Picturebox (ScaleMode = vbPixels) on a Form (ScaleMode = vbPixels) and at location 198, 207 in the Picturebox there is a dot. How do I figure this location to the screen's location? Also, how to figure screen coordinates to the picturebox coordinate of 198, 207?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Re: Screen and Picturebox X, Y relationship - Need Help
this website since the update is slow and stop responding!!! what the **** is wrong? anyways back to your question
i'm not exactly sure what you are asking but have a look at this
Code:
Private XX As Single
Private YY As Single
Private Sub Command1_Click()
Picture1.DrawWidth = 2
Picture1.Line (198, 207)-(198, 207), vbBlack
Screen.MousePointer = vbHourglass
For XX = 1 To Screen.Width
For YY = 1 To Screen.Height
DoEvents
If Picture1.Point(XX, YY) = vbBlack Then
MsgBox XX & " - " & YY
Screen.MousePointer = vbDefault
Exit Sub
End If
Next YY
Next XX
End Sub
Private Sub Command2_Click()
Dim ScreenX As Single
Dim ScreenY As Single
Picture1.BorderStyle = 0
ScreenX = Form1.Left / Screen.TwipsPerPixelX + Picture1.Left + XX
ScreenY = Form1.Top / Screen.TwipsPerPixelY + Picture1.Top + YY
MsgBox "Dot is Placed at." & vbNewLine & "ScreenX (Pixels): " & ScreenX & vbNewLine & "ScreenY (Pixels): " & ScreenY
Picture2.Move ScreenX - (Form1.Left / Screen.TwipsPerPixelX), ScreenY - (Form1.Top / Screen.TwipsPerPixelY), 1, 1
End Sub
click command1 to get coords from picturebox's black dot (takes a couple seconds)
click command2 to get coords from screens then use it to move picture2 position on top on picture1's dot position (to see if coords are right)