Solved

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

Posted on 2003-11-03
3
201 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
[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
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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

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…
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 …
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 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…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

628 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