Hi All
It's rare for me to ask a question in this newsgroup
VB.NET 2003 ONLY - FRAMEWORK 1.1
--------------------------------------------------
How do I check/uncheck an extended System Menu item & handle the Click
Event?
Imports System.Runtime. InteropServices
<DllImport("use r32")_
Public Shared Function GetSystemMenu(B yVal hwnd As IntPtr, _
ByVal bRevert As Boolean) As IntPtr
End Function
<DllImport("use r32")_
Public Shared Function AppendMenu(ByVa l hMenu As IntPtr, _
ByVal wFlags As MenuFlags, ByVal wIDNewItem As Int32, _
ByVal lpNewItem As String) As Boolean
End Function
<Flags()_
Public Enum MenuFlags As Integer
MF_BYPOSITION = 1024
MF_REMOVE = 4096
MF_SEPARATOR = 2048
MF_STRING = 0
End Enum
Private Const WM_SYSCOMMAND As Integer = &H112
Form Load Event:
Dim ptrHandle As IntPtr = GetSystemMenu(M e.Handle, False)
AppendMenu(ptrH andle, MenuFlags.MF_SE PARATOR, 1000, "") 'Seperator
AppendMenu(ptrH andle, MenuFlags.MF_ST RING, 1001, "On Top") ' New Menu
Item
WndProc:
#Region "WndProc (SUB)"
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND Then
Select Case m.WParam.ToInt3 2
Case 1000 'Do nothing as it's seperator
Case 1001
' Handle The TopMost Click Event Here
End Select
End If
MyBase.WndProc( m)
End Sub
#End Region
------------------------------------
The way I want the System Menu to be handles is like so:
MenuItem.Checke d = Not MenuItem.Checke d
Me.TopMost = MenuItem.Checke d
Any ideas?
Thanks in advance
It's rare for me to ask a question in this newsgroup
VB.NET 2003 ONLY - FRAMEWORK 1.1
--------------------------------------------------
How do I check/uncheck an extended System Menu item & handle the Click
Event?
Imports System.Runtime. InteropServices
<DllImport("use r32")_
Public Shared Function GetSystemMenu(B yVal hwnd As IntPtr, _
ByVal bRevert As Boolean) As IntPtr
End Function
<DllImport("use r32")_
Public Shared Function AppendMenu(ByVa l hMenu As IntPtr, _
ByVal wFlags As MenuFlags, ByVal wIDNewItem As Int32, _
ByVal lpNewItem As String) As Boolean
End Function
<Flags()_
Public Enum MenuFlags As Integer
MF_BYPOSITION = 1024
MF_REMOVE = 4096
MF_SEPARATOR = 2048
MF_STRING = 0
End Enum
Private Const WM_SYSCOMMAND As Integer = &H112
Form Load Event:
Dim ptrHandle As IntPtr = GetSystemMenu(M e.Handle, False)
AppendMenu(ptrH andle, MenuFlags.MF_SE PARATOR, 1000, "") 'Seperator
AppendMenu(ptrH andle, MenuFlags.MF_ST RING, 1001, "On Top") ' New Menu
Item
WndProc:
#Region "WndProc (SUB)"
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_SYSCOMMAND Then
Select Case m.WParam.ToInt3 2
Case 1000 'Do nothing as it's seperator
Case 1001
' Handle The TopMost Click Event Here
End Select
End If
MyBase.WndProc( m)
End Sub
#End Region
------------------------------------
The way I want the System Menu to be handles is like so:
MenuItem.Checke d = Not MenuItem.Checke d
Me.TopMost = MenuItem.Checke d
Any ideas?
Thanks in advance
Comment