Anyone knows Tbutton with Glyph and Windows XP theme compatible, sample code included
Hi all,
Does anyone know of a Tbutton decendant with an option to put a icon on it?
The Speedbutton and TbitBtn are NOT theme aware Tbutton IS.
I'we added some code snippet to prove it IS possible in theory
Ive added the following manifest mtheme.res from .rc script to the project
-------------------------------------------------------------------
1 24 "themed.manifest"
themed.manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
<assemblyIdentity
name="Genaral Application"
processorArchitecture="x86"
version="1.0.0.0"
type="win32"/>
<description>Windows Shell</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
-------------------------------------------------------------------
I'we added some code snippet to prove it IS possible in theory
-------------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, SKbutton, ExtCtrls, Buttons;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Image1: TImage;
BitBtn1: TBitBtn;
SpeedButton1: TSpeedButton;
procedure getbuttoncanvas;
procedure Button2Click(Sender: TObject);
procedure Button1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
public
{ Public declarations }
mybitmap:Tbitmap;
buttoncanvas:integer;
end;
var
Form1: TForm1;
MyIcon : TIcon;
implementation
{$R *.DFM}
procedure Tform1.getbuttoncanvas;
begin
mybitmap:=Tbitmap.create;
mybitmap.height:=button1.height;
mybitmap.width:=button1.width;
buttoncanvas:=getdc(button1.handle);
mybitmap.canvas.handle:=buttoncanvas;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
getbuttoncanvas;
{ create our TIcon }
MyIcon := TIcon.Create;
MyIcon.Assign(Image1.Picture );
try
{ draw our TIcon }
mybitmap.canvas.Draw(5, 5, MyIcon);
finally
{ free our TIcon }
MyIcon.Free;
end;
end;
procedure TForm1.Button1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
Button2Click(Self);
end;
end.