Why can't I maximize my window?

David Meego - Click for blog homepageA recent support case asked "Why can't I maximise my Payable Transaction Entry Distribution window?".  This worked for versions 8.0 and 9.0 but does not work for version 10.0 and GP 2010 (v11.0).  What has changed?

Everything. Well ... lots in the way windows in the Microsoft Dynamics GP application are handled.

When version 10.0 was released the interface was changed from MDI (Multiple Document Interface) to SDI (Single Document Interface). See the post Version 10.0 and its individual windows for more information. As part of this change, the way in which windows can be sized was changed.

Quick theory bit: In Dexterity, a window can be set to size automatically or the developer can control how the fields behave when a window is expanded. Most windows in the application are set to size automatically, unless the developer wanted to specifically control the way the window resizes. So looking at automatic mode: Standard fields do not resize; scrolling windows can only resize vertically; and listboxes, treeviews & listviews can resize vertically and horizontally.

So, what does this mean? Here is a quick summary:

  • A window with only standard fields will not benefit from resizing at all. This type of window cannot be resized or maximized.
  • A window with only standard fields and scrolling windows will only benefit from resizing vertically.  This type of window can be resized vertically (and before v10.0 it could be maximized).
  • A window which has listbox, treeview or listview fields will benefit from resizing vertically and horizontally. This type of window can be resized vertically and horizontally or maximized.

I have highlighted above the behavior that has changed since v10.0.  The reason is because when we resize a window in a direction that has no benefit it just creates white space (a blank area) on the window. For example, below is a screenshot of the Payables Transaction Entry Distribution window maximized in v9.0.  Note how more than half the screen is white space.

To avoid the creation of white space, version 10.0 onwards will only allow a window that is resizable in both directions to be maximized.   So in our case, the bottom edge of the Payables Transaction Entry Distribution window can be dragged down to show just as many lines in the scrolling window, but we can no longer maximize the window to fill most of the screen with "nothing".

In the example screenshot from GP 2010 below, you will see that this has the added benefit of still be able to see the main transaction window as well as the expanded distribution window.

I hope this explains why the change was made.

So, if you are the sort of user who likes to maximise windows as soon as you open them (and your site is registered for Modifier & VBA), wouldn't be nicer if GP would remember the size and position of the windows based on just how you like them.  The next section explains how to make this happen. 


Back in July 2008, I published an example post which showed how to use Visual Basic for Applications (VBA) to remember a window's size and position.  This post, VBA - Screen Size and Position Example used the Purchase Order Entry window for the example. Also see Support Debugging Tool examples in links below.

As the code for this quick customisation is generic (IE. works with any window), I decided to provide step by step instructions of how to add the code to any window in any product.

  1. Open the window you want to remember its size and position.
  2. Select Tools >> Customize >> Add Current Window to Visual Basic.
  3. Select Tools >> Customize >> Visual Basic Editor.
  4. Locate the window in the Project List, expand the appropriate Dictionary Module find the window.
  5. Double click on the window (not the grids if there are scrolling windows).
  6. Copy the code below to the clipboard. (Use Ctrl-A to select all.)
  7. Paste from the clipboard into the editor window.
  8. Select Debug >> Compile <Module Name> .
  9. Select File >> Save <Module Name> .
  10. Close the Visual Basic Editor.

Code to remember window size and position using DUOS to store data

Option Explicit

Dim WindowCollection As DUOSObjects
Dim WindowObject As DUOSObject

Private Sub Window_AfterClose()
    Set WindowCollection = DUOSObjectsGet("Window." & UCase(UserInfoGet.UserID))
    Set WindowObject = WindowCollection.Item(Me.Caption)
    WindowObject.Properties("Left") = Str(Me.Left)
    WindowObject.Properties("Top") = Str(Me.Top)
    WindowObject.Properties("Height") = Str(Me.Height)
    WindowObject.Properties("Width") = Str(Me.Width)
End Sub

Private Sub Window_BeforeOpen(OpenVisible As Boolean)
    Set WindowCollection = DUOSObjectsGet("Window." & UCase(UserInfoGet.UserID))
    Set WindowObject = WindowCollection.Item(Me.Caption)
    If Val(WindowObject.Properties("Height")) > 0 And Val(WindowObject.Properties("Width")) > 0 Then
        Me.Left = Val(WindowObject.Properties("Left"))
        Me.Top = Val(WindowObject.Properties("Top"))
        Me.Height = Val(WindowObject.Properties("Height"))
        Me.Width = Val(WindowObject.Properties("Width"))
    End If
End Sub

 

Note: The code above is valid for v10.0 and later only, as it is using the UserInfoGet object to retrieve the current User ID.

Now every time the window is closed, it will store its size and position into the DUOS (Dynamic User Object Store) table. When the window is re-opened, the data is read back and the windows size and position is restored accordingly.

 

For some related window size and position posts, see the following articles:

Hope you find this information and example code useful. 

David

// Copyright © Microsoft Corporation. All Rights Reserved.
// This code released under the terms of the
// Microsoft Public License (MS-PL, https://opensource.org/licenses/ms-pl.html.)

09-Oct-2013: Added links to related articles.