Most of the developers came across this particular limitation i.e. minimize and maximize buttons in VBA forms.
These buttons are by default available in Visual Basic forms i.e.; in design view of form we can locate appropriate properties for these buttons. But while designing VBA forms these properties are not available and the buttons doesn’t appear on the form.New Stuff: How to set default reserved quantity in Sage 300 ERP
In order to add these missing buttons kindly follow below code snippets.
Step 1: Variable declaration in the main module file.
<SNIP >
Public Const WS_MINIMIZEBOX = &H20000
Public Const WS_MAXIMIZEBOX = &H10000
Public Const SWP_FRAMECHANGED = &H20
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const GWL_STYLE = (-16)
Public Declare Function GetActiveWindow Lib “user32.dll” () As Long
Public Declare Function GetWindowLong Lib “user32” _
Alias “GetWindowLongA” _
(ByVal hwnd As Long, _
ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib “user32” _
Alias “SetWindowLongA” _
(ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Public Declare Function SetWindowPos Lib “user32” _
(ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long) As Long
</SNIP >
Now let’s add the buttons to the form.
Step 2: Define method “AppAddMinimizeMaximizeButton” in the user form.
<SNIP>
Private Sub AppAddMinimizeMaximizeButton(p_str_Minimize_Maximize_Box As String)
Dim hwnd As Long
hwnd = GetActiveWindow
Call SetWindowLong(hwnd, GWL_STYLE, _
GetWindowLong(hwnd, GWL_STYLE) Or _
p_str_Minimize_Maximize_Box)
Call SetWindowPos(hwnd, 0, 0, 0, 0, 0, _
SWP_FRAMECHANGED Or _
SWP_NOMOVE Or _
SWP_NOSIZE)
End Sub
</SNIP>
Step 3: On form activation; call the method to add the buttons to the user form:
<SNIP>
Private Sub UserForm_Activate()
AppAddMinimizeMaximizeButton WS_MINIMIZEBOX AppAddMinimizeMaximizeButton WS_MAXIMIZEBOX
End Sub
</SNIP>
After execution you can notice the buttons has been added to the form.
Using above mentioned instructions minimize/maximize buttons can be added VBA forms (macro).
About Us
Greytrix a globally recognized Premier Sage Gold Development Partner is a one stop solution provider for Sage ERP and Sage CRM needs. Being recognized and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.
Greytrix offers unique GUMU™ integrated solutions of Sage 300 with Sage CRM, Salesforce.com and Magento eCommerce along with Sage 300 Migration from Sage 50 US, Sage 50 CA, Sage PRO, QuickBooks, Sage Business Vision and Sage Business Works. We also offer best-in-class Sage 300 customization and development services and integration service for applications such as POS | WMS | Payroll | Shipping System | Business Intelligence | eCommerce for Sage 300 ERP and in Sage 300c development services we offer services such as upgrades of older codes and screens to new web screens, newer integrations using sdata and web services to Sage business partners, end users and Sage PSG worldwide. Greytrix offers over 20+ Sage 300 productivity enhancing utilities that we can help you with such as GreyMatrix, Document Attachment, Document Numbering, Auto-Bank Reconciliation, Purchase Approval System, Three way PO matching, Bill of Lading and VAT for Middle East.
For more details on Sage 300 and 300c Services, please contact us at accpac@greytrix.com. We will be glad to assist you.