Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi Ungewollte Transparenz bei einem ToolbarButton (https://www.delphipraxis.net/123305-ungewollte-transparenz-bei-einem-toolbarbutton.html)

Xong 30. Okt 2008 13:58


Ungewollte Transparenz bei einem ToolbarButton
 
Hallo liebe DPler!
Ich verdreifle gerade.
Ich nutze die Komponente TAdvToolBar von TMS, um Buttons vom Typ TAdvToolBarButton als grafische Buttons anzeigen zu lassen.
Das funktioniert auch prima. Allerdings werden die Bilder vom Typ TBitmap immer mit einer Transparenzfarbe versehen. Alle Pixel mit der Farbe des linken unteren Pixels werden transparent dargestellt. Ich versuche, diese Transparenz abzuschalten.
Im OnCreate des Testformulars verändere ich dazu die Transparent-Eigenschaft der Eigenschaft Glyph des Buttons auf "false" und versuche noch ein paar andere Sachen. Trotzdem bleibt die Transparenz erhalten.
Delphi-Quellcode:
  AdvToolBarButton1.Glyph.Transparent := false;
  AdvToolBarButton1.Glyph.TransparentColor := clGreen;
  AdvToolBarButton1.Glyph.TransparentMode := tmFixed;
  AdvToolBarButton1.Glyph.Canvas.Refresh;
  AdvToolBarButton1.Update;
  AdvToolBarButton1.Refresh;
  AdvToolBarButton1.Repaint;
Ich weiß nicht, was ich sonst noch alles versuchen könnte.

Das Problem ist, dass die Nutzer des Programms später weitere Buttons hinzufügen können. Sie sollen auch eigene Bilder verwenden dürfen. Deshalb kann ich das Problem nicht einfach umgehen, in dem ich das Bild an mein Problem anpasse.

Hat jemand eine Idee, was ich tun könnte, damit die Transparenz deaktiviert wird?

LG,
Xong

PS: Entwicklungsumgebung ist Windows 2003 mit Delphi Developer Studio 2006

OldGrumpy 30. Okt 2008 15:37

Re: Ungewollte Transparenz bei einem ToolbarButton
 
Setz mal die Eigenschaft "ParentBackground" auf False.

Xong 30. Okt 2008 15:56

Re: Ungewollte Transparenz bei einem ToolbarButton
 
Danke für deine Antwort.
Zitat:

Zitat von OldGrumpy
Setz mal die Eigenschaft "ParentBackground" auf False.

Ich kann diese Eigenschaft nicht finden und auch nicht setzen. :(

Wenn ich übrigens statt der Eigenschaft Glyph des Buttons das Bild über die Eigenschaft Picture setze, dann funktioniert es ohne Transparenz. Allerdings auch nur, wenn ich keine Bitmapdatei lade.
Ich finde das komisch und irgendwie auch inkonsequent.

Wenn der Support von TMS sich meldet, gebe ich mal hier ne Rückmeldung.

LG,
Xong

Xong 3. Nov 2008 10:57

Re: Ungewollte Transparenz bei einem ToolbarButton
 
Der Support hat sich gemeldet.

Meine Email:
How to avoid transparency of an bitmap-image assigned to a TAdvToolbarButton?
Hi!

I am currently using your component TAdvToolBar to create a toolbar like it is described in the tutorial at http://www.tmssoftware.com/site/atbdev.asp
To create image-toolbarbuttons I assign an bitmap-image to the Glyph-property of the button. Unfortunatly, the image is drawn with transparency. The color of the pixel in the bottom left corner of the image is set as the transparency-color. I do not want to have this transparency.

How can I avoid this?

I tried to set the Transparent-property of the Glyph to false, but this affected nothing.
Do I have to call something like an Update-method to see the change?

My System is Windows 2003 with Borland Developer Studio 2003.

I am looking forward to hear from you soon.

Yours,
Robert Rupf

PS: I tried to set the Picture-property of the Button. If I use a bitmap-file the image has transparency, with a png-file i dont get transparency.
So, how can I allow to assign bitmaps (without transparency of course...)?


Die Antwort:
RE: How to avoid transparency of an bitmap-image assigned to a TAdvToolbarButton?
Currently, when a glyph is used , it is hardcoded that this glyph or
picture is drawn with transparency. If you do not want transparency,
this will have to be changed in the method

procedure TAdvCustomToolBarButton.DrawGlyphAndCaption

by removing the calls:

AGlyph.Transparent := true;

and

FPicture.Graphic.Transparent := true;

Thanks for your interest in our components and
let us know if we can be of any further help.



Meine Lösung:
Einfaches Überschreiben der Methode ist nicht möglich. Man muss die gesamte Komponente ändern.
Dafür legt man eine neue Unit im Projekt an, die genauso, wie die alte heißt, also AdvToolBar.pas.
Darin werden die zwei oben genannten Codezeilen auskommentiert und fertig ist das untransparente Bild.

Alternativ kann man natürlich auch eine eigene Komponente ableiten...

LG,
Xong


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:35 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz