uhmm im no tut writer, so i typed a simple script.. im sure youll learn somthing from it...
after all i havent seen anyone use OnPaint Except Kiat..
Edit : i think i saw YAKMAN use OnPaint...
and i never seen anyone peroid. put a canvas on Speed Button
so maybe you can learn how look at this
SCAR Code:
program New;
const
FormPosX = 10;
FormPosY = 10;
var
MainForm : TForm;
SpeedButton : TSPEEDBUTTON;
Bitmap : Integer;
Canvas : TCanvas;
procedure OnPaint(Sender : TObject);
begin
if (Sender is TForm) then // Draw The Pic to the form...
CopyCanvas(Canvas, TForm(Sender).Canvas, 0, 0, 34, 27, FormPosX, FormPosY, 34 + FormPosX, 27 + FormPosY);
end;
procedure InitForm;
begin
MainForm := CreateForm;
MainForm.SetBounds(0, 0, 300, 200);
MainForm.POSITION:= poDesktopCenter;
MainForm.BORDERICONS:= [biMinimize, biSystemMenu];
MainForm.BORDERSTYLE:= bsSingle;
MainForm.Color := 0;
MainForm.Caption := 'Place a pic on Speedbutton and form';
MainForm.Onpaint := @OnPaint;
SpeedButton := TSpeedButton.Create(MainForm);
SpeedButton.parent:= MainForm;
SpeedButton.SetBounds(90, 80, 100, 30);
SpeedButton.Caption := 'SCAR';
SpeedButton.Glyph.Width := 34; // The Width you with the canvas on the buttion to be
SpeedButton.Glyph.Height := 30; // the height for the canvas...
SpeedButton.Layout := blGlyphLeft; // Use Layout For Other Postions blGlyphRight, bottom, ect
SpeedButton.Margin := 1; // this will control the margin
SafeCopyCanvas(Canvas, SpeedButton.Glyph.Canvas, 0, 0, 34, 27, 0, 0, 34, 27);
MainForm.ShowModal;
end;
procedure SafeInitForm;
var
v: TVariantArray;
begin
setarraylength(V, 0);
ThreadSafeCall('InitForm', v);
end;
procedure LoadBitmaps;
begin
Bitmap := BitmapFromString(34, 27, 'z78DAED98D10E83200C457F6999C6' +
'CDC7858CFFFFA46534C6ABA5D882222EBB0F3C188DF7E4B650F5F' +
'EAFB86EA0EBFB1F8669BD0A97E45F5A5BE3B2FA6F998BDEEE5CD7' +
'95B178EF5C1B2C4864E1FAFA478A16EA8DFCEBB8E2FE5BA040E75' +
'4F7BCFE27A2B5FF67D03BE82C16DEEF980B5D211EA4C23B918E88' +
'6AA693DEAF90659D8ACC885C9894862B8F9AD73FEF05DE2F120B4' +
'ACA2E9DD7B2066C14F846BE2EB9C6715A352CBA7D6FBD571CC7A2' +
'E78AF58BE47F7E563A837825E8591E4C76AED4892FFB4F4F08DA1' +
'316FB9144147D502E577CC7B0F8CF9916E89E1EB42F579AC532E9' +
'6D1321CB2BE8082E6967D8F28F35A94DE71E449E39513957AEFF9' +
'9C29A8E445492976EC64EFBCFAF37E42ACF4B66B1F98FE59B33CF' +
'58F3C274622C35FCEF95175D97D3A9EDBF242F5D3AE7F8B7E6855' +
'DC36736FC0E6AF38F8D3C39FFDA9FB4A3F501DD2D25B8');
Canvas := GetBitmapCanvas(Bitmap);
end;
begin
try
LoadBitmaps;
SafeInitForm;
finally
FreeForm(MainForm)
FreeBitmap(Bitmap);
except
Writeln('ERROR: With Loading');
end;
end.