Solved

window menu - add or delete menu item

Posted on 2003-11-21
1
531 Views
Last Modified: 2010-04-16
How can I add, delete or disable menu items in the window menu?
0
Comment
Question by:qweqwe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
raidos earned 125 total points
ID: 9797799
Var
  hSysMenu : hMenu;
  NCT: Integer;
Begin
    hSysmenu := GetSystemmenu(HandleOfYourWindow,False);
    Nct := Getmenuitemcount(hSysmenu);
    Deletemenu(hSysmenu,NCT-1,MF_BYPosition);
    //Plockar bort Separatorn på fönstret
    Deletemenu(hSysmenu,NCT-2,MF_BYPosition);
    //Redraw the Menu
    Drawmenubar(HandleOfYourWindowAgain);
End;

That's for removing items the last 2 items in the menu...

Enabling and disabling is similar to Deleting...
just replace Deletemenu with
  EnableMenuItem(hSysMenu, NCT-1, MF_BYPOSITION OR MF_DISABLED);
Or
  EnableMenuItem(hSysMenu, NCT-1, MF_BYPOSITION OR MF_ENABLED);
 
There are other Constants than MF_BYPOSITION in play aswell but check out the MSHelp for EnableMenu item and you'll get the full picture..

Adding items is no breeze...you will need to hook some WM_Message targeted for the window..
Haven't done that before so i don't really know how to do it...i've investigated some but my memory is clouded.. ;P

Regards
//raidos

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

739 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