Solved

Maximise, minimise and close.

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

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

751 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