Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2003-11-03
3
Medium Priority
?
207 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 100 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 100 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

Technology Partners: 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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…

782 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