Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make a new resize area 1

Status
Not open for further replies.

Nordlund

Programmer
Jul 17, 2001
458
SE
Hi there.
The TStatusbar does not support sizegrip if it's placed on a TPanel. (Delphi 7)

I want to duplicate the resize funktion the TStatusbar has, and place it on a regulal TPanel...

Quick solutions anyone?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is always another way to solve it, but I prefer my way.
 
You made the jump from Delphi 3? I found out by accident when recompiling in Delphi 5, that the size grip disappeared. The statusbar "wants" to be on the bare form and is automatically aligned to AllBottom
Just put the panels on the form after the statusbar.

Steven
 
Nordlund,
do you want to resize the panel or the form where the panel resides?

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
I'm building a new Combobox, and the Dropdown window should have a sizegrip.

I have solved this by creating a new TGripPanel component The component is quick'n'dirty, just to cover my needs, no nifty published properties and so on.. :)

Code:
  TGripPanel = class(TCustomPanel)
  private
    FOwnerCombo: TCompleteCombo;
    function GetGripRect: TRect;
  protected
    procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
    procedure Paint; override;
  public
    constructor Create(AOwner: TComponent); override;
  end;

{ TGripPanel }

constructor TGripPanel.Create(AOwner: TComponent);
begin
  inherited;
  ControlStyle := ControlStyle - [csSetCaption];
  ParentFont := false;
end;

function TGripPanel.GetGripRect: TRect;
var
  GripWidth: integer;
  GripHeight: integer;
begin
  GripWidth := GetSystemMetrics(SM_CXHSCROLL) ;
  GripHeight := GetSystemMetrics(SM_CYVSCROLL) ;
  Result.Left := Width - GripWidth +6;
  Result.Top := Height - GripHeight +6;
end;

procedure TGripPanel.Paint;
var
  Rect: TRect;
begin
  inherited;

  Rect := GetGripRect;
  with Self.Canvas do
  begin
    Brush.Style := bsClear;
    Font.Name := 'Marlett';
    Font.Size := 8;

    Pen.Color := clred;
    Font.Color := clGray;
    TextOut(Rect.Left, Rect.Top, 'o');

    Font.Color := clWhite;
    TextOut(Rect.Left, Rect.Top, 'p');
  end;
end;

procedure TGripPanel.WMNCHitTest(var Msg: TWMNCHitTest);
var
  ScreenPt: TPoint;
begin
  inherited;

  if not (csDesigning in  ComponentState) and (Msg.Result = HTCLIENT) then
  begin
    ScreenPt := ScreenToClient(Point(Msg.Xpos, Msg.Ypos));
    if (ScreenPt.X >= GetGripRect.Left) and (ScreenPt.Y >= GetGripRect.Top) then
      Msg.Result := HTBOTTOMRIGHT
    else
      Msg.Result := 0;
  end;
end;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There is always another way to solve it, but I prefer my way.
 
a star for your own solution :)

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top