Source Code



Resizable forms and size grip

  • anonymous
  • Dec 18' 13
  • Delphi
  • 278
  • 85
  • United States

When a form has a sizable border, ther is no default way to supply a visual cue but using a status bar. Luckily a window API may help us. The API in question is DrawFrameControl.



How the name suggests, this API is used to draw the frame of various controls such as buttons, check boxes, menus and, yes, size grips just by supplying a display context and the proper flags.


Here is a sample code on how to use this API in a regular Deplhi form with sizable border.

 

unit PasarKode;

interface

uses
  Windows, Forms;

type
  TfrmTest = class(TForm)
    procedure FormResize(Sender: TObject);
    procedure FormPaint(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmTest: TfrmTest;

implementation

{$R *.DFM}

procedure TfrmTest.FormResize(Sender: TObject);
begin
     Self.Repaint;
end;

procedure TfrmTest.FormPaint(Sender: TObject);
var
   rectBounds: TRect;
begin
     rectBounds := Self.ClientRect;

     with rectBounds do
     begin
          Left := Right - GetSystemMetrics(SM_CXVSCROLL);
          Top := Bottom - GetSystemMetrics(SM_CYVSCROLL);
     end;

     {Here is the magic!!}
     DrawFrameControl(Self.Canvas.Handle, 
                      rectBounds, 
                      DFC_SCROLL, 
                      DFCS_SCROLLSIZEGRIP);
end;

end.
  • Tags : delphi, resize, grip
comments powered by Disqus

Related Code

Simple Like Function

Suspend the PC

Get current url

Using WinZip as a backup tool

Upper the first letter of each word

Rotate Font

Access the controls of a TRadioGroup

fairly nominal



Category

Tag Linked