Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 1997-07-20
4
Medium Priority
?
172 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

609 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