Solved

How to add items to title bar menu

Posted on 2004-08-27
5
831 Views
Last Modified: 2008-03-10
Hello.

How do I add  items to the popup menu that appears when you click on an application title bar. (The menu that has Minimize, Maximize, Close etc).

Thanks. js
0
Comment
Question by:jeremiahscott
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:sonicblis
ID: 11914303
I assume you're speaking of a windows form, like adding "always on top"?
0
 

Author Comment

by:jeremiahscott
ID: 11914560
Yes, I have a windows form.

I probably didn't explain this well. If you click on Internet Explorers title bar you will see a popup menu. The items are [Restore, Move...Close]. If you do the same thing on a windows command prompt window they have added 3 more items [Edit, Defaults, Properties]. I want to mimic that.

thx
0
 
LVL 19

Accepted Solution

by:
Desp earned 100 total points
ID: 11919539
[DllImport("user32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);

[DllImport("user32.dll")]
private static extern bool AppendMenu (IntPtr hMenu, Int32 wFlags, Int32
wIDNewItem, string lpNewItem);

public const Int32 WM_SYSCOMMAND = 0x112;
public const Int32 MF_SEPARATOR = 0x800;
public const Int32 MF_STRING = 0x0;
public const Int32 IDM_ABOUT  = 1000;

private void Form1_Load(object sender, System.EventArgs e)
{
IntPtr sysMenuHandle = GetSystemMenu(this.Handle, false);
AppendMenu(sysMenuHandle, MF_SEPARATOR, 0, string.Empty);
AppendMenu(sysMenuHandle, MF_STRING, IDM_ABOUT, "About...");
}

protected override void WndProc(ref Message m)
{
if(m.Msg == WM_SYSCOMMAND)
 switch(m.WParam.ToInt32())
 {
  case IDM_ABOUT :
    MessageBox.Show("This is About dialog");
   return;
  default:
   break;
 } base.WndProc(ref m);
}
0
 

Author Comment

by:jeremiahscott
ID: 11922857
I got it working. Thanks. I couldn't figure out what that menu was called. "System Menu"
0
 
LVL 19

Expert Comment

by:Desp
ID: 11924580
User menu are the menus designed and developed by the programmer himself(like Mainmenu and ContextMenu control). SystemMenu is something common functaionality provided by the Operating system.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question