Sage 300 -Allowing Only Minimize Box on Customized OCX

By | December 1, 2017

Sage 300 classic desktop provides various user interfaces i.e. screens which are basically OCX files i.e. “ActiveX Control Objects”. The entry screens generally has windows maximize and minimize buttons but for Report user interfaces or those user interfaces on which no tabular data or grid present the maximize button might been disabled. While customizing these Sage 300 user interfaces on which maximize button is disabled, developers may face the difficulty to achieve the same effect on customized OCX. In this blog we are going to discuss simple code changes to be done in the standard code to achieve the same.

New Stuff: Migrate AP Payments from Sage Pro to Sage 300 ERP

The visibility of maximize and minimize buttons for the Accpac user interface container’s is depend on the global declarations done while creating any OCX i.e. depend on the value (True / False) set for the “ACCPACUIResizable” Property.

If this has been set to “True” then both Minimize and Maximize buttons are visible and if it is set as “False” both Maximize and Minimize buttons will not appear.
To make only Minimize button visible on Accpac UI below code changes can be done:

  1. In the module “ACCPACUIGlobals” in general declarations set the “ACCPACUIResizable” property to false.

“Public Const ACCPACUIResizable As Boolean = False”
2. In the user control code in “SaveUISize()” subroutine make the changes enclosed under “’B-GT… ‘E-GT’” below
Private Sub SaveUISize()
On Error Resume Next
Dim lParentHwnd As Long
Dim bMaximized As Boolean
Dim bMinimized As Boolean
‘ Find the top-level parent window (doesn’t ‘ include owner, i.e. caller, windows).
lParentHwnd = GetAncestor(UserControl.hWnd, _GA_ROOT)
If Err.Number = 0 Then
‘B-GT-Commented code line and added code for maximizing button disabling
‘bMaximized = CBool(IsZoomed(lParentHwnd))
bMaximized = False
‘E-GT-Commented code line and added code for maximizing button disabling
bMinimized = CBool(IsIconic(lParentHwnd))
‘ The parent doesn’t have an Hwnd, so assume
‘ it is not maximized or minimized.
bMaximized = False
‘B-GT-Commented code line and added code for maximizing button disabling
‘bMinimized = False
bMinimized = True
‘E-GT-Commented code line and added code for maximizing button disabling
Err.Clear ‘ this error is now handled
End If
If (bMaximized = True) Or (bMinimized = True) Then
‘ GET OUT! DON’T save the size, but DON’T
‘ clear the previous saved size either!
Exit Sub
End If
With mSession.GetAccpacProperty
.menuID = ACCPACProgramName
.objectID = ACCPACProgramName
‘ See if we need to save/clear the height.
.keyword = UIHEIGHT_KEY
If ScaleHeight <= msMinHeight Then
Dim strUIHeight As String
strUIHeight = CStr(ScaleHeight)
.PropPut CVar(strUIHeight), Len(strUIHeight)
End If
‘ See if we need to clear/save the width.
.keyword = UIWIDTH_KEY
If ScaleWidth <= msMinWidth Then
Dim strUIWidth As String
strUIWidth = CStr(ScaleWidth)
.PropPut CVar(strUIWidth), Len(strUIWidth)
End If
End With ‘ mSession.GetAccpacProperty
End Sub
The above changes will allow us to get the OCX user interface with only minimize and close button. Kindly refer to below customized user interface for the reference:

As you can see in the screenshot above the “Maximized” button is disabled for the customized OCX.