Home > dotnetjunkies > Modify a Window’s System Menu (vb.net) Help!

Modify a Window’s System Menu (vb.net) Help!

I was trying to add a “About“ in a vb.net application’s System (or Control) Menu as they say (ya know the one with the minimize,maximize,close etc) , I had done this in VB6 before, but its strange I can get it done in vb.net, I know the technique is to get the handle and add a separtor and then our new menu etc…

Found this code at http://www.developerfusion.com/show/4655/ but was in c#, can somehelp dissecting it to work in vb.net or provide an alternative ?

using System.Runtime.InteropServices;

private static extern int GetSystemMenu (int hwnd, int bRevert);

private static extern int AppendMenu (
int hMenu,int Flagsw,int IDNewItem,string lpNewItem);

private void SetupSystemMenu ()
// get handle to system menu
int menu = GetSystemMenu(this.Handle.ToInt32(),0);
// add a separator
// add an item with a unique ID
AppendMenu(menu,0,1234,”About SiteWatcher”);

protected override void WndProc (ref Message m)
base.WndProc(ref m);
// WM_SYSCOMMAND is 0x112
if (m.Msg == 0x112)
// check for my new menu item ID
if (m.WParam.ToInt32() == 1234)
// show About box here…

Categories: dotnetjunkies
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s