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

x
?
Solved

Moving window without a taskbar

Posted on 1998-01-09
4
Medium Priority
?
159 Views
Last Modified: 2010-04-04
I'm creating an application which uses the bsNone Borderstyle. How can I give the user the ability to move, but not resize this window? I'm not trying to do anything fancy lke a solid drag or anything, all I want is to be able to move the window.
0
Comment
Question by:AJFleming
  • 2
4 Comments
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1356010
AJFleming,

  In the OnResize Event of the form:

var  X,Y: Integer;

X = Form1.Width;
Y = Form1.Height

Form1.Width := X;
Form1.Height := Y;

This will allow the user to resize the window but as soon as they let go of the mouse the window will "snap back" to it's origional size.

Good luck with your project!
Pegasus;
0
 
LVL 1

Author Comment

by:AJFleming
ID: 1356011
Sorry, maybe I wasn't clear enough in my question. The lack of resize is already sorted out, what I need is a way to drag a form without it having a title bar (or having an invisible title-bar.) using a bsNone border style doesn't appear to let the user move the window...
0
 
LVL 3

Accepted Solution

by:
Matvey earned 150 total points
ID: 1356012
Try this, it works!

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

var Moving: boolean;
OldX, OldY, OldLeft, OldTop: integer;
{$R *.DFM}

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
   if (Button = mbLeft) then begin
            Moving := True;
            OldX := X;
            OldY := Y;
            OldLeft := X;
            OldTop := Y;
   end;

end;

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

procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
   if Moving then begin
         OldX := X;
       OldY := Y;
            SetBounds(      Left+OldX-OldLeft,
                               Top+OldY-OldTop,
                                  Width,
                                  Height);
   end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Moving := false;
end;

end.

Good luck,
Matvey
0
 
LVL 1

Author Comment

by:AJFleming
ID: 1356013
Thanks... That works great...
0

Featured Post

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.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

772 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