System Menu (On Top) VB.NET 2003

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Newbie Coder

    #1

    System Menu (On Top) VB.NET 2003

    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


  • Mattias Sjögren

    #2
    Re: System Menu (On Top) VB.NET 2003

    >How do I check/uncheck an extended System Menu item & handle the Click
    >Event?
    Use the CheckMenuItem or SetMenuItemInfo function.


    Mattias

    --
    Mattias Sjögren [C# MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    • Newbie Coder

      #3
      Re: System Menu (On Top) VB.NET 2003

      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)





      "Mattias Sjögren" <mattias.dont.w ant.spam@mvps.o rgwrote in message
      news:OuamTlCkHH A.1240@TK2MSFTN GP04.phx.gbl...
      How do I check/uncheck an extended System Menu item & handle the Click
      Event?
      >
      Use the CheckMenuItem or SetMenuItemInfo function.
      >
      >
      Mattias
      >
      --
      Mattias Sjögren [C# MVP] mattias @ mvps.org
      http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
      Please reply only to the newsgroup.

      Comment

      Working...