Autor Beitrag
FriFra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 557

Win XP Prof, Win XP Home,Win Server 2003,Win 98SE,Win 2000,Win NT4,Win 3.11,Suse Linux 7.3 Prof,Suse Linux 8.0 Prof
D2k5 Prof, D7 Prof, D5 Standard, D3 Prof, K3 Prof
BeitragVerfasst: Sa 16.07.05 17:55 
Wenn man 2 ImageLists verwendet wovon eine die aktiven und die andere die inaktiven Images beinhaltet, kann man diese auch verwenden um Glyphs für BitBtn bzw. Speedbuttons zu erzeugen.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
  function GlyphFromImageLists(Source1, Source2: TImageList; Index: integer;
    BkColor: TColor): TBitmap; overload;
  var
    bmp1, bmp2: TBitmap;
    R1, R2: TRect;
    bColor1, bColor2: TColor;
  begin
    bColor1 := Source1.BkColor;
    bColor2 := Source2.BkColor;
    Source1.BkColor := BkColor;
    Source2.BkColor := BkColor;
    bmp1 := TBitmap.Create;
    bmp2 := TBitmap.Create;
    Result := TBitmap.Create;
    try
      Source1.GetBitmap(Index, bmp1);
      Source2.GetBitmap(Index, bmp2);
      R1.Left := 0;
      R1.Top := 0;
      R1.Right := bmp1.Width;
      R1.Bottom := bmp1.Height;
      R2.Left := bmp1.Width;
      R2.Top := 0;
      R2.Right := bmp1.Width * 2;
      R2.Bottom := bmp1.Height;
      Result.Width := bmp1.Width * 2;
      Result.Height := bmp1.Height;
      Result.Canvas.CopyRect(R1, bmp1.Canvas, R1);
      Result.Canvas.CopyRect(R2, bmp2.Canvas, R1);
    finally
      bmp1.Free;
      bmp2.Free;
      Source1.BkColor := bColor1;
      Source2.BkColor := bColor2;
    end;
  end;
  function GlyphFromImageLists(Source1, Source2: TImageList; Index: integer):
      TBitmap; overload;
  begin
    Result := GlyphFromImageLists(Source1, Source2, Index, clBtnFace);
  end;


Anwendung:
ausblenden Delphi-Quelltext
1:
2:
BitBtn1.Glyph.Assign(GlyphFromImageLists(ImageList1, ImageList2, 21));
BitBtn1.NumGlyphs := 2;

_________________
Michael
(principal certified lotus professional - developer)