Delphi 2010 vertical toolbar - delphi

I am using RAD Studio 2010 on Windows 10. Is there any way to create a vertical toolbar for Delphi VCL projects? Something similar to what is shown in the attached picture (right side, top to bottom, on main window):
I need selectable items.This mean changing in back color in clicking or when mouse move over it

You can do this with a TListView. Assign your images to a TImageList, and assign that ImageList to the ListView.LargeImages property. Add an item for each image you want to display using the Items property (or right-click on the ListView and choose New Item from the context menu), assigning the proper caption and imageindex for each item. Make sure the ListView.ViewStyle is set to vsIcon, and the ListView.ItemOptions.AutoArrange is set to True.
Here's a sample of the result of a quick test app with a few random images I added - just a few 32x32 images in the Win10 style, courtesy of Icons8. It shows the highlighted Button 3 item as the mouse pointer is hovering over it.
The only drawback to using the TListView is that if the dialog is sized so that all items in the ListView aren't visible, the ListView will display a vertical scrollbar automatically. You'll want to make sure that you leave enough space for that scrollbar just in case, or restrict your window's MinHeight constraint to prevent it from being resized too small. On the other hand, if you want to display more than one item in each row, it's easily accomodated with the TListView - just widen the control to allow more items per row, and the AutoArrange property will take care of everything.

Related

Align a component exactly in the middle of a panel

I have a TRichEdit and a TButton on a TPanel, which is not aligned in the centre of the panel:
Is there a quicker way to align these components in the centre of the panel, than just by dragging it around and guessing if it is in the centre?
Also, I am using Delphi 2010.
I tried selecting the components and using the alignment options:
But it only aligned the button to the rich edit:
First, you must not select the panel, because that is not involved in this process.
Second, there is another toolbar Position that has a button to center the selected elements inside its parent.
I have no Delphi 2010 at hand, so I cannot provide a screenshot, but both icons look quite similar.
Quickest way for aligning components at design time is by using right-clicking on specific component and then choosing Position->Align from the shown popup menu.
If you want to align your component to the center of the parent then chose Center in window for either horizontal or vertical alignment whichever you need. If you have multiple components selected Delphi will align the whole group to the center of the parent and not each individual component to the center of the parent.
If you want to align one component to the center position of another other component then select the two components first and then right click on the component on which you want your component to be centered on. And now in popup menu select Position->Align and in the opened window chose Centers wither for horizontal or vertical alignment based on what you need.

How resize a cxgrid with the mouse?

I have 4 cxgrid into a cxTabSheet, 3 aligned albottom and 1 aligned alClient...
When the mouse is over the edge of any cxgrid, the cursor mouse doesn´t change to the crSize(NS, WE, NESW, NWSE) and cannot select the border of grid for drag the mouse and resize it.
How can I do this?
The easiest way to do this, without writing any code, is to use one or more splitters on your form: see TSplitter and the Devex custom version, TcxSplitter, in the online help.
To use, place one or more splitters on the form orientated to allow resizing of the grid(s) as you wish, then place the grids on the appropriate areas of the splitters, or on panels on the splitters. One splitter can be placed inside another, so that you can have one resizable area inside another.

Delphi: how to create a "thumb" which can sit above the vertical scrollbar?

MS Word has such a feature:
Small rectangle is shown above vert scrollbar and is clickable.
I want to add such thumb above vertical scrollbar of my TMemo descendant, for example. How can I? I need to handle click on such thumb - show split screen (show 2nd memo).
Word constructs this form in a custom fashion - it separately adds the thumbs and the scrollbar to the window. To emulate this behaviour in VCL you would have to do the same - instead of instantiating a TMemo, make a custom control containing the memo, and a regular scroll bar, and use positioning to put a tiny button above the scrollbar with the same width.

How to offset the position of the cursor in an edit control?

I'm building a custom edit control which consists of adding both an icon at the left and an icon button at the right, both inside the edit control. This requires shifting the starting point of the text (and cursor) to the right by X amount of pixels. This also means I need to 'Limit' how wide the text can be drawn too, to make room for the button on the right. The intention is to provide both a custom icon on the left, such as in a browser, as well as an 'X' button on the right to clear the contents of the edit control.
How to offset the Rect of where to draw the text and cursor in a TCustomEdit descendant?
If you are using more recent version of Delphi, there should already be a TButtonedEdit Control and can do your work.
If not, I think you can send a EM_SETMARGINS message to your TCustomEdit to set the left and right margin.
SendMessage(CustomEdit.Handle, EM_SETMARGINS, EC_LEFTMARGIN or EC_RIGHTMARGIN, MakeLong(LeftMargin, RightMargin));

Delphi.Stretch Control (anchors:l,r,t and align:alNone) if one Control is Invisible

Did anybody do this?
If I have 2 components on a form, 1-st is invisible, 2-d (which has anchors:left,right,top and align:alNone) must fill space of invisible control. For example, if you have uTorrent try to hide list of categories then listview will immediately fill free space.
How to do this?
Thanks!
Just set Align of second control to alClient and it will do just that (filling the available space). You do not need to set the Anchors in this case.

Resources