Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Button auf ComboBox (https://www.delphipraxis.net/27037-button-auf-combobox.html)

NicNacMan 3. Aug 2004 10:33


Button auf ComboBox
 
hi,

ich hab ein kleines problem beim zeichnen auf eine combobox:
ich will ein transparentes bitmap auf den button zeichnen,
aber wenn das bild kleiner ist als das rect, wird es nicht gezeichnet
(scheint an "Brush.Style := bsClear" zu liegen, da es ohne geht).
mit offsetx/-y zentrier ich das bild.

Delphi-Quellcode:
var
  OffsetX, OffsetX: Integer;
  R, Rgfx        : TRect;
  C              : TControlCanvas;

...

  if (not FPicture.Empty) then
    begin
      FPicture.TransparentColor := FTransparentColor;
      FPicture.Transparent := FTransparent;

      OffsetX := (Rgfx.Right - Rgfx.Left - FPicture.Width ) div 2;
      OffsetY := (Rgfx.Bottom - Rgfx.Top - FPicture.Height) div 2;
      R := Rgfx;
      OffsetRect(R, -R.Left-OffsetX, -R.Top-OffsetY);

// so gehts zwar, aber ohne transparent
      C.CopyRect(Rgfx, FPicture.Canvas, R);


// und so gehts nur, wenn das bild größer ist, als Rgfx
      C.Brush.Style := bsClear;
      C.BrushCopy(Rgfx, FPicture, R, FTransparentColor);

    end;

...
ich habs auch schon mit einem 2ten bitmap (weil ich FPicture nicht verändern will) versucht,
in das ich dann den teil, den ich brauche kopiere, und dann das 2te bitmap mit Canvas.Draw zeichne.
das ging zwar, aber da ich das ganze in meiner komponente verwende, fängt die an zu flackern.

gibt es noch andere möglichkeiten, transparent teile eines bitmaps zu kopieren?
den ganzen aufwand mach ich ja eigentlich nur, weil das bild mittig auf dem button sitzen soll,
und der rand nicht über die eingabefläche der combobox gezeichnet werden soll,
kann man das vll auch einfacher lösen (also das zentrieren meine ich)?

thx schonmal
nicnacman

omata 29. Sep 2004 23:25

Re: Button auf ComboBox
 
Moin,

was spricht gegen einen SpeedButton?


MfG
Thorsten


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:49 Uhr.

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