Solved

Moving window without a taskbar

Posted on 1998-01-09
4
144 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks... That works great...
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

743 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