How to place a component above a TMainMenu? - delphi

When I add, for example, a TPanel to a form and align it using alTop and then add a TMainMenu to the same form, the main menu position overrides the panel position such that the Main Menu remains topmost on the form with the panel appearing below it.
Is it possible to override the TMainMenu position so I can add a component like a Panel above it and the Main Menu below it?
Alternatives like TActionManager and/or TToolBar are not suitable because of BiDi compatibility issues.

No, the main menu is a Windows component and its location is fixed. This isn't a Delphi limitation but a restriction on how menus work with windows in Windows.
From MSDN (emphasis mine) :
Only an overlapped or pop-up window can contain a menu bar; a child window cannot contain one. If the window has a title bar, the system positions the menu bar just below it. A menu bar is always visible.
If you want menu-like behaviour in a component which you can freely place anywhere on your form, you would need to either write one yourself or look for third-party alternatives.

Related

How do I 'revert to inherited' if control is not clickable?

Assume the following situation:
FrmBase has a TPanel named PnlClient, align alClient
FrmDescendant inherits from FrmBase
In FrmDescendant I change a PnlClient property
In FrmDescendant I place another control (say another TPanel named PnlDescendant) on PnlClient and align it alClient.PnlDescendant now completely covers PnlClient
I place lots of other components on PnlDescendant, not necessarily aligned, so I'm afraid to change PnlDescendant (e.g. setting align to alNone and resizing) and lose positions
How can I execute 'revert to inherited' for PnlClient?
There's nothing in the main menu, or in the popup menu for the controls in the Structure View...
Currently using Delphi 10.4.1 Sydney
This is easy for a keyboard user like myself:
Click on PnlDescendant in the form editor to make it the focused and selected control.
Press Esc to select its parent, PnlClient.
Press the Menu key on your keyboard to display the context menu of PnlClient. If you have a cheap keyboard without a Menu key, press Shift+F10 instead.
Click on "Revert to Inherited". (Or, much faster: press the menu item's underlined character, probably I.)
(But notice that this will remove PnlDescendant completely. Probably you didn't want that, but that's how it works.)

Button tabs with images in delphi

I would like to dvelop an app with a GUI like CCleaner, where you have a left aligned tabs, (but not the typically wicvh contain only a word) with an image in a button.
I couldn't find the properties, probably because i'm working only with the installation of delphi XE2, an i have only the TTabControl on the win32 pallete.
i don't know how to create a form like this i call above. Can it be created with a ttabcontrol?
Could anyone help me? I want a form with a left tab with button in each option, that change the right side of the form...
On the Win32 palette there are TTabControl (as you know) and TPageControl which is similar to TTabControl but has separate pages (called TTabSheet) for each tab.
Both have a property TabPosition with 4 possible values: tpTop (default), tpBottom, tpLeft and tpRight. The text of the tabs are vertical for tab positions tpLeft and tpRight. Both tab controls also supports images in the tabs through the Images property which can take a TImageList as container for the images.
If you don't like the vertical text on the tabs, you can compose your form with separate buttons on the left and panels or frames as pages. As buttons you can use TBitBtn or TButton buttons placed directly on the form or on a panel if you like, or you can use a TButtonGroup All of these supports the TImageList mentioned above. For some you can have separate images for disabled, hovered (hot), selected and pressed states.
Read more about these controls in the help.

Delphi: allow horz/vert scrollbars to show standard popup menus?

I use Delphi7. I use custom memo control, TSyntaxMemo component.
I see that many apps (Notepad, Notepad++, uTorrent, ...) use standard popup menu for scrollbars:
scroll here
up
down
page up
page down
scroll up
scroll down
(this is list for a vertical bar).
How can I use such menus for scrollbars in "my" memo? W/o doing these menus by hands.
You don't have to do anything at all to make that menu show in a Windows EDIT control. That's a standard system menu implemented by the control. It appears on a TMemo added to a vanilla VCL forms app, since TMemo is simple a wrapper of the multi-line variant of the EDIT control.
Here's all I needed in my .dfm file:
object Form1: TForm1
object Memo1: TMemo
Align = alClient
ScrollBars = ssVertical
end
end
This is functionality provided by the system. If your control is not behaving that way then I can think of the following reasons why that happens:
Your control is not a Windows EDIT control.
Your control is an EDIT control but it is not using the default message handler that results in this menu.
If item 1 is the reason, then there's nothing you can do to get the system display the menu. If your control is not an EDIT control you can hardly expect it to magically behave like one. In the case of item 2, you need to work out how the control is stopping the message that leads to the menu being handled by the control's default message handler.

How do I add buttons to a FireMonkey toolbar?

With 10 years of experience in development, I could not put new buttons on the Toolbar FireMonkey. Could anyone help me?
There is no component editor menu-item to add buttons or seperators, but you can drag buttons from the toolpallet to the toolbar. Or select the toolbar in the form and press F6. Type the name of the control you want on the toolbar and press enter.
TToolBar is now simply a container. You must drop your own controls onto it.
To add a control to a ToolBar, make sure that your ToolBar is selected on the form, select your child control in the Tool Palette, and then click the location in the ToolBar that you wish your child control to appear.
Another way to do this is to ensure that the ToolBar is selected and double-click the control in the Tool Palette. Whatever control is selected becomes the parent.
Many of the new FireMonkey UI controls are now simply containers, including TStatusBar.
To add a text line to TStatusBar, you must add your own TLabel or other control.
I found that the best way to put an image on a button was to literally drop a TImage onto the button and unset the TImage's HitTest property.
All FireMonkey controls are containers and can have child controls now. It might take a little longer to configure your UI, but you have a lot of flexibility.
Use the TLayout control for dividing up the parent control and aligning your controls. Use the Margin and Padding properties to adjust the spacing.

Delphi: suggests, ideas in a building of User Interface

I am building an user interface. My program will consist of 4 main parts:
1) Top Menu - TMainMenu. A top of a window
2) Main Menu - TTreeView. A left of a window. Each item of TreeView=corresponded TabSheet of TPageCotrol.
3) Work space - TPageControl. No tabs. An left space.
Each TabSheet has it's own ToolBar and other controls. It will be 5 menus (5 items in TreeView) = 5 TabSheets -> 5 ToolBars and other controls on each TabSheet.
It almost exactly looks like here (it could be: TreeView as Main Menu; MainMenu as Top Menu; Work Area - ToolBar and other controls):
I would like to use an user interface like here:
Where the CoolBar are represented with the Top Menu and the ToolBar (it suits my purpose to use 5 ToolBars instead of 1 ToolBar on each TabSheet). But after a discussion here it seems impossible to copy this CoolBar with the MainMenu and the ToolBar.
My question: how to build an efficient user interface using as examples the UI of uTorrent and the UI of Windows Firewall?
Are there good alternatives, ideas of a building of the UI? How would you make your interface if you need those 4 parts as me?
Now I have something like this:
Thanks!
You'll have to have 5 panels in your client area.
As you select a node in the treeview on the left you will need to call
pnlInboundRules.BringToFront;
The difficult thing is then how to update the single toolbar with the items that should appear on it based on what "tab" you've selected.
You would have to delete the toolbar buttons, and add new buttons for that "page".
Ian suggest panels, I would go with PageControl and set it's tabs TabVisible to false at runtime(*). The reason is that it is much more easy to manage at design time. When user select an item from treeview, activate corresponding TabSheet...
*) I actually haven't done this with stock TPageControl so I don't rememeber would it work this way, ie would it activate TabSheet which have it's TabVisible set to false. It might be that you have to set TabHeight to 0 or use some other trick to hide tabs at runtime.

Resources