-
Nov 29th, 2013, 04:35 AM
#1
Thread Starter
Member
[ASK]Remove or Disable Menu on MDI Form Icon
hi..
can i now how to disable or remove the menu on MDI Form icon?
i use this code but this code just disable MAX Button on MDi Form
code from http://www.vbforums.com/showthread.p...=1#post2208777
Code:
Private Declare Function GetSystemMenu Lib "user32.dll" ( ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32.dll" ( ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32.dll" (ByVal hWnd As Long) As Long
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 nIndex As Long) As Long
Public Sub RemoveSizingButton(ByVal hWnd As Long)
Const WS_MAXIMIZEBOX As Long = &H10000
Const MF_BYPOSITION As Long = &H400&
Const MF_BYCOMMAND As Long = &H0&
Const SC_MAXIMIZE As Long = &HF030
Const SC_SIZE As Long = &HF000
Const SW_HIDE As Long = 0
Const GWL_STYLE = (-16)
Const WS_THICKFRAME As Long = &H40000
Dim lStyle As Long
Dim hwndMenu As Long
lStyle = GetWindowLong(hWnd, GWL_STYLE)
lStyle = lStyle And Not (WS_THICKFRAME Or WS_MAXIMIZEBOX)
SetWindowLong hWnd, GWL_STYLE, lStyle
'deletting Menu
hwndMenu = GetSystemMenu(hWnd, False)
lStyle = DeleteMenu(hwndMenu, SC_MAXIMIZE, MF_BYCOMMAND)
lStyle = DeleteMenu(hwndMenu, SC_SIZE, MF_BYCOMMAND)
lStyle = DrawMenuBar(hWnd)
End Sub
Private Sub MDIForm_Load()
RemoveSizingButton Me.hWnd
End Sub
thanks b4
-
Nov 29th, 2013, 04:53 AM
#2
Re: [ASK]Remove or Disable Menu on MDI Form Icon
I don't think you can totally remove the icon and have nothing there but to remove the default icon
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Nov 29th, 2013, 05:04 AM
#3
Thread Starter
Member
Re: [ASK]Remove or Disable Menu on MDI Form Icon
Originally Posted by Nightwalker83
I don't think you can totally remove the icon and have nothing there but to remove the default icon
thanks for your respon. but me.icon=nothing just remove the icon n show the system icon.
i need remove or disable the menu on MDIForm icon
this menu show if you click the icon
-
Nov 29th, 2013, 05:09 AM
#4
Re: [ASK]Remove or Disable Menu on MDI Form Icon
Like I said, I don't think you can although, the code here claims to do what you want but I have been unable to get it to work.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Nov 29th, 2013, 05:14 AM
#5
Re: [ASK]Remove or Disable Menu on MDI Form Icon
Check this article about RemoveMenu by Randy Birch.
p.s. It only removes the "Close" menu item and button.
Maybe this KB article can be of any help: http://support.microsoft.com/kb/110393
Last edited by Arnoutdv; Nov 29th, 2013 at 05:21 AM.
-
Nov 29th, 2013, 05:39 AM
#6
Thread Starter
Member
Re: [ASK]Remove or Disable Menu on MDI Form Icon
Originally Posted by Arnoutdv
yes i now this article
but i confused where ti get the window ID for my my problem (MDI Icon n MDI Icon menu)
i have use spy++ but this not show win ID
-
Nov 30th, 2013, 01:58 AM
#7
Re: [ASK]Remove or Disable Menu on MDI Form Icon
See if the following code accomplishes your goal:
Code:
Option Explicit 'In a standard (BAS) module
Private Const WM_CANCELMODE As Long = &H1F
Private Const WM_DESTROY As Long = &H2
Private Const WM_INITMENUPOPUP As Long = &H117
Private Declare Function SendMessageW Lib "user32.dll" (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function DefSubclassProc Lib "comctl32.dll" Alias "#413" (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SetWindowSubclass Lib "comctl32.dll" Alias "#410" (ByVal hWnd As Long, ByVal pfnSubclass As Long, ByVal uIdSubclass As Long, Optional ByVal dwRefData As Long) As Long
Private Declare Function RemoveWindowSubclass Lib "comctl32.dll" Alias "#412" (ByVal hWnd As Long, ByVal pfnSubclass As Long, ByVal uIdSubclass As Long) As Long
Public Function Subclass(ByRef MDI As MDIForm) As Boolean
Subclass = SetWindowSubclass(MDI.hWnd, AddressOf SubclassProc, ObjPtr(MDI), AddressOf SubclassProc): Debug.Assert Subclass
End Function
Private Function SubclassProc(ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long, _
ByVal uIdSubclass As Long, ByVal dwRefData As Long) As Long
Select Case uMsg
Case WM_INITMENUPOPUP
If lParam And &HFFFF0000 Then 'If the high-order word is TRUE, then the menu is the window menu
SendMessageW hWnd, WM_CANCELMODE, 0&, 0& 'Tell the DefWindowProc function to cancel internal menu processing
Exit Function 'The EndMenu API works too, but it sometimes causes flickering
End If
Case WM_DESTROY
dwRefData = RemoveWindowSubclass(hWnd, dwRefData, uIdSubclass): Debug.Assert dwRefData
End Select
SubclassProc = DefSubclassProc(hWnd, uMsg, wParam, lParam)
End Function
Code:
Option Explicit 'In an MDIForm
Private Sub MDIForm_Load()
Subclass Me
End Sub
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Nov 30th, 2013, 04:41 AM
#8
Re: [ASK]Remove or Disable Menu on MDI Form Icon
Code:
' In a module BAS
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
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 nIndex As Long) As Long
Private Const GWL_STYLE = (-16)
Public Sub ChangeMDIBorderStyle(ByRef pMDIForm As Form)
Dim lngStyle As Long
Dim lngNewStyle As Long
lngStyle = GetWindowLong(pMDIForm.hwnd, GWL_STYLE)
If lngStyle And WS_SYSMENU Then
lngNewStyle = lngStyle Xor WS_SYSMENU
Else
lngNewStyle = lngStyle Or WS_SYSMENU
End If
Call SetWindowLong(pMDIForm.hwnd, GWL_STYLE, lngNewStyle)
Call DrawMenuBar(pMDIForm.hwnd)
End Sub
From MDIForm call:
Code:
Call ChangeMDIBorderStyle(Me)
Call again to toogle yes/no.
N.B. Of course all buttons will be removed, also.
Isn't possible to remove the icon only.
Last edited by gibra; Nov 30th, 2013 at 04:47 AM.
-
Nov 30th, 2013, 10:29 AM
#9
Re: [ASK]Remove or Disable Menu on MDI Form Icon
Originally Posted by gibra
Call again to toogle yes/no.
I think your code can be further reduced to a single line:
Code:
Public Sub ToggleMDIWindowMenu(ByRef pMDIForm As MDIForm)
Const GWL_STYLE = (-16&), WS_SYSMENU = &H80000
SetWindowLong pMDIForm.hWnd, GWL_STYLE, GetWindowLong(pMDIForm.hWnd, GWL_STYLE) Xor WS_SYSMENU
End Sub
The DrawMenuBar API doesn't seem to be necessary.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
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
|