getting menu event in activeX object from inserted menu item - activex

I am inserting menu items from my activeX control into the container using ::InsertMenu(...). The insertion works and my menu item shows up but I do not receive events for it (even though I have an event handler for the OnCLick()). Of course this is because the event is going to the container and not to my control. Is there any way in C++Builder to capture that event? The container ignores it since it does not know how to handle the menu event itself, does it pass it onto the container, if so, how can I grab it?

Related

how to add multiple dialogs in angular7 such that it return to its previous dialog and also reflecting data changes in the parent component

When a click on cancel (using confirm()) its not going back to previous dialog but to the parent component.
Tried creating a html, instead of confirm() , but still it not working as it is going to parent component instead of previous dialog.

Is it possible to open a menu when a button is clicked in Rad Studio

It is possible to do in most other environments, but i'm unable to find a way to do this with Embarcadero.
The closest thing that was found is setting the DropDownMenu property on a button with bsSplitButton property... however this has a problem that it only works with Vista (so in fact i cannot even test if it works at all).
Alternatively it is currently possible to add a regular right button drop down.
Is there a way to connect button's left button click event to a specific drop down menu?
Your button's OnClick event handler can call the Popup() method of a TPopupMenu component. You do not have to assign the PopupMenu to the button unless you want it to handle right-clicking.

Delphi TMenuItem OnClick not working if menu has sub items

It appears Onclick events are not processed for menu items that have sub-items.
I realize I could create a leaf item which users could use instead, but I would like to have my menu folders respond to OnClick (in my case to "launch" all sub-items)
Is there any way around this limitation?
Menu items that have sub-items do indeed fire OnClick events. But they fire when the sub-menu opens rather than when you click on the parent menu item.
I'm pretty sure you don't want to invoke all sub-items when that happens. The OnClick event for a parent menu fires whenever the sub-menu is opened. Either when you click on the parent menu item, hover over it, or press the right arrow key when the menu item is selected via the keyboard.
So, the OnClick event for a parent menu corresponds to opening the sub-menu. Invoking all the child menu item actions when the sub-menu is opened goes against all standard expected UI behaviour. What you should do is add another sub-item that can be used to invoke all actions. Don't go against the platform standard UI unless there are no sane alternatives.

Show different popup menu depending on what column the mouse is over in a Delphi TListView control?

I have a Delphi 6 application that has a TJvListView control. I have a popup menu tied to that control via the control's PopupMenu property. What I would like to do is show a different popup menu based on which column the user had the mouse over when they right clicked, with the additional option to not show a popup menu at all if the current column does not need one. How can I do this?
Thanks to this detailed sample by Remy Lebeau on in-place editing in a TListView I know what row and column the mouse is over except for one wrinkle. The mouse down event where I determine the current row and column occurs after the popup menu is exited.
I now need to know two things. First, how can I get some event to fire before the popup menu shows after a right mouse click so I can record the current list view row and column and suppress the popup menu if I want to, and second, how I can show a different popup based on the current column. I am hoping to avoid having to write a bunch of mini-forms instead of using the TListView PopupMenu property and supporting code. Is there a simple solution, perhaps some fancy footwork in a sub-class I should create around TJvListView?
You could perform the detection in mousemove instead of mousedown/Click and change the popupmenu depending.
You also could remove any popupmenu and call the wished via p.pupup in mousedown as you desire.

How can I make a menu stay visible after it's clicked?

I'm using Delphi. I have my popup menu ready, and in a submenu I want to click, but I don't want the popup menu to disappear. I want to click and make it stay.
Easy one, disable the item. < g >
Joke aside, not an easy task.
If you want the popup menu to act like a top-most form (that is you can both interact with the items and with controls on your form without deactivating the menu), forget it, it cannot be done with a standard menu.
But if your requirement is as exactly as stated in your question (click an item, and the menu is not closed - click outside and it is closed), with some work, it would be possible.
Your aim would be to subclass the window that your submenu will reside in to override some message handling. First, derive a new class from 'TPopupList' and override its 'WndProc'. Here is an example doing this.
If you intend to prevent the closing of the menu by selecting root items then in PopupList's WndProc you'd handle WM_ENTERIDLE and get the popup menu's window handle from the message's lParam and subclass the popup menu's window.
If you only intend to prevent the closing of the menu by selecting submenu items, then in PopupList's WndProc you'd watch for WM_INITMENUPOPUP messages where the wParam is "not" the handle of the PopupMenu itself, that would mean a submenu is about to be shown. Only then you'd handle WM_ENTERIDLE and get the window handle that the submenu resides in and subclass that window.
After subclassing the window that the popup menu or the popup submenu resides in, you'd intercept an undocumented 'MN_BUTTONDOWN' ($01ED) message and prevent further handling (not call the original window procedure). Probably you'd also want to prevent closing of the menu with the keyboard; you'd watch for WM_KEYDOWN (Enter) and WM_CHAR (accelerator) messages.
Well, would take some work I guess.
I don't know how can you do that but TAdvStickyPopupMenu component (TMS software) can do this.

Resources