Developing for Dynamics GP

by David Musgrave (Perth, WA, Australia) and the Microsoft Dynamics GP Developer Support Team (Fargo, ND, USA)

Why can't I maximize my window?

Why can't I maximize my window?

  • Comments 6

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, http://opensource.org/licenses/ms-pl.html.)

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

  • Hi David,

    This is great. Thanks for sharing this code.

    I would like to ask one thing is ..

    Since you are aware that "Integration Assistant for Excel" is discontinued after GP 8 version. Which is very bad as we were using excel to upload General Journal to uploads large JV's.  We have used JV Upload template(Adupter) provided in "Integration Assistant for Excel" .

    Do you have any VBA code simillar to JV Upload adapter provided in IA for Excel? Or do you have any plan to desin such template in future?

    Regards,

    Santosh

  • Hi Santosh

    You should have been issued with keys for Integration Manager if you were registered for Integration Assistant for Excel.  You can use Integration Manager to perform your imports.

    You can also use macros and Word mail merge to import transactions.

    blogs.msdn.com/.../how-to-use-word-mail-merge-and-macros-to-import-data.aspx

    David

  • Posting from Mark Polino at DynamicAccounting.net

    msdynamicsgp.blogspot.com/.../why-can-i-maximize-my-window.html

  • Hi Dave,

    One of my client has two screens: primary 17" and secondary 22". He opens a program via Citrix on the primary screen and then drags it onto the secondary screen.

    The problem is that this application does not maximize or allows him to resize on the secondary screen. It can be resized on the primary screen with no issues; its just the secondary screen that this application won't move beyond the middle of the screen or resize or maximize.

    OS is 32 bit Win 7 enterprise. Thank you.

  • Priyesh,

    Hmmm good question and to be honest I'm not sure.

    I have 2 monitors (22 & 20 i think) and I can maximize a window such as Sales Transaction Entry (SOP Entry) on both just fine.

    I'm on Win7 Enterprise 64bit but not Citrix.

  • Hi David,

    What a great quick Tip!  This one is always a crowd pleaser.

    Leslie

Page 1 of 1 (6 items)
Comments Information

PLEASE READ BEFORE POSTING

Please only post comments relating to the topic of this page.

If you wish to ask a technical question, please use the links in the links section (scroll down, on right hand side) to ask on the Newsgroups or Forums. If you ask on the Newsgroups or Forums, others in the community can respond and the answers are available for everyone in the future.

Leave a Comment
  • Please add 5 and 7 and type the answer here:
  • Post