How to avoid image is Hidden by Button - delphi

I have kept an TImage component at the Top-right corner of a bitbutton.While loading of Form some part of image is Hidden by Button as like in image .How to avoid this.? and also tell me how to find corner of a Button such that i can place my image correctly to show notification correctly in case of Dynamically loaded buttons.
Yours Rakesh.

A TImage cannot be brought in front of a TBitButton since a BitButton is a windowed control (TWinControl). Instead of a TBitBtn or a TButton, you can use a control which does not descend from TWinControl, like a TSpeedButton.
The top-right corner of a button is at (Button.Left + Button.Width, Button.Top).

A TBitButton owns a window handle and only controls with an own window handle can be placed in front of it. You could place your bitmap on a TPanel (TPanel inherits from TWinControl and has a window handle), and this panel you can bring in front of any other control. Set the BorderStyle of the panel to bsNone, so it only works as a container and is not visible.
P.S. If your bitmap is as simple as the one in your example, you could directly write onto the panel and set the colors accordingly.

Related

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 - How to change a TButton background color in a VCL Form Application?

In my Delphi VCL Form Application I have to change the background color of a TButton.
Is there a way to apply this change without using a third-party components?
Thanks.
You can't change the color of a TButton component directly, instead you must use a third-party component or owner draw the button (BS_OWNERDRAW).
Create a panel.
Change panel's color to any color.
Empty panel's caption.
Create a SpeedButton inside the panel.
Set SpeedButton's Flat property True.
Set SpeedButton's Align propert alClient.
Voila! Here is your button with color!
Original source: https://engineertips.wordpress.com/2020/07/21/delphi-button-background-color/
Nice tip, thank you, Xel Naga!
You can also place an image on the panel, to make your button even nicer.
Here I’ve added an image of a Yellow- Glass- button.
To get the rounded corners, you shape the panel like this >>
SetWindowRgn(Panel1.Handle, CreateRoundRectRgn(0, 0, Panel1.Width, Panel1.Height, 65, 40), True);
Next level after that, you can add 3 more images (on top of each-other) for button states: Mouse Over (OnMouseEnter), Button Pressed (OnMouseDown) and Button Disabled. Just change the Visible state of the images to reveal the one you want to see...

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.

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.

How to check if form is maximized?

I'm having a problem with a component I use.Its aligned to bottom ,and ,when form is maximized,the control is placed at the correct position,but when I attempt to minimize the form,the control stays at the position where it is.
I tried using a timer that always sets the align to bottom,but I'm sure a timer is the worst solution to my issue.
Please suggest a way to set the align to Bottom when the form is restored from maximize.(maximize->restore only).
My current idea is to check if form is maximized at FormResize event,but that won't work,because I need to do it when its restored,not maximized.
You can check if a form is maximised by using
Self.WindowState = wsMaximized
Other states are
wsNormal
wsMinimized
wsMaximized
Depending on what you are doing, you could also place the control on a panel and align the panel to the bottom of the form, if you turn the borders off and use the parent colour, you cant see the panel, that way it will stay at the bottom of the form without additional code.

Resources