was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

37 Visitors Online


 
...zur Laufzeit deaktivierte (disabled) Bilder für TSpeedButton / TBitBtn erzeugen?
Autor: FINANCES Ltd
Homepage: www.finances-ltd.narod.ru
[ Tip ausdrucken ]  

Tip Bewertung (6):  
     


procedure AddDisableBMP(SB : array of TObject);
var 
  
BM, SBM : TBitmap;
  w, x, y, NewColor, i : integer;
  PixelColor : TColor;
begin
  
BM := TBitmap.Create;
  SBM := TBitmap.Create;
  try
    for 
i := 0 to High(SB) do 
    begin
      if 
(SB[i] is TSpeedButton) then
        
BM.Assign((SB[i] as TSpeedButton).Glyph)
      else if (SB[i] is TBitBtn) then
        
BM.Assign((SB[i] as TBitBtn).Glyph)
      else 
        
Exit;

      if not Assigned(BM) or (BM.Width <> BM.Height) then Exit;

      w := BM.Width;
      SBM.Width := w * 2;
      SBM.Height := w;
      SBM.Canvas.Draw(0, 0, BM);

      for x := 0 to w - 1 do
        for 
y := 0 to w - 1 do 
        begin
          
PixelColor := ColorToRGB(BM.Canvas.Pixels[x, y]);
          NewColor := Round((((PixelColor shr 16) + ((PixelColor shr 8) and $00FF) +
            (PixelColor and $0000FF)) div 3)) div 2 + 96;
          BM.Canvas.Pixels[x, y] := RGB(NewColor, NewColor, NewColor);
        end;


      SBM.Canvas.Draw(w, 0, BM);

      if (SB[i] is TSpeedButton) then with (SB[i] as TSpeedButton) do 
        begin
          
Glyph.Assign(SBM);
          NumGlyphs := 2;
        end
      else 
        with 
(SB[i] as TBitBtn) do 
        begin
          
Glyph.Assign(SBM);
          NumGlyphs := 2;
        end;
      BM := TBitmap.Create;
      SBM := TBitmap.Create;
    end;
  finally
    
BM.Free;
    SBM.Free;
  end;
end;

 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners