elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Únete al Grupo Steam elhacker.NET


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP)
| | | |-+  Programación Visual Basic (Moderadores: LeandroA, seba123neo)
| | | | |-+  Redimensionar formularios sin borde
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Redimensionar formularios sin borde  (Leído 1,593 veces)
aaronduran2


Desconectado Desconectado

Mensajes: 790



Ver Perfil WWW
Redimensionar formularios sin borde
« en: 24 Agosto 2008, 00:11 am »

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.


En línea

LeandroA
Moderador
***
Desconectado Desconectado

Mensajes: 760


www.leandroascierto.com


Ver Perfil WWW
Re: Redimensionar formularios sin borde
« Respuesta #1 en: 24 Agosto 2008, 00:37 am »

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
Código:
'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
Código:
Option Explicit
Dim cSizeForm As New SizeForm

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

Saludos


En línea

aaronduran2


Desconectado Desconectado

Mensajes: 790



Ver Perfil WWW
Re: Redimensionar formularios sin borde
« Respuesta #2 en: 24 Agosto 2008, 18:22 pm »

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.
En línea

LeandroA
Moderador
***
Desconectado Desconectado

Mensajes: 760


www.leandroascierto.com


Ver Perfil WWW
Re: Redimensionar formularios sin borde
« Respuesta #3 en: 24 Agosto 2008, 22:36 pm »

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

En línea

aaronduran2


Desconectado Desconectado

Mensajes: 790



Ver Perfil WWW
Re: Redimensionar formularios sin borde
« Respuesta #4 en: 25 Agosto 2008, 16:29 pm »

OK, gracias por tu ayuda.

Saludos.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
borde de un div decorado...
Desarrollo Web
Kase 2 2,895 Último mensaje 15 Noviembre 2012, 09:28 am
por Kase
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines