Maximaliseren beperken tot 1 formulier

Status
Niet open voor verdere reacties.

mindgame112

Gebruiker
Lid geworden
5 okt 2009
Berichten
61
Beste mensen hier ben ik weer,

Mijn vraag deze keer gaat over het maximaliseren van een formulier. Ik heb namelijk een hoofdformulier dat ik wil maximaliseren maar vanuit dat formulier kan ik ook meerdere andere formulieren openen maar die maximaliseert hij dan ook gelijk automatisch.

Ik heb nu dus in de form onload staan Docmd.Maximize maar dat past hij dus automatisch toe op alle formulieren die daarna geopend worden en dat heb ik dus liever niet.

Iemand een idee om daar iets aan te doen misschien?

Met vr. gr.

Sjoerd Redeker
 
i.p.v. maximaliseren kan je ook de randen van je beeldscherm opzoeken. Dan lijkt je form gemaximaliseerd maar is het niet. Het volgende form opent dan niet meer gemaximaliseerd.
 
Hier is een beetje code om duidelijk te maken wat ik bedoel.
Stop de code in een module en run MaximizeRestoredForm
Maximaliseer het form binnen Access:
Code:
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

'Type the following procedure:
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)
    RetVal = ShowWindow(F.Hwnd, SW_SHOWNORMAL)
    
End Sub
Voorbeeld
Code:
Private Sub Form_Load()
    MaximizeRestoredForm Me
End Sub
Enjoy!
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan