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

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.

Related

How to use FMX Style Manager to create a fade out effect for TMemo

I am trying to add a fade-out effect to a TMemo control.
In the Form Designer it works quite well with a TLayout, TRectangle, and TMaskToAlphaEffect, as show in the screenshot on the left side. However, I would like to use the Style Designer (TStyleBook), as this seems the predestined approach and offers even more possibilities.
I have recreated it in the Style Designer, and in the Form Designer it looks as expected.
At runtime, however, the fade-out effect is not visible for TMemo styled by the TStyleBook. The "manually" styled TMemo is working fine.
As the Windows resources for the TStyleBook generates a ~83kb .fmx file, I had to upload the MCVE, which can be found on DropBox.
To do it on your own, follow these steps:
Open new FMX project
Add a TMemo to the form
Right click the TMemo and select "Edit Custom Stlyes..."
Select "background" under Memo1Style1 in the structure panel
Add a TRectangle from the component palette by double clicking
Select the Rectange1Style and change
Align to "Client"
Fill -> Kind to "Gradient"
Add a TMaskToAlphaEffect as child from the component palette by double clicking (Rectange1Style still selected)
Close the Style Designer and confirm applying the changes
If I change the Z-order of the TRectangle in the Style Designer, the effect also disappears in the Form Designer.
Am I missing something, or is it due to an incorrect Z-order at runtime, or is my approach fundamentally wrong?

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.)

How to place a component above a TMainMenu?

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.

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: Styled TMainMenu and TToolBar in TCoolBar

I'm attempting to create an application menu and toolbar in Delphi XE3 that looks like the following (from a program I have):
I'm able to replicate a portion of this look by doing the following:
Create a new VCL Forms application
Add a TMainMenu and insert template menus for File/Edit/etc.
Add a TCoolBar to the form
Add a TToolBar to the TCoolBar
Add a TToolButton to the TToolBar for each of File/Edit/etc. and choose the Group property
Delete the Menu property from the form (so no program menu shows)
Assign the MenuItem property for each TToolButton to the corresponding File/Edit/etc.
Add a second TToolBar to the TCoolBar beneath the first one
Here's what it looks like:
It's somewhat similar but is still missing all the style elements to modify the look of the new application menu.
My question is, does anyone know of how to achieve a similar look, perhaps with a third-party component library? It seems likely that the original developer used a third-party VCL library. I'd like the drop shadow in addition to the styled menus and TCoolBar.
I've tried Raize Components, TMS Advanced Toolbars & Menus, and am in the process of trying DevExpress VCL components. None of them seem to provide a solution, but perhaps I'm not familiar enough with them yet to figure it out.
Delphi has come with an ActionBands demo that can show you how to obtain this appearance "out of the box" for your menus using TActionMainMenuBar (and TActionToolBar). Just change the Style menu to XP Style in the demo:
The rest of your steps seem pretty well complete. For the images on the menu items and toolbar buttons, see the use of ImageList components in association with the TActions on the menu and toolbar in the demo.

Resources