System Menu (On Top) VB.NET 2003

N

Newbie Coder

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("user32")> _
Public Shared Function GetSystemMenu(ByVal hwnd As IntPtr, _
ByVal bRevert As Boolean) As IntPtr
End Function

<DllImport("user32")> _
Public Shared Function AppendMenu(ByVal 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(Me.Handle, False)
AppendMenu(ptrHandle, MenuFlags.MF_SEPARATOR, 1000, "") 'Seperator
AppendMenu(ptrHandle, MenuFlags.MF_STRING, 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.ToInt32
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.Checked = Not MenuItem.Checked
Me.TopMost = MenuItem.Checked

Any ideas?

Thanks in advance
 
N

Newbie Coder

Mattias,

SYSTEM MENU not standard menu

I have asked this question in C++ & VB.NET 2003 & no-one can come up with an
answer & your suggestion is completely wrong

Thanks for taking the time to TRY to help me though

--
Newbie Coder
(It's just a name)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top