473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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("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
May 4 '07 #1
2 1463
>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.
May 6 '07 #2
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" <ma********************@mvps.orgwrote in message
news:Ou**************@TK2MSFTNGP04.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.

May 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jason Rodman | last post by:
I have standard winform that I have hidden the title bar so that I can make my own custom header. I have my own code to drag the form and close/minimize/maximize and even show the title in the task...
2
by: TB | last post by:
For a simple form without its own menu I wanted to add an "About..." command to the system menu as I would for an old MFC/C++ application. However I cannot find out how to access the system menu...
0
by: Will Pittenger | last post by:
I have a C# .NET program which does without a normal titlebar for its main window. Trouble is, I still want the user to be able to access select commands while the program is minimized. (I...
6
by: Scotty | last post by:
What function is called in response to a click on "Close" on system menu (the "X" in the top right side of window)?
6
by: Jordi Rico | last post by:
Hi, we are making custom forms in our app, so we use forms with no border and no control buttons in order to make all at our own. The problem is that our customer wants the system menu...
1
by: iwdu15 | last post by:
hi, i added an item to the system menu for every application (looping through each process and using the MainWindowHandle to get the handle, the using the GetSystemMenu and AppendMenu APIs to add a...
5
by: Salem | last post by:
Hi! I have a problem. When i set FormBorderStyle property of a form to None i can't get the system menu (that windows menu with close, maximize, minimize and other options) to show up when i...
1
by: ram.gct | last post by:
Hi, I have an IE modal window created with showModalDialog() in javascript. Is there a way I can disable the system menu that appears when we left click on top left corner of the modal window . ...
4
by: raj.indian.08 | last post by:
Hi all, I am trying to modify the system menu of all the applications in my machine. For example say - I am creating multiple desktops for windows - and I want to give every application the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.