Results 1 to 6 of 6

Thread: Place a Canvas on SpeedButton And TForm

  1. #1
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default Place a Canvas on SpeedButton And TForm

    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.

  2. #2
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow, i just needed this, thanks a million, + rep.

    Also, is it possible to have like 3 speed buttons all with different bitmaps on the form at once?

    And last question....when putting a bitmap on a form, is it possible to make the bitmap's background transparent? I think SetTransparentColor(Bitmap, clWhite); only works for debug canvases.

  3. #3
    Join Date
    Dec 2006
    Location
    utah
    Posts
    1,427
    Mentioned
    2 Post(s)
    Quoted
    7 Post(s)

    Default

    Thanks,


    yes you should be able to have 3 bitmaps with diffrent buttons..


    uhmm on TSpeedBitmap, change your background white and the canvas will blend in the background... if thats what you mean...

  4. #4
    Join Date
    Dec 2006
    Location
    In the SaMe WoRld as yOu
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey nice Tut,

    The main bit on this form is the button with picture? am i right?

    Wats is this speed button main used for?

    Can this be intergrated in a tabbed form?

    Yes, this may seem nooby but im willing to learn

    Thanks alot

    http://stats.srl-forums.com/be/SRL-S...erbars/305.png
    | Buying All Rune Ess - 30Ea | & | Buying P Ess As well |

    http://www.fenjer.com/adnan/SRLStats/305.png
    If I see you autoing with level 3 - Default clothes - Crap name I WILL report you.
    [ Auto Correctly: Put this in your signature, if you agree ]

    http://starblaster.freehostia.com/stress/Aje10.png

  5. #5
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by SKy Scripter View Post
    Thanks,
    uhmm on TSpeedBitmap, change your background white and the canvas will blend in the background... if thats what you mean...
    Yes, I noticed that, but not what I meant. Im trying to put a bitmap picture directly on the form using an Image thing. I used hwat is in the fastdrawtest script in the SRL scripts test folder. I think the method it uses is only for debug boxes though, but i want to use it on a form (not the moving part, just the transparency part)

  6. #6
    Join Date
    Aug 2007
    Posts
    104
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry to bump an old post

    But, if Rune Hacker is still wondering...I read a few tuts and I think this is right:

    MyForm.Brush.style := bsclear;

    Then load another canvas on top of the transparent background.

    Thank god I know Delphi...sure makes learning scar easier.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Canvas Help.
    By skilld u in forum OSR Help
    Replies: 3
    Last Post: 07-10-2008, 09:18 PM
  2. Canvas
    By Negaal in forum OSR Help
    Replies: 7
    Last Post: 01-30-2008, 05:57 PM
  3. canvas
    By ~~Amur~~ in forum OSR Help
    Replies: 7
    Last Post: 01-02-2008, 06:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •