Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Resizing Form

Posted on 2001-06-25
8
Medium Priority
?
203 Views
Last Modified: 2010-04-06
Hi
how can i tell a form to resize just in vertical,
and when mouse is over the corners, the cursor change to vertical arrow?

thanks in advance
Nima,
0
Comment
Question by:Mohamadi
  • 4
  • 2
  • 2
8 Comments
 
LVL 1

Expert Comment

by:z_darius
ID: 6226117
all you need to do is this:

1. declare

const
  maxW=100;

2. initialize form's width in FormCreate method to the desired value (from the constant)

procedure TForm1.FormCreate(Sender: TObject);
begin
  width:=maxW;
end;

3. using FormResize method keep the width at constant's value

procedure TForm1.FormResize(Sender: TObject);
begin
  if (width > maxW) or (width < maxW)then
    width:=maxW;
end;
0
 
LVL 4

Expert Comment

by:StevenB
ID: 6226415
 You can also implement this at design time by using the forms Constraints property and setting MaxWidth and MinWidth the the same value.
0
 

Author Comment

by:Mohamadi
ID: 6229457
thanks,
but how can i tell the form to change the cursor to vertical arrow, not the slip one,

i saw this ability in MS Money 97, in the search form.

thanks agian
Nima,
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 4

Expert Comment

by:StevenB
ID: 6229582
One solution would be to do this:

1) Set the forms BorderStyle property to bsSingle.

2) Declare this constant in the interface section of the form's code:
  const
    DragRegion = 10;

3) Declare these variables in the form declaration:
  private
    fMouseDown : Boolean;
    fMouseDownY : Integer;
    fInitialHeight : Integer;

4) Add these event handlers to your form:

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  If (Y > (ClientHeight - DragRegion)) then begin
    fMouseDown := True;
    fInitialHeight := Height;
    fMouseDownY := Y;
  end;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  If (Y > (ClientHeight - DragRegion)) then Screen.Cursor := crSizeNS
  else Screen.Cursor := crDefault;
  If fMouseDown then begin
    Height := fInitialHeight + (Y-fMouseDownY);
  end;
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  fMouseDown := False;
end;




The full code from my test application unit is:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;

const
  DragRegion = 10;

type
  TForm1 = class(TForm)
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    fMouseDown : Boolean;
    fMouseDownY : Integer;
    fInitialHeight : Integer;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  If (Y > (ClientHeight - DragRegion)) then begin
    fMouseDown := True;
    fInitialHeight := Height;
    fMouseDownY := Y;
  end;
end;

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  If (Y > (ClientHeight - DragRegion)) then Screen.Cursor := crSizeNS
  else Screen.Cursor := crDefault;
  If fMouseDown then begin
    Height := fInitialHeight + (Y-fMouseDownY);
  end;
end;

procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  fMouseDown := False;
end;

end.



  There may be a neater solution that interfaces directly with the Windows API, but I couldn't find it after a brief look. This, however, achieves what you want I think.

  Steven.


0
 
LVL 1

Expert Comment

by:z_darius
ID: 6233583
Mohamadi,

I think it's time to award points, just in case you want have any kind of credibility for the future. Some folks (and I don't include myself) did some good job answering your questions. Now, show their answers were worth the effort.
0
 
LVL 4

Accepted Solution

by:
StevenB earned 30 total points
ID: 6233598
 Mohamadi has a good grading record, I'm sure he's just not available, or is checking the suggested solutions.
0
 

Author Comment

by:Mohamadi
ID: 6233643
Thanks for your answer.
but as you said, there migth be a windows API function which changes the form's style.
if you find that i would be very happy to heare from you
my Email is Mohamadi@neda.net

thanks
with best regard
Nima,
0
 
LVL 4

Expert Comment

by:StevenB
ID: 6233649
 If I find anything I'll be sure to let you know.

  Cheers, Steven.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question