1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

TSplitter enhanced with grab bar

Discussion in 'Delphi Programming' started by AdminDF, Mar 13, 2014.

  1. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    Recently someone asked me what splitter component I had used in my (very secret) resource editor. The splitter is a very simple descendant of the standard VCL TSplitter. The only difference from the standard one is that my custom splitter sports a grab bar, bumps, knobs or whatever they are called.
    The source for the custom splitter is only about 40 lines of code so I thought I might as well just post it here and let everyone benefit from it. The source also demonstrates a very useful technique that I often use to customize the standard VCL components without the hassle of having to create design time packages.
    It’s really very simple so without further ado here comes:

    [​IMG]

    Code:
    unit amSplitter;
    
    interface
     
    uses
      ExtCtrls;
     
    //------------------------------------------------------------------------------
    //
    //      TSplitter enhanced with grab bar
    //
    //------------------------------------------------------------------------------
    type
      TSplitter = class(ExtCtrls.TSplitter)
      protected
        procedure Paint; override;
      end;
     
    implementation
     
    uses
      Windows, Graphics, Controls, Classes;
     
    //------------------------------------------------------------------------------
    //
    //      TSplitter enhanced with grab bar
    //
    //------------------------------------------------------------------------------
    procedure TSplitter.Paint;
    var
      R: TRect;
      X, Y: integer;
      DX, DY: integer;
      i: integer;
      Brush: TBitmap;
    begin
      R := ClientRect;
      Canvas.Brush.Color := Color;
      Canvas.FillRect(ClientRect);
     
      X := (R.Left+R.Right) div 2;
      Y := (R.Top+R.Bottom) div 2;
      if (Align in [alLeft, alRight]) then
      begin
        DX := 0;
        DY := 3;
      end else
      begin
        DX := 3;
        DY := 0;
      end;
      dec(X, DX*2);
      dec(Y, DY*2);
     
      Brush := TBitmap.Create;
      try
        Brush.SetSize(2, 2);
        Brush.Canvas.Brush.Color := clBtnHighlight;
        Brush.Canvas.FillRect(Rect(0,0,1,1));
        Brush.Canvas.Pixels[0, 0] := clBtnShadow;
        for i := 0 to 4 do
        begin
          Canvas.Draw(X, Y, Brush);
          inc(X, DX);
          inc(Y, DY);
        end;
      finally
        Brush.Free;
      end;
     
    end;
     
    end.

    Usage
    Place a standard TSplitter on a form.
    Add amSplitter to the interface section uses clause.

    Code:
    interface
     
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, ExtCtrls,
      amSplitter;
    Compile and Run .
     
    paramithas likes this.

Share This Page