473,606 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1788
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("use r32", CallingConventi on:=CallingConv ention.Cdecl)> _
Private Shared Function GetSystemMenu( _
ByVal hwnd As IntPtr, _
ByVal bRevert As Boolean) As IntPtr
End Function

<DllImport("use r32", CallingConventi on:=CallingConv ention.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.ToInt3 2 = MyMenuItemID Then
MessageBox.Show ("MyMenuItem Clicked", "System Menu")
End If
End If
End Sub

Private Sub Form1_Load(ByVa l sender As Object, ByVal e As System.EventArg s)
_
Handles MyBase.Load
Dim SysMenu As IntPtr = GetSystemMenu(M e.Handle, False)
AppendMenu(SysM enu, MF_SEPARATOR, 0, Nothing)
AppendMenu(SysM enu, 0, MyMenuItemID, "MyNewItem" )
End Sub

"Tim Greenwood" <ti***********@ yahoo.com> wrote in message
news:uZ******** ******@TK2MSFTN GP11.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
15094
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 the field values and write them to an ASCII file on the hard drive. Can anyone confirm that this is even possible? I have dredged up one article "Accessing the Internet Explorer Document Object Model from Visual Basic 5.0" (Asmi, 1998) that covers...
1
4061
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" name="nameCheckbox">optional</p> <p><input id="idRadio1" name="nameRadio">yes<input id="idRadio2" name="nameRadio">no</p> <p><select id="idSelect" name="nameSelect"><option value="a">a</option><option value="b">b</option><option value="c">c</option></select></p>
3
5830
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 is a way to control the WIDTH of the menu boxes, so they would all be alike? Thank you for any help Rich
2
13489
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 view them in control. I found there is no control in .net for this so I'm using the webbrowser control. How can you load the html directly into the control? Or do I have save the
3
2786
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 IDs. Thanks Vivek
6
2243
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 Public, I can access them, but the next time the controls are manipulated in the design mode, they are converted back to Protected. Is there an obvious/easy way around this? Thanks.
3
450
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
1652
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"() RETURNS TABLE AS Begin RETURN
0
1152
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"> <Items> <asp:MenuItem Text="File" Value="File" Selectable="False"> <asp:MenuItem Text="Open" Value="Open"></asp:MenuItem>
0
8009
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8432
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8299
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6753
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5962
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5456
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3919
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3964
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.