Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15136

[RESOLVED] Drag textbox Fails after .scale

$
0
0
Hello,

Trying to do a simple drag OBJ scenario, which works fine on initial startup.
However, the back Container (picture1.scale) is changed, then dragging becomes pretty much useless.

Any ideas?

3 Controls required:
-Needs a picture box (picture1)
-Needs a textbox inside the picture box (text1)
-Needs a button (button1)


Code:

Option Explicit

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long


Private Sub Command1_Click()
Picture1.Scale (0, 0)-(600, Picture1.Height)
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not Button = 1 Then Exit Sub

    Static OldMousePos As POINTAPI
    Dim MousePos As POINTAPI
    GetCursorPos MousePos
    Debug.Print Picture1.Width, Picture1.ScaleWidth
    If MousePos.X = OldMousePos.X And MousePos.Y = OldMousePos.Y Then Exit Sub
    OldMousePos = MousePos

    Text1.Left = X - Text1.Width / 2
    If Text1.Left < 0 Then Text1.Left = 0
    If Text1.Left + Text1.Width > Picture1.Width Then Text1.Left = Picture1.Width - Text1.Width
End Sub

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Form_MouseMove Button, Shift, X + Text1.Left, Y + Text1.Top
End Sub

Name:  drag.jpg
Views: 38
Size:  13.0 KB
Attached Images
  

Viewing all articles
Browse latest Browse all 15136

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>