?
Solved

Moving an empty (no menubar) form around the screen.

Posted on 1997-07-20
4
Medium Priority
?
165 Views
Last Modified: 2010-04-04
I've created an empty form that I can't figure out how to move.

What I did:

1. Created a form with no components.
2. Set all the forms properties so nothing would show             around the borders.
3. Set the back color to green.
4. Double-Clicking on the form quits the application.
5. I set the client height to 2.

When I run the program it does what it's supposed to.  It puts a green line on the screen without a menu bar,  min/max buttons or boarder,  just a clean green line that stays on top of everything and goes away if you
double click on it.

Is there a way to allow the user to drag this line around without having a menu bar?  I can't find one.

I did play with setWindowPos but it only seems to work with child windows.

If it helps the purpose of this line is supposed to be to help users focus across the correct line in an Access 2.0 form.  It works but they can't move it which would be a big help.  They currently do the same thing by wrapping rubberbands around the monitors and placing the band across the
middle of the screen,  a bit inconvient at best.

Thanks.
0
Comment
Question by:wirth
[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
  • 3
4 Comments
 

Author Comment

by:wirth
ID: 1339368
Edited text of question
0
 

Author Comment

by:wirth
ID: 1339369
Edited text of question
0
 
LVL 4

Accepted Solution

by:
erajoj earned 400 total points
ID: 1339370
This is a way I use often:

var
  X0, Y0   : Integer;
  MoveForm : Boolean = False; // Delphi 2+

procedure TGreenLine.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (Button = mbLeft) then begin
    MoveForm := True;
    X0 := X; Y0 := Y;
  end;
end;

procedure TGreenLine.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if MoveForm then SetBounds(Left-X0+X, Top-Y0+Y, Width, Height);
  { If you want to move vertically only: }
  // if MoveForm then SetBounds(Left, Top-Y0+Y, Width, Height);
end;

procedure TGreenLine.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    MoveForm := False;
end;

If you want to make it easier to grab then use region-functions
to create a "handle" that is wider than the line, do something
like this:

procedure TGreenLine.FormCreate(Sender: TObject);
var
  RGN, RGN1, RGN2: HRGN;
begin
  Cursor := crVSplit; // Just for appearance
  SetBounds(0, Screen.Height div 2, Screen.Width, 15);
  RGN1 := CreateRectRGN(0, 0, Screen.Width, 2);
  RGN2 := CreateEllipticRGN(Screen.Width-30, -15,
    Screen.Width+30, +15);
  CombineRGN(RGN1, RGN1, RGN2, RGN_OR);
  SetWindowRgn(Handle, RGN1, true);
end;                    

Enjoy!

/// John

0
 

Author Comment

by:wirth
ID: 1339371
Thank's earjoj.  I tried the basics you put in and it worked like a charm.  I'm going to try out the rest of your idea now.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

771 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