Autor Tema: Redimensionar controles en tiempo de ejecución  (Leído 2915 veces)

0 Usuarios y 1 Visitante están viendo este tema.

aedEric

  • Megabyte
  • ***
  • Mensajes: 211
  • Reputación: +20/-0
    • Ver Perfil
Redimensionar controles en tiempo de ejecución
« en: Abril 23, 2014, 03:31:42 pm »
Hola Foristas tengo la siguiente cuestión quiero mover y redimensionar controles labels en tiempo de ejecución con el mouse, ya llevo unos días y no logro poder solucionar mi duda alguien lo a realizado, si alguien de aqui tiene alguna sugerencia u opinión se lo voy agradecer eternamente gracias

nota: puedo mover una serie de controles sin nungun problema con el siguiente codigo estos estan sobre un control picture,

Código: [Seleccionar]
Dim Save_X As Single
Dim Save_Y As Single

Private Sub Label1_DragDrop(Index As Integer, Source As Control, X As Single, Y As Single) '==
Source.Move Label1(Index).Left + X - Save_X, Label1(Index).Top + Y - Save_Y
End Sub

Private Sub Label1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)'==
   Save_X = X
   Save_Y = Y
   Label1(Index).Drag 1
End Sub

Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1(Index).MousePointer = 5
End Sub

Private Sub Label1_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)'===
Label1(Index).Drag 2
End Sub

Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)'==
Source.Move X - Save_X, Y - Save_Y
End Sub


saludos desde México
No he fracasado. He encontrado 10000 soluciones que no funcionan.

seba123neo

  • Terabyte
  • *****
  • Mensajes: 763
  • Reputación: +88/-5
    • Ver Perfil
Re:Redimensionar controles en tiempo de ejecución
« Respuesta #1 en: Abril 23, 2014, 09:04:47 pm »
en este post:

Alguno conoce algun contro capaz de hacer esto

ahi puse un codigo para mover los controles y hasta te aparece la famosa flechita para redimensionar, el tema es que solo sirve para controles con al propiedad .Hwnd

aedEric

  • Megabyte
  • ***
  • Mensajes: 211
  • Reputación: +20/-0
    • Ver Perfil
Re:Redimensionar controles en tiempo de ejecución
« Respuesta #2 en: Abril 23, 2014, 10:48:14 pm »
Hola Seba123neo muchas gracias

fijate que esta yo utlizando esto con text y no con label pero voy a optar por tu clase mejor muchas gracias sebas


Código: [Seleccionar]
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" _
    (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, _
    ByVal X As Long, ByVal Y As Long, _
    ByVal cX As Long, ByVal cY As Long, ByVal wFlags As Long) As Long
Const GWL_STYLE = (-16)
Const WS_THICKFRAME = &H40000
'
Const SWP_DRAWFRAME = &H30
Const SWP_NOMOVE = &H2
Const SWP_NOSIZE = &H1
Const SWP_NOZORDER = &H4


Código: [Seleccionar]
Private Sub CambiarEstilo(queControl As Control)
    Dim Style As Long
   
    On Local Error Resume Next
   
    Style = GetWindowLong(queControl.hwnd, GWL_STYLE)
    If Err Then
        Err = 0
    Exit Sub
    End If
    Style = Style Or WS_THICKFRAME
    Style = SetWindowLong(queControl.hwnd, GWL_STYLE, Style)
    Style = SetWindowPos(queControl.hwnd, _
        Me.hwnd, 0, 0, 0, 0, SWP_NOZORDER Or _
        SWP_NOSIZE Or SWP_NOMOVE Or SWP_DRAWFRAME)

End Sub

saludos...

No he fracasado. He encontrado 10000 soluciones que no funcionan.