Solved

Maximise, minimise and close.

Posted on 2003-10-31
4
170 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
  • 2
4 Comments
 
LVL 1

Expert Comment

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

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 85

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

746 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now