Solved

Moving window without a taskbar

Posted on 1998-01-09
4
157 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month5 days, 13 hours left to enroll

626 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