Solved

Moving window without a taskbar

Posted on 1998-01-09
4
149 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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Thread safe  opinion 7 126
Making delphi communicate with a c# service 16 89
Create a path if not exists 7 69
Base1 Encode/Decode 3 68
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now