Visual Basic - Mover TextBox

Life is soft - evento anual de software empresarial
 
Vista:

Mover TextBox

Publicado por BISTECK (1 intervención) el 15/01/2005 00:34:07
Hola

Señores, quisiera saber cómo mover un textbox de posición con eso de Arrastrar y Soltar

Alguien me podría decir como hacerlo? no doy con la solución

Muchas gracias compadres
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Mover TextBox

Publicado por miguel (1042 intervenciones) el 17/01/2005 18:51:25
Aqui vienen ejemplos:
http://vbasic.astalaweb.com/Drag%20&%20Drop/1_Drag%20&%20Drop.asp
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Mover TextBox...Ejemplo!!!

Publicado por miguel (1042 intervenciones) el 17/01/2005 18:57:42
Ejemplo:
Dim oldX As Long, oldY As Long, isMoving As Boolean

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
oldX = X
oldY = Y
isMoving = True
End Sub

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If isMoving Then
Text1.Top = Text1.Top - (oldY - Y)
Text1.Left = Text1.Left - (oldX - X)
End If
End Sub

Private Sub Text1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
isMoving = False
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Mover TextBox...Ejemplo!!!

Publicado por Benjo (679 intervenciones) el 17/01/2005 21:10:42
La única diferencia con el ejemplo amterior es que se utilizan las API de Win32.

'En un Form va pegado el siguiente codigo
'Crea un TextBox
Option Explicit
Private Sub DragIt(ByVal lngHwnd As Long)
Dim lngReturn As Long
lngReturn = ReleaseCapture()
lngReturn = SendMessage(lngHwnd, WM_NCLBUTTONDOWN, HTCAPTION, CLng(0))
End Sub

Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
Call DragIt(Text1.hwnd)
End If
End Sub

`En un Módulo Bas
Option Explicit
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function ReleaseCapture Lib "user32" () As Long
Public Const WM_NCLBUTTONDOWN = &HA1
Public Const HTCAPTION = 2
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar