delphi - Is possible for a menu item to receive an OnClick event even when it's not enabled? -


i'm trying enable administrator enable/disable menu items in main menu of application ctrl+clicking them. i've injected tmenuitem class in main form custom version , overridden click virtual method, so:

uses   forms, menus;  type   tmenuitem = class(menus.tmenuitem)   public     controlactivationstate: boolean;     procedure click; override;   end;    tmymainform = class(tform)  ...  procedure tmenuitem.click; begin   if controlactivationstate , iskeypressed(vk_control)     self.enabled := not self.enabled   else     inherited; end; 

it works, top level menu. why top level menu items receives onclick events when disabled , other menu items don't? there way make child menu items receive events too?

the top level onclick event triggered receipt of wm_initmenupopup message. message sent when top level item disabled. i'm not sure why sent in scenario, is. , same true sub-item has children.

however, sub-item without children, onclick triggered wm_command message. system never sends message if menu item disabled.

what attempting cannot readily done. way can see doing handle raw mouse , keyboard events. personally, not contemplate doing so.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -