Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Moving window without a taskbar

Posted on 1998-01-09
4
Medium Priority
?
158 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 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 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