| |
| Keeping a glyph's transparent area transparent. |
 |
Under some video modes, the transparent area of the standard
TBitBtn glyphs turns gold or maroon. How can I keep the standard
TBitBtn's glyph transparent?
The following example demonstrates a technique where the
transparent portion of the glyph is filled with the background color
of the button, making the glyph appear transparent. Example: function InitStdBitBtn(BitBtn : TBitBtn;
kind : TBitBtnKind) : bool;
var
Bm : TBitmap;
Bm2 : TBitmap;
begin
Result := false;
if Kind = bkCustom then exit;
Bm := TBitmap.Create;
case Kind of
bkOK : Bm .Handle := LoadBitmap(hInstance, 'BBOK');
bkCancel : Bm .Handle := LoadBitmap(hInstance, 'BBCANCEL');
bkHelp : Bm .Handle := LoadBitmap(hInstance, 'BBHELP');
bkYes : Bm .Handle := LoadBitmap(hInstance, 'BBYES');
bkNo : Bm .Handle := LoadBitmap(hInstance, 'BBNO');
bkClose : Bm .Handle := LoadBitmap(hInstance, 'BBCLOSE');
bkAbort : Bm .Handle := LoadBitmap(hInstance, 'BBABORT');
bkRetry : Bm .Handle := LoadBitmap(hInstance, 'BBRETRY');
bkIgnore : Bm .Handle := LoadBitmap(hInstance, 'BBIGNORE');
bkAll : Bm .Handle := LoadBitmap(hInstance, 'BBALL');
end;
Bm2 := TBitmap.Create;
Bm2.Width := Bm .Width;
Bm2.Height := Bm .Height;
bm2.Canvas.Brush.Color := ClBtnFace;
bm2.Canvas.BrushCopy(Rect(0, 0, bm2.Width, bm2.Height),
Bm ,
Rect(0, 0, Bm .width, Bm .Height),
bm .canvas.pixels[0,0]);
bm .Free;
LockWindowUpdate(BitBtn.Parent.Handle);
BitBtn.Kind := kind;
BitBtn.Glyph.Assign(bm2);
LockWindowUpdate(0);
bm2.Free;
Result := true;
end; procedure TForm .Button Click(Sender: TObject);
begin
InitStdBitBtn(BitBtn , bkOk);
end; 7/ 6/98 4:3 :28 PM
|
|
| Hits/month |
2,500,000+ |
Downloads (Since May 2000) |
7,393,709 |
| Total Files |
6,023 |
| Forum msgs |
7,670 |
| Articles/FAQs |
70+/900+ |
Top Selling Software at Amazon
|