Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: jorgelin95 en 18 Septiembre 2010, 20:27 pm



Título: [Ayuda] Form
Publicado por: jorgelin95 en 18 Septiembre 2010, 20:27 pm
Cómo hago para que el Form no se puede modificar el tamaño, es decir que no se expansible Gracias


Título: Re: [Ayuda] Form
Publicado por: raul338 en 18 Septiembre 2010, 20:34 pm
Cambia el BorderStyle por Fixed Dialog


Título: Re: [Ayuda] Form
Publicado por: Elemental Code en 20 Septiembre 2010, 16:05 pm
ahora si necesitas que sea maximizable pero que no lo puedas cambiar de tamaño
en el evento Form rezise pones algo asi

Código
  1. on error resume next
  2. me.height = X
  3. me.width = Y

X e Y son el alto y ancho respectivamente


Título: Re: [Ayuda] Form
Publicado por: Dessa en 26 Septiembre 2010, 13:38 pm
En Diseño es como te dice raul y si necesitas cambiar en ejecución se puede usar SetWindowLong (sirve tambien para formularios sin borde)

Código:
Option Explicit
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

Private Sub Form_Load()
  Command1.Caption = "FIXED"
  Command2.Caption = "SIZEABLE"
End Sub

Private Sub Command1_Click()
  Call SetWindowLong(Me.hwnd, &HFFF0, GetWindowLong(Me.hwnd, &HFFF0) And Not &H40000)
  Call SetWindowPos(Me.hwnd, &H0, &H0, &H0, &H0, &H0, &H20 Or &H2 Or &H4 Or &H1)
End Sub

Private Sub Command2_Click()
  Call SetWindowLong(Me.hwnd, &HFFF0, GetWindowLong(Me.hwnd, &HFFF0) Or &H40000)
  Call SetWindowPos(Me.hwnd, &H0, &H0, &H0, &H0, &H0, &H20 Or &H2 Or &H4 Or &H1)
End Sub






Título: Re: [Ayuda] Form
Publicado por: Psyke1 en 26 Septiembre 2010, 14:22 pm
Dessa porque no utilizas constantes?
Creo que quedaria mas claro :P

DoEvents! :P


Título: Re: [Ayuda] Form
Publicado por: Dessa en 26 Septiembre 2010, 16:24 pm
Ahí va con constantes, Psyke.

Código:

Option Explicit

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 Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_SIZEBOX = &H40000

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

Private Const SWP_FRAMECHANGED = &H20
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOZORDER = &H4
Private Const SWP_NOSIZE = &H1

Private Const SWP_REFRESH = SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOZORDER Or SWP_FRAMECHANGED

Private Sub Form_Load()
  Command1.Caption = "FIXED"
  Command2.Caption = "SIZEABLE"
End Sub

Private Sub Command1_Click()
  Dim lngstylo As Long
  lngstylo = GetWindowLong(Me.hwnd, GWL_STYLE) And Not WS_SIZEBOX
  Call SetWindowLong(Me.hwnd, GWL_STYLE, lngstylo)
  Call SetWindowPos(Me.hwnd, &H0, &H0, &H0, &H0, &H0, SWP_REFRESH)
End Sub

Private Sub Command2_Click()
  Dim lngstylo As Long
  lngstylo = GetWindowLong(Me.hwnd, GWL_STYLE) Or WS_SIZEBOX
  Call SetWindowLong(Me.hwnd, GWL_STYLE, lngstylo)
  Call SetWindowPos(Me.hwnd, &H0, &H0, &H0, &H0, &H0, SWP_REFRESH)
End Sub





Título: Re: [Ayuda] Form
Publicado por: seba123neo en 26 Septiembre 2010, 22:29 pm
ahora si necesitas que sea maximizable pero que no lo puedas cambiar de tamaño
en el evento Form rezise pones algo asi

Código
  1. on error resume next
  2. me.height = X
  3. me.width = Y

X e Y son el alto y ancho respectivamente

con ese codigo habria un horrible flickering del formulario, es mejor hacer un Hook a WM_GETMINMAXINFO

saludos.