Excel - boton minimizar userform

 
Vista:

boton minimizar userform

Publicado por Haver (149 intervenciones) el 03/01/2007 23:23:01
como coloco un boton de minimizar o maximizar en un userform? porque por lo general solo tiene el de cerrar...
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:boton minimizar userform

Publicado por JuanC (792 intervenciones) el 03/01/2007 23:58:56
Hay que recurrir a las API de Windows
Hace bastante que no lo uso asi que fijate si funciona bien...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Option Explicit
 
Private Declare Function apiGetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function apiSetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function apiDrawMenuBar Lib "user32" Alias "DrawMenuBar" (ByVal hWnd As Long) As Long
Private Declare Function apiFindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function apiGetSystemMenu Lib "user32" Alias "GetSystemMenu" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function apiModifyMenu Lib "user32" Alias "ModifyMenuA" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpString As Any) As Long
 
Private Const MF_BYCOMMAND = &H0&
Private Const MF_ENABLED = &H0&
Private Const MF_GRAYED = &H1&
Private Const SC_CLOSE = &HF060&
 
Private Const GWL_EXSTYLE = (-20)
Private Const GWL_STYLE As Long = (-16)
 
Private Const WS_EX_APPWINDOW = &H40000
Private Const WS_SYSMENU As Long = &H80000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const WS_POPUP As Long = &H80000000
Private Const WS_THICKFRAME = &H40000
 
Public Sub ModificarVentana(frm As Object, bMinimizar As Boolean, bMaximizar As Boolean, bCerrar As Boolean, bReDimensionable As Boolean)
Dim hWnd&, hMenu&
Dim lStyle&
On Error Resume Next
hWnd = apiFindWindow(vbNullString, frm.Caption)
 
If Not bCerrar Then
   hMenu = apiGetSystemMenu(hWnd, 0)
   apiModifyMenu hMenu, SC_CLOSE, MF_BYCOMMAND Or MF_GRAYED, -10, "Close"
End If
 
lStyle = apiGetWindowLong(hWnd, GWL_STYLE)
 
lStyle = lStyle Or WS_SYSMENU
If bMinimizar Then lStyle = lStyle Or WS_MINIMIZEBOX
If bMaximizar Then lStyle = lStyle Or WS_MAXIMIZEBOX
If bReDimensionable Then lStyle = lStyle Or WS_THICKFRAME
lStyle = lStyle Or WS_POPUP
 
apiSetWindowLong hWnd, GWL_STYLE, (lStyle)
 
lStyle = apiGetWindowLong(hWnd, GWL_EXSTYLE)
lStyle = lStyle Or WS_EX_APPWINDOW
 
apiSetWindowLong hWnd, GWL_EXSTYLE, lStyle
apiDrawMenuBar hWnd
End Sub

Saludos desde Baires, JuanC
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:boton minimizar userform

Publicado por Manu (1 intervención) el 20/01/2007 13:40:56
Hola,

En mi caso no quiero colocar los botones de minimizar y de maximizar sino que cuando arranque el userform se haga del tamaño de la pantalla directamente, como lo podria conseguir??.

Gracias y un saludo.
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:boton minimizar userform

Publicado por EFREN (1 intervención) el 29/04/2008 16:35:49
¿Como minimzar un userform en VBA de excel?
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:boton minimizar userform

Publicado por aqui (1 intervención) el 22/01/2019 02:12:13
1
2
3
4
5
Private Sub UserForm_Initialize()
    Application.WindowState = xlMaximized
    Me.Width = Application.Width
    Me.Height = Application.Height
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:boton minimizar userform

Publicado por MANUEL (1 intervención) el 03/10/2008 22:31:41
BUENO ENCIAME UN MENSAJE A MI CORREO Y TE MANDO UN USERFORMS CON UN USERFORMS MAXMIZADO Y MINIMIZADO
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