How to simulate OnMouseMove event on TMenuItem? - delphi

When mouse cursor is over some menu item (TMainMenu) then the item is highlighted. I would like to add a text inside my status bar describing the menu item but I have no OnMouseMove or any similiar event for TMenuItem to do this. How to achive this?
I'm using C++ Builder XE6.
Thanks!

The VCL can handle this automatically for you.
Assign your desired text to the TMenuItem.Hint property:
Specifies the text string that can appear when the user moves the mouse pointer over a menu item.
Set Hint to a string that provides more information about the meaning of the menu item than the Caption. The hint text appears in the Status Bar when the user pauses with the mouse over the menu item if Help Hints are enabled (that is, if the Form's and the Application's ShowHint properties are True). It is also available for the code in the application's OnHint event handler.
And then set the TStatusBar.AutoHint property to true.
Specifies whether the status bar's text is set automatically to the current hint.
Use AutoHint to specify whether the status bar's text is set automatically to the current hint. When AutoHint is True, the status bar automatically responds to hint actions by displaying the long version of the hint's text in the first panel.
Any changes to the TApplication.Hint property, such as when the mouse moves over a UI control or menu item, will propagate to the TStatusBar automatically.

Related

How do I prevent menu and toolbar clicks stealing focus from a floating form?

I want to achieve the same effect as in Visual Studio 2010+, where if you float an editor on top of the main form, clicking on a main form menu or toolbar button doesn't cause the main form to steal focus; instead the floating window retains focus.
Without this it becomes impossible to invoke any main menu command that operates on a focused control when the focused control is in a floating window - because the control you wanted to operate on loses focus just as the command is invoked.
(Ironically, if you look closely at this image you'll see that the selection in the editor is muted, indicating that the editor control doesn't have focus. Visual Studio seems to be doing something slightly devious to achieve the illusion that the floating window is still focused.)
The solution is very easy if you are using TActionMainMenuBar and TActionToolBar.
First the menu bar: TActionMainMenuBar has a property AutoFocus, which is True by default. Set this to False and then clicking on the menu won't automatically give focus to the form containing the menu. Instead, the form that previously had focus will retain it.
Now the tool bar: TActionToolBar doesn't have an AutoFocus property. Instead you need to handle its OnMouseActivate event and return maNoActivate.
Note that returning maNoActivate from an OnMouseActivate handler doesn't work for all controls. Some controls such as TButton will give themselves the focus when clicked regardless of the return result from the OnMouseActivate handler. But in the case of TActionToolBar we do get the effect we are after.
It took me a while to find this though, and even searching Google for a page containing both 'AutoFocus' and 'OnMouseActivate' elicits no useful results (other than, presumably, this page once it gets indexed). So I hope this answer will help someone else.

Combo box not focusable

Is there any way we can set the combo box not focusable? Because every time I select an item from combo box (drop down list), the keyboard shows up and the text from drop down list can be edited. I can't find any property from property inspector to disable this up. Or maybe we can disable this one programmatically in which I don't know.
Consider using an Option Menu (unlike a Combo Box an Option Menu has no field which a user can type into - and therefore no unwanted appearance of the keyboard)
Dave
The default script for a combo box is a menuPick handler. Whether or not you use the functionality of that handler or not, you would add this line at the end of that handler:

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.

delphi 2009 accelerators

How to remove the Accelerators from TMainMenuActionBar ?
can't seem to find the AutoHotKey = maManual property to change, nor to find any other property that will cause the right effect.
(Assuming the question is about TActionMainMenuBar) you would set the AutoHotKeys property through the ActionManager component that the action bar is linked to (through its ActionManager property). Unlike the TMainMenu's AutoHotKeys, this one is a boolean property.
To set the property at design time,
Select the 'ActionManager' component on the form
Click the ... button on the right side of the ActionBars property in OI.
Select your MainMenuBar from the popped up Editing ActionManager1.ActionBars' dialog.
Click the ... button on the right side of the Items property in OI, which will launch the Editing ActionManager1.Items dialog
Do not select any of the items at this time. Instead, set the AutoHotKeys property to True or False in OI.
At run time you can do:
ActionManager1.ActionBars[0].Items.AutoHotKeys := False;
Note that you might need to re-set the Caption of an Item after toggling AutoHotKeys. I.e. 'F&ormat' -> 'Format'.

How to set the glyph for a toolbar button to blank?

I add a toolbar with some standard Delphi components to my application. Unfortunately, the stupid arrow is first glyph (does anyone even know what it is for?)
I would like to destroy it totally, or, at least, set itcs icon to blank, so that it blends in with the toolbar.
How can I do this?
I need some code which can be executed twice without causing an exception. Thanks
TToolButton gets its image from combining its ImageIndex property with the enclosing toolbar's Images property, which refers to a TImageList. To make a toolbar button have no image, assign ImageIndex := -1.
To remove the glyph from a TSpeedButton at design time, select the button, and then select the Glyph property in the Object Inspector. Press Del to clear the property. To do the same at run time, assign Button.Glyph := nil.
If you have a pre-made toolbar, such as TMediaPlayer or TDBNavigator, then you can't customize the buttons. They always show the arrow glyphs that are hard-coded in the control. You can choose to hide or show certain buttons, though. If you placed the control just to get a row of buttons and have no intention of using them to play media or navigate a database, then don't use that control. Just place a TPanel and put standalone buttons on it.

Resources