Sometimes My Form Shows Up at Different Sizes (1 Viewer)

JMongi

Active member
Local time
Today, 08:02
Joined
Jan 6, 2021
Messages
802
I specify the size of the form on load. This parameters have not changed recently. However, without a seeming reason, sometimes the form shows up resized (all controls resized). I do have a VBA module that is for resizing forms, but it's not being used at the moment. So, I'm at a loss. Mainly because it's not consistent. If I was inadvertently calling resize code, or hooking into it somehow, it would do so every time. But, sometimes it does and sometimes it doesn't. It's confusing. I'm going to delete the module for the time being and see if that eliminates it. But, I wanted to post here to see if anyone had any ideas. Here is a sample of my form code.

Code:
Private Sub Form_Open(Cancel As Integer)

Dim Rt As Integer
Dim Dn As Integer
Dim Wd As Integer
Dim Ht As Integer
Me.Painting = False
'Position and Size in TWIPS, 1440 TWIPS per inch
Rt = OldFormLeft + 24
'Debug.Print Me.Name & " " & "Rt= " & Rt
Dn = OldFormTop + 372
'Debug.Print Me.Name & " " & "Dn= " & Dn
Wd = 10 * 1440
'Debug.Print Me.Name & " " & "Wd= " & Wd
Ht = 8.25 * 1440
'Debug.Print Me.Name & " " & "Ht= " & Ht

DoCmd.MoveSize Rt, Dn, Wd, Ht

Me.Painting = True

End Sub
Code:
Private Sub Form_Load()
On Error GoTo ErrHandler

Select Case Me.OpenArgs
    Case "AI_Show"  'show application interface
        DoCmd.Restore
       
    Case "AI_Hide"  'hide application interface
        Me.Painting = False
            'omit the ...Or WS_EX_APPWINDOW ...section to hide the taskbar icon
        SetWindowLong Me.hWnd, GWL_EXSTYLE, GetWindowLong(Me.hWnd, GWL_EXSTYLE) Or WS_EX_APPWINDOW
        ShowWindow Application.hWndAccessApp, SW_HIDE
        ShowWindow Me.hWnd, SW_SHOW
        Me.Painting = True

End Select

DeveloperMode = True

'Get current filename for display in footer
Dim AppFilenameVar As String
AppFilenameVar = Left(CurrentProject.Name, Len(CurrentProject.Name) - 6)

Exit Sub

ExitHandler:
Me.Painting = True 'To ensure painting is turned back on even with an error
Exit Sub

ErrHandler:
Call ErrProcessor  
Resume ExitHandler
   
End Sub

The Load Code is using Application UI hiding from @isladogs
 

Minty

AWF VIP
Local time
Today, 12:02
Joined
Jul 26, 2013
Messages
10,354
I can't see where OldFormLeft and OldFormTop are being set - so they must be Public variables or properties.
I suspect that is your problem.
 

JMongi

Active member
Local time
Today, 08:02
Joined
Jan 6, 2021
Messages
802
How would that affect the size of my form? They are set on the close of the previous form.

Code:
Private Sub Form_Close()
OldFormTop = Me.WindowTop
'Debug.Print Me.Name & " " & "OldFormTop on Close= " & OldFormTop
OldFormLeft = Me.WindowLeft
'Debug.Print Me.Name & " " & "OldFormLeft on Close= " & OldFormLeft
End Sub
 

JMongi

Active member
Local time
Today, 08:02
Joined
Jan 6, 2021
Messages
802
And just to clarify. This is in regards to the SCALED size of the form. No controls are being clipped or chopped off or squished. All relative positions remain intact. The whole form is scaled down, controls and all.

It will go many close and open cycles without issue, then crop up, stick around for awhile then disappear again. I thought I had some leftover code somewhere, but I just went through and standardized this code yesterday (thought that had fixed it) and it cropped up again this morning. Thus this post. I haven't had time to implement and test my module deletion yet. When I do, I will post here.
 

Users who are viewing this thread

Top Bottom