473,412 Members | 2,005 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,412 software developers and data experts.

Accessing form control menus

Title says it. Seems there should be an easy way to get a menu object
reference to the System menu in the upper left corner of a form so I can add
items to it.

Jul 19 '05 #1
1 1767
I believe you'll have to do this the old way, using GetSystemMenu and
AppendMenu or InsertMenuItem API Calls, then overide WndProc for the
messages. The following is a very basic VB.Net example:

<DllImport("user32", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared Function GetSystemMenu( _
ByVal hwnd As IntPtr, _
ByVal bRevert As Boolean) As IntPtr
End Function

<DllImport("user32", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared Function AppendMenu( _
ByVal hMenu As IntPtr, _
ByVal uFlags As Integer, _
ByVal uIDNewItem As Integer, _
ByVal lpNewItem As String) As Boolean
End Function

Private Const WM_SYSCOMMAND As Integer = &H112
Private Const MF_SEPARATOR As Integer = &H800&
Private Const MyMenuItemID As Integer = 1001

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
If m.Msg = WM_SYSCOMMAND Then
If m.WParam.ToInt32 = MyMenuItemID Then
MessageBox.Show("MyMenuItem Clicked", "System Menu")
End If
End If
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
_
Handles MyBase.Load
Dim SysMenu As IntPtr = GetSystemMenu(Me.Handle, False)
AppendMenu(SysMenu, MF_SEPARATOR, 0, Nothing)
AppendMenu(SysMenu, 0, MyMenuItemID, "MyNewItem")
End Sub

"Tim Greenwood" <ti***********@yahoo.com> wrote in message
news:uZ**************@TK2MSFTNGP11.phx.gbl...
Title says it. Seems there should be an easy way to get a menu object
reference to the System menu in the upper left corner of a form so I can add items to it.

Jul 19 '05 #2

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

Similar topics

3
by: Tom Meuzelaar | last post by:
Hello: I'm using VB6 in VS enterprise. I'd like to place an HTML form inside a VB container, have a user fill out the form information, click a submit button, and then have the program capture...
1
by: DU | last post by:
Assuming you have a typical form built in this manner: <form action="..."> <p><input id="idInputText" name="nameInputText" type="text" size="20"></p> <p><input id="idCheckbox"...
3
by: Rich | last post by:
We are preparing a page with twelve (12) drop down option/select menus, arranged vertically. It works, and it is what the user needs. The widths of the menu boxes are random now, but is there...
2
by: Dave | last post by:
Hi, I'm creating a windows forms utility to create dhtml flyout menus. I want to load the html and javascript generated into a webbrowser control, thats on the form, so I can view the menus and...
3
by: Vivek Sharma | last post by:
Hi, I have created a dropdownlist as a web user control. I am using its multiple instances on the webpage. How do I access the selectedValue of each instance? All the instances have different...
6
by: arvee | last post by:
Is there a way to access controls (and their properties) in a user control? The Web Form Designer marks controls as 'Protected' which makes them inaccessable from the host form. If I mark them as...
3
by: Tim Greenwood | last post by:
Title says it. Seems there should be an easy way to get a menu object reference to the System menu in the upper left corner of a form so I can add items to it.
0
by: aakash | last post by:
Hello Guys I am upsizing ms access project to give it a ms sql connectivity I am having problem in accessing form control values in ms sql function CREATE FUNCTION "ReportList DateRange"() ...
0
by: Dana | last post by:
Hi All I have a menu control on my page, something like: <form action=Default.aspx runat="server"> <asp:Menu ID="Menu1" runat="server" BackColor="#F7F6F3" DynamicHorizontalOffset="2">...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.