Solved

Maximise, minimise and close.

Posted on 2003-10-31
4
174 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

756 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