Solved

window menu - add or delete menu item

Posted on 2003-11-21
1
522 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
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.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

943 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

19 Experts available now in Live!

Get 1:1 Help Now