Solved

window menu - add or delete menu item

Posted on 2003-11-21
1
520 Views
Last Modified: 2010-04-16
How can I add, delete or disable menu items in the window menu?
0
Comment
Question by:qweqwe
1 Comment
 
LVL 3

Accepted Solution

by:
raidos earned 125 total points
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now