This is a reposting of an article I originally wrote on my Developing for Dynamics GP blog.
This article is another Support Debugging Tool Non-Logging Trigger example and is a follow up to two previous articles:
From Mark Polino: Dynamic Future – Vote – Resize the Left Pane on Smartlists
This example stores the size and position of the SmartList window using a very similar technique to the post from earlier this week. The main difference is that instead of storing a setting in the Dex.ini file, this time it uses a Support Debugging Tool Parameter. These Parameters are stored in the SY_User_Object_Store (SY90000) table, this is the same table that Visual Basic for Applications uses for the DUOS (Dynamic User Object Store).
The reason that the code uses the DUOS table instead of the a Dex.ini setting is so that it can handle being used in a terminal server or Citrix farm environment.
Below is the reasoning:
- If the setting was left as a Dex.ini setting, it would affect all users using the workstation and would not allow individual users to control the setting the way they wanted it. Each user can change the single setting and this will affect other users on that workstation.
- Also in a farm environment, the Dex.ini setting on each of the servers on the farm is a different file and so has different settings. This means that the setting would change based on the server accessed for a particular remote session and so there is very little chance of consistency.
- By using a Parameter stored the DUOS table, the setting is stored on a per user, per company basis and will follow the user regardless of the physical workstation or server being used.
The other big difference with this example is the enhancement to allow control of the size of the left hand (TreeView) and right hand (ListView) panes of the SmartList window. As mentioned in Mark’s post, when the window is resized the size of the left pane increases to a point where it is much larger than required and is wasting a huge amount of screen real estate.
With this customisation, the size of the left pane can be set as a percentage of the total window size ranging from 5% to 95%. I have found that a value of 10% or 15% works well.
- To change the size of the left hand pane of the SmartList window, from the Additional menu, use the option “Change size of SmartList Window left hand pane”. This will display the current percentage ratio value for the left hand pane and allow you to change it.
- When the window is resized after the left hand pane has been made smaller, it is possible for the left hand pane to disappear entirely. If this happens, either use the menu option to re-select the size you want, or click on another window and then click back on SmartList window for the previously set ratio to be re-applied.
- The position information is relative to the Microsoft Dynamics GP main application window and so can show negative figures when the window was last positioned higher than or left of the main window.
The example uses four Trigger IDs:
This trigger captures the size and position information of the window and the percentage ratio of the left hand TreeView pane just before it closes and writes this information into DUOS table as the Parameter Win_SmartList.
This trigger reads the previously written Parameter and parses the line to size and position information. It then adjusts the SmartList window’s size and position just before it is opened.
This trigger adds the menu choice to the Additional Menu and allows the percentage ratio for the left hand pane of the SmartList window to be selected. Once a ratio is selected, the number of pixels needed to adjust the window fields by is calculated and the adjustments made. Also, the settings for the current size and position and percentage ratio are stored back into the Parameter.
This trigger works whenever the SmartList window gains focus. It reads the previously written Parameter and parses the left hand pane percentage ratio and then makes the appropriate adjustments to the window fields.
Use of the SMARTLIST_ACT trigger on the WindowActivate event was required as using the SMARTLIST_PRE on the Form Pre event was too early and the window field size changes did not take effect.
The Support Debugging Tool Debugger Settings file with these triggers is attached as an archive to the bottom of this post.
Please leave a comment if you find this example useful.
This article was originally posted on the Developing for Dynamics GP Blog and has been reposted on http://www.winthropdc.com/blog.