Solved

Maximise, minimise and close.

Posted on 2003-10-31
4
176 Views
Last Modified: 2010-05-03
Halo,

     I am wonder, is there a way to determine if the the maximise, minimise and/or close button is enabled.
0
Comment
Question by:homerWS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:JonGartzia
ID: 9657980
Form's properties MaxButton (true or false), MinButton (true or false).
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 20 total points
ID: 9658463
If your form has a control box then you have a close button.  It can be turned off however, using the following code.  You could, for instance, disable the close and max buttons, only allowing your form to minimize.

' In a Module:
' Disable "X" on window
Declare Function DrawMenuBar Lib "User32" (ByVal hWnd As _
  Long) As Long
Declare Function GetMenuItemCount Lib "User32" (ByVal hMenu _
  As Long) As Long
Declare Function GetSystemMenu Lib "User32" (ByVal hWnd As _
  Long, ByVal bRevert As Long) As Long
Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Long, _
  ByVal nPosition As Long, ByVal wFlags As Long) As Long

Public Const MF_BYPOSITION = &H400
Public Const MF_REMOVE = &H1000

' On the Form
Private Sub Form_Load()
    ' This will remove the Close menu option from the control box
    ' and disable the X button on the form.
    Dim hMenu As Long
    Dim lItemCount As Long
    hMenu = GetSystemMenu(Me.hWnd, 0)
    If hMenu Then
        lItemCount = GetMenuItemCount(hMenu)
        Call RemoveMenu(hMenu, lItemCount - 1, MF_REMOVE Or _
        MF_BYPOSITION)
        Call RemoveMenu(hMenu, lItemCount - 2, MF_REMOVE Or _
        MF_BYPOSITION)
        Call DrawMenuBar(Me.hWnd)
    End If
   
    ' How to tell if the Min/Max buttons are enabled
    Debug.Print "Min Button = " & Me.MinButton
    Debug.Print "Max Button = " & Me.MaxButton
End Sub
0
 

Author Comment

by:homerWS
ID: 9660009
Halo Idle_Mind,

     Is it possible to tell if the close button (X) is enable?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 9660889
If it is possible, it would have to been done through the API's.  I'm not sure how to do that however.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month3 days, 21 hours left to enroll

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question