Problemas al maximizar
Publicado por isaac (23 intervenciones) el 26/02/2012 11:16:48
Hola,
Si al iniciar una base de datos le coloco el típico DoCmd.Maximize, me maximiza el formulario ocultando la barra de tareas (aún estando bloqueada), entonces encontre esta rutina en internet:
Private Sub Form_Load()
Call MaximizeRestoredForm(Me)
End Sub
Crear un modul amb aquest codi:
Option Compare Database
Option Explicit
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, _
ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Const SW_MAXIMIZE = 3
Const SW_SHOWNORMAL = 1
Sub MaximizeRestoredForm(F As Form)
Dim MDIRect As RECT
Dim RetVal As Long
' If the form is maximized, restore it.
If IsZoomed(F.hwnd) <> 0 Then
RetVal = ShowWindow(F.hwnd, SW_SHOWNORMAL)
End If
' Get the screen coordinates and window size of the
' MDIClient window.
RetVal = GetWindowRect(GetParent(F.hwnd), MDIRect)
' Move the form to the upper-left corner of the MDIClient
' window (0,0) and size it to the same size as the
' MDIClient window.
RetVal = MoveWindow(F.hwnd, 0, 0, MDIRect.Right - _
MDIRect.Left - 4, MDIRect.Bottom - MDIRect.Top - 4, True)
End Sub
que si maximiza sin ocultar la barra de tareas, pero quita los botones Minimizar y Maximizar, y eso no me gusta (Ya sé, soy un poco raro, todo el mundo pregunta como ocultarlas).
¿Podrias decirme si se puede quitar alguna parte de este código para que aparezcan los botones (he probado quitando líneas pero no lo he logrado) o si conoceis alguna otra manera de conseguirlo?
Como siempre, muchas gracias por todo
Si al iniciar una base de datos le coloco el típico DoCmd.Maximize, me maximiza el formulario ocultando la barra de tareas (aún estando bloqueada), entonces encontre esta rutina en internet:
Private Sub Form_Load()
Call MaximizeRestoredForm(Me)
End Sub
Crear un modul amb aquest codi:
Option Compare Database
Option Explicit
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Declare Function IsZoomed Lib "user32" (ByVal hwnd As Long) As Long
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, _
lpRect As RECT) As Long
Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, _
ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
ByVal nHeight As Long, ByVal bRepaint As Long) As Long
Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Const SW_MAXIMIZE = 3
Const SW_SHOWNORMAL = 1
Sub MaximizeRestoredForm(F As Form)
Dim MDIRect As RECT
Dim RetVal As Long
' If the form is maximized, restore it.
If IsZoomed(F.hwnd) <> 0 Then
RetVal = ShowWindow(F.hwnd, SW_SHOWNORMAL)
End If
' Get the screen coordinates and window size of the
' MDIClient window.
RetVal = GetWindowRect(GetParent(F.hwnd), MDIRect)
' Move the form to the upper-left corner of the MDIClient
' window (0,0) and size it to the same size as the
' MDIClient window.
RetVal = MoveWindow(F.hwnd, 0, 0, MDIRect.Right - _
MDIRect.Left - 4, MDIRect.Bottom - MDIRect.Top - 4, True)
End Sub
que si maximiza sin ocultar la barra de tareas, pero quita los botones Minimizar y Maximizar, y eso no me gusta (Ya sé, soy un poco raro, todo el mundo pregunta como ocultarlas).
¿Podrias decirme si se puede quitar alguna parte de este código para que aparezcan los botones (he probado quitando líneas pero no lo he logrado) o si conoceis alguna otra manera de conseguirlo?
Como siempre, muchas gracias por todo
Valora esta pregunta
0