-
July 13th, 2007, 10:30 PM
#1
Disable Min,Max and X button in MDI child form
I want to disable min,max & X button in MDI child form. I try disable this in not MDI child from and its works but not in MDI child form. I get the code in codeguru web.
Please help.Thanks
-
July 13th, 2007, 11:46 PM
#2
Re: Disable Min,Max and X button in MDI child form
may you have to refresh form,
what is your code?
-
July 14th, 2007, 02:57 AM
#3
Re: Disable Min,Max and X button in MDI child form
the_magicien : You would need to use the following APIs :
GetSystemMenu
EnableMenuItem
-
July 15th, 2007, 05:36 AM
#4
Re: Disable Min,Max and X button in MDI child form
How do I use that function?
Thanks
-
July 15th, 2007, 06:14 AM
#5
Re: Disable Min,Max and X button in MDI child form
This will work for the 'x' button and the min/max system menu items of the child form but the titlebar buttons on the child form still seem to function.
The EnableMenuItem API didnt work either for the min/max.
Code:
Option Explicit
'WRITTEN BY ROBDOG888
'MDI CHILD FORM
Private Sub Form_Load()
'REMOVE THE SYSTEM MENU ITEM - CLOSE
RemoveMenu GetSystemMenu(Me.hwnd, 0), GetMenuItemCount(GetSystemMenu(Me.hwnd, 0)) - 3, MF_BYPOSITION
'REMOVE THE MENU SEPARATOR
RemoveMenu GetSystemMenu(Me.hwnd, 0), GetMenuItemCount(GetSystemMenu(Me.hwnd, 0)) - 3, MF_BYPOSITION
'REMOVE THE SYSTEM MENU ITEM - MAX
RemoveMenu GetSystemMenu(Me.hwnd, 0), GetMenuItemCount(GetSystemMenu(Me.hwnd, 0)) - 3, MF_BYPOSITION
'REMOVE THE SYSTEM MENU ITEM - MIN
RemoveMenu GetSystemMenu(Me.hwnd, 0), GetMenuItemCount(GetSystemMenu(Me.hwnd, 0)) - 3, MF_BYPOSITION
'NOTE: THE CODE LEAVES THE "NEXT" MENU ITEM WHICH IS FOR ADVANCING TO THE NEXT CHILD FORM
End Sub
Code:
Option Explicit
'WRITTEN BY ROBDOG888
'IN A MODULE
Public Declare Function RemoveMenu Lib "user32" ( _
ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Public Declare Function GetSystemMenu Lib "user32" ( _
ByVal hwnd As Long, _
ByVal bRevert As Long) As Long
Public Declare Function GetMenuItemCount Lib "user32.dll" ( _
ByVal hMenu As Long) As Long
Public Const MF_BYPOSITION As Long = &H400&
-
July 15th, 2007, 12:38 PM
#6
Re: Disable Min,Max and X button in MDI child form
Originally Posted by the_magicien
I want to disable min,max & X button in MDI child form.
Please help.Thanks
If you don't mind, can you tell me why do you want to disable all those buttons.
actually you want to disable for a particular time or you don't want.
-
July 15th, 2007, 05:36 PM
#7
Re: Disable Min,Max and X button in MDI child form
Probably because they dont want the child forms to be closed or resized seeing that it may allow acess to other child forms either out of turn or create issues in the program if they change child forms without the "Next form" menu.
-
July 15th, 2007, 07:26 PM
#8
Re: Disable Min,Max and X button in MDI child form
Originally Posted by RobDog888
Probably because they dont want the child forms to be closed or resized seeing that it may allow acess to other child forms either out of turn or create issues in the program if they change child forms without the "Next form" menu.
If that is the case, it is a direct violation of the MDI user interfice specifications. The OP should switch to a non-MDI architecture.
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
July 16th, 2007, 01:19 AM
#9
Re: Disable Min,Max and X button in MDI child form
Originally Posted by RobDog888
The EnableMenuItem API didnt work either for the min/max.
Hmm, what was I thinking! Man, I give dumb answers sometimes!
OK, I did find a way to Remove the Child form's Minimize & Maximise buttons!
This procedure, Removes the Minimize & Maximze buttons on the Child form, and Disables the Close button on the Child form too.
Code:
Option Explicit
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function GetWindowLong Lib "User32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal lIndex As Long) As Long
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 MAXIMIXE_BUTTON = &HFFFEFFFF
Const MINIMIZE_BUTTON = &HFFFDFFFF
Const MF_BYPOSITION = &H400
Const GWL_STYLE = (-16)
Enum RemoveMenuEnum
rmMove = 1
rmSize = 2
rmMinimize = 3
rmMaximize = 4
rmClose = 6
End Enum
Private Sub Form_Load()
Call pRemoveMenu(Me, rmClose)
Call RemoveChildMenu(Me, rmMaximize)
Call RemoveChildMenu(Me, rmMinimize)
Call RemoveChildMenu(Me, rmSize)
Call RemoveChildMenu(Me, rmMove)
End Sub
Private Sub RemoveChildMenu(ByVal TargetForm _
As Form, ByVal MenuToRemove As RemoveMenuEnum)
Dim lSysMenu As Long
Dim lStyle As Long
lSysMenu = GetSystemMenu(TargetForm.hWnd, 0&)
Call RemoveMenu(lSysMenu, MenuToRemove, MF_BYPOSITION)
Select Case MenuToRemove
Case rmClose
Call RemoveMenu(lSysMenu, MenuToRemove - 1, MF_BYPOSITION)
Case rmMinimize, rmMaximize
lStyle = GetWindowLong(TargetForm.hWnd, GWL_STYLE)
If MenuToRemove = rmMaximize Then
lStyle = lStyle And MAXIMIXE_BUTTON
Else
lStyle = lStyle And MINIMIZE_BUTTON
End If
Call SetWindowLong(TargetForm.hWnd, GWL_STYLE, lStyle)
End Select
End Sub
Right, now, you can remove them, but, CPUWizard actually brought up a good point too, why is this functionality needed ¿
-
July 16th, 2007, 09:17 AM
#10
Re: Disable Min,Max and X button in MDI child form
I think, if you want to show all those buttons as disabled then only you need codes.
Otherwise you don't need codes for that. You can do that by handling form's properties.
Check These properties.
Form's properties.
1) BorderStyle (It has 5 style)
2) ControlBox (remove all those buttons)
3) MinButton (Disable minimize button)
4) MaxButton (Disable maximize button)
-
July 16th, 2007, 09:44 AM
#11
Re: Disable Min,Max and X button in MDI child form
But can you change those properties' settings at run time ¿ No.
-
July 16th, 2007, 10:25 AM
#12
Re: Disable Min,Max and X button in MDI child form
Can't change in run time, that's why I asked before, he want to do that in a particular time or not.
-
March 5th, 2010, 01:37 PM
#13
Re: Disable Min,Max and X button in MDI child form
Actually the Normal Form Min, Max & X button will disable using the Control Box = False in Form Property Window, bu i want to know how o diable it for MDI Form not for Child could you pls tell me
thnx
-
March 5th, 2010, 03:22 PM
#14
Re: Disable Min,Max and X button in MDI child form
selva.spak This thread is over 2 years old.............
Please start a new thread, thank you!
I am closing this thread now.
Hannes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|