Redimensionar formularios sin borde

Iniciado por aaronduran2, 24 Agosto 2008, 00:11 AM

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

aaronduran2

Hola. Quisiera saber como redimensionar formularios que no tienen borde, ya que me hice una barra de título propia y lo malo es que necesito redimensionarlos.

Gracias de antemano.

LeandroA

hola te paso una clase sensilla que hice para un proyecto, para mis nesecidades estuvo bien ahora fijate si te sirve a vos.

Modulo Clase
Nombre =  SizeForm

'Name SizeForm
Option Explicit

Private Const WM_SYSCOMMAND = &H112&
Private Const MOUSE_MOVE = &HF012&
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
Private Declare Function ReleaseCapture Lib "user32.dll" () As Long

Const BorderSize = 6

Dim SizeMode As Long
Dim InPoint As Boolean
Private WithEvents Form As Form

Public MinWidth As Long
Public MaxWidth As Long
Public MinHeight As Long
Public MaxHeight As Long
Public HeatherHeight As Long

Function SetForm(frm As Form)
Set Form = frm
End Function

Private Sub Class_Initialize()
    MinWidth = 100
    MaxWidth = Screen.Width
    MinHeight = 40
    MaxHeight = Screen.Height
    HeatherHeight = 20
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 1 Then
    Select Case X
        Case Is > Form.ScaleWidth - BorderSize
            InPoint = True
            SizeMode = 1
        Case Is < BorderSize
            InPoint = True
            SizeMode = 4
    End Select
   
    Select Case Y
        Case Is > Form.ScaleHeight - BorderSize
            InPoint = True
            SizeMode = 2
        Case Is < BorderSize
            InPoint = True
            SizeMode = 3
    End Select
   
    If X > Form.ScaleWidth - BorderSize * 2 And Y > Form.ScaleHeight - BorderSize * 2 Then
        InPoint = True
        SizeMode = 5
    End If
   
    If Y < HeatherHeight + 3 And Y > BorderSize And Button = 1 And Not InPoint Then
        Call MoveForm
        Exit Sub
    End If

End If


End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)


If X > Form.ScaleWidth - BorderSize * 2 And Y > Form.ScaleHeight - BorderSize * 2 Then
    Form.MousePointer = 8
Else
    If X > Form.ScaleWidth - BorderSize Or X < BorderSize Then
        Form.MousePointer = 9
    Else
        If Y > Form.ScaleHeight - BorderSize Or Y < BorderSize Then
            Form.MousePointer = 7
        Else
            Form.MousePointer = 0
        End If
    End If
End If

If InPoint And Button = 1 Then

    Select Case SizeMode
        Case 1: If X > MinWidth And X < MaxWidth Then Form.Width = X * 15
        Case 2: If Y > MinHeight And Y < MaxHeight Then Form.Height = Y * 15
        Case 3
            If Form.ScaleHeight - Y > MinHeight And Form.ScaleHeight - Y < MaxHeight Then
                Form.Move Form.Left, Form.Top + Y * 15, Form.Width, Form.Height - Y * 15
            End If
        Case 4:
            If Form.ScaleWidth - X > MinWidth And Form.ScaleWidth - X < MaxWidth Then
                Form.Move Form.Left + X * 15, Form.Top, Form.Width - X * 15, Form.Height
            End If
        Case 5
            If X > MinWidth And X < MaxWidth Then Form.Width = X * 15
            If Y > MinHeight And Y < MaxHeight Then Form.Height = Y * 15
    End Select
   

End If
End Sub

Public Sub MoveForm()
    Form.MousePointer = 0
    ReleaseCapture
    SendMessage Form.hwnd, WM_SYSCOMMAND, MOUSE_MOVE, 0
End Sub


Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    InPoint = False
End Sub


y en el formulario

Option Explicit
Dim cSizeForm As New SizeForm

Private Sub Form_Load()
    Me.ScaleMode = 3
    cSizeForm.SetForm Me
End Sub


Saludos

aaronduran2

Gracias LeandroA, el ejemplo funciona bien. ¿Pero no se podría poner en escala normal y no en píxel? Lo digo porque sería muy tedioso cambiar todos los valores que tengo en mi programa.

Gracias y saludos.

LeandroA

hola cambia donde dice x* 15 por x   andoede dice y * 15 por y

Const BorderSize = 60

y

HeatherHeight = 300

y bueno masomenos con eso esta


aaronduran2