Solved

window menu - add or delete menu item

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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