Solved

Maximise, minimise and close.

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

773 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