Solved

Easy...  Close "X" diable...

Posted on 2003-11-03
3
197 Views
Last Modified: 2010-05-01
Hello, im trying to 'grayout' to disable the X button at the top of a child form in a mdi form, not sure if its diffrent than just any regular form, but if you can' please provide some source.

Thanks...
0
Comment
Question by:dawnyd01
3 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 9673376
An MDI form is the same as a regular form with the MDICild property set to true.  You should be able to gray out the X button in the same matter .Borderstyle = None should remove Min, Max and "X".
0
 
LVL 28

Assisted Solution

by:vinnyd79
vinnyd79 earned 25 total points
ID: 9674678
Give this a try:

Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Const MF_BYPOSITION = &H400&
Private Const MF_DISABLED = &H2&

Private Sub DisableX(frm As Form)
Dim hMenu As Long, nCount As Long

'Get handle to system menu
hMenu = GetSystemMenu(frm.hwnd, 0)

'Get number of items in menu
nCount = GetMenuItemCount(hMenu)

'Remove last item from system menu (last item is 'Close')
Call RemoveMenu(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)

'Redraw menu
DrawMenuBar frm.hwnd
End Sub

' usage
Private Sub Form_Load()
DisableX Form1
End Sub
0
 
LVL 8

Accepted Solution

by:
harris_c earned 25 total points
ID: 9675524
Private Declare Function GetSystemMenu Lib "User32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long

Const MF_BYPOSITION = &H400

Private Sub MDIForm_Load()
    'first mdi child
    Form1.Show
    RemoveMenu GetSystemMenu(Form1.hWnd, 0), 6, MF_BYPOSITION
   
    'second mdi child
    Form2.Show
    RemoveMenu GetSystemMenu(Form2.hWnd, 0), 6, MF_BYPOSITION
   
    'need to refresh somehow
    Me.Arrange (2)
End Sub
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

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…
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…
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…

685 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