Recent

Author Topic: How to move a window without the titlebar  (Read 17766 times)

stemueh

  • Guest
How to move a window without the titlebar
« on: October 28, 2004, 03:13:04 pm »
Hello All,

How can I move a window without the use of the title bar, like winamp on windows? I know the delphi way for this, but it not works in lazarus under linux (maybe cause there are no working window messages for this?)

can everyone give me an little example?


thanks

Adam.Pilorz

  • Jr. Member
  • **
  • Posts: 67
    • http://www.pilotmp3.devtown.net
How to move a window without the titlebar
« Reply #1 on: October 28, 2004, 04:55:48 pm »
Well... Write down (or rather copy) your way, and I will try to find why it doesn't work with Lazarus.
Under Windows in Lazarus (I don't have Linux runed right now) you can do it by this:
procedure TForm1.Form1MouseDown(Sender: TOBject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  XPos:=X;
  YPos:=Y;
  Moving:=True;
end;

procedure TForm1.Form1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  If Moving then Form1.Left:=Form1.Left+X-XPos;
  If Moving then Form1.Top:=Form1.Top+Y-YPos;
end;

procedure TForm1.Form1MouseUp(Sender: TOBject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  Moving:=False;
end;
Associated to Form1 Events and with following declaration:
  Form1=class(TForm)
  ...
  private
    { private declarations }
    XPos, YPos: Integer;
    Moving: Boolean;

Anonymous

  • Guest
How to move a window without the titlebar
« Reply #2 on: October 30, 2004, 11:24:39 am »
Thanks,

but this is not the way I mean. It works not really good, cause the windows jumps sometime or hangs while moving. The "Delphi-Way" I mean is to use a windows Message ( see http://delphi.about.com/library/weekly/aa061300a.htm for a description).  In short:

"Windows sends a wm_NCHitTest message whenever a mouse event occurs, that is, when the cursor moves, or when a mouse button is pressed or released. If the mouse is not captured, the message is sent to the window beneath the cursor. Otherwise, the message is sent to the window that has captured the mouse.

If we can make Windows think that the user is dragging (has clicked on) the title bar rather than the client area, then the user could drag the window by clicking in the client area. The easiest way to do this is to "fool" Windows into thinking that you're actually clicking on the title bar of a form. We will do this by handling the WM_NCHitTest windows message. Here's what you have to do:

1. insert the following line into your form's "Private declarations" section (message handling procedure declaration):

procedure WMNCHitTest(var Msg: TWMNCHitTest);
  message wm_NCHitTest;

2. add the following code into the "implementation" section of your form's unit (where Form1 is assumed form name):

procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
begin
  inherited;
  if  Msg.Result = htClient then
    Msg.Result := htCaption;
end;


This way I move my windows in delphi, but in lazarus it does'nt work. I think the messages - in lazarus they begin with LM.. - will not do what they should do. So is there a similiar way for lazarus for smooth moving the window without the title bar?

Anonymous

  • Guest
How to move a window without the titlebar
« Reply #3 on: October 30, 2004, 11:31:50 am »
Sorry,

I forgot to say that I need this for Linux.

S]"]>Blockedeh

Lightning

  • Sr. Member
  • ****
  • Posts: 422
How to move a window without the titlebar
« Reply #4 on: October 30, 2004, 12:17:36 pm »
You can't do this in Linux the Windows way.
There are some Linux apps. that do this too.
Check the source of XMMS(WinAmp for Linux) or other Linux apps that use skins.
The future must be... Fast and OpenSource so...
Think Open and Lightning Fast!

stemueh

  • Guest
Yes I Know. but..
« Reply #5 on: October 30, 2004, 07:56:16 pm »
I thought someone had have already this problem in lazarus and I could get a hint.

I think its not the way to see how xmms implements this, cause this must be done somewhere in the form class or a overriden method of the form or customform class. But unfortunately I don't know much about moving windows in linux generally(thought I have to know the whole way from the xserver over the windowmanager to the widgetset and then the lazarus class).

It was good to know at least the starting point to find it out.

s]"]>Blockedeh

Adam.Pilorz

  • Jr. Member
  • **
  • Posts: 67
    • http://www.pilotmp3.devtown.net
How to move a window without the titlebar
« Reply #6 on: October 31, 2004, 06:06:07 pm »
Well. I'm using my way to do it. It is much more universal, as it doesn't need to use system messages.

scismondo

  • New Member
  • *
  • Posts: 13
    • http://www.icilinux.com
How to move a window without the titlebar
« Reply #7 on: February 04, 2005, 03:42:28 pm »
Hi,

Depending on your window manager, just try Alt + Left click. This should work with KDE at least, maybe with other window managers... This way you're able to move any window, even if you don't see / don't have a title bar.

Seb.

Schaelle

  • New Member
  • *
  • Posts: 13
How to move a window without the titlebar
« Reply #8 on: August 03, 2006, 11:29:01 am »
Anyone has a solution for this problem for windows?
(That means: What i must do that the way how it works in Delphi, it also works in Lazarus?)

CCRDude

  • Hero Member
  • *****
  • Posts: 615
How to move a window without the titlebar
« Reply #9 on: August 03, 2006, 12:16:38 pm »
Buy the first three volumes of Macintosh Inside (just because it's one of the best resources for user interface design guidelines), and when you're done reading them, you've hopefully understood the aesthetics of a GUI that follows standards instead of annoying the user with fancy colors and unexpected "features" :D

(sorry if this is not helping in this question ;) )

Schaelle

  • New Member
  • *
  • Posts: 13
How to move a window without the titlebar
« Reply #10 on: August 03, 2006, 12:40:46 pm »
Hrmpf, only because i have designed the gui by myself it should not be usibilty?

CCRDude

  • Hero Member
  • *****
  • Posts: 615
How to move a window without the titlebar
« Reply #11 on: August 03, 2006, 01:43:41 pm »
The key is to give users what they expect, not what us programmers like ;)

A windows user expects Windows to move only when dragging the title bar.

* If you add code for moving by dragging any part of the window, a novice will stop and yell "hey, what did I do wrong, I just clicked that form and it moved!".
* The average user will say "Oh, I didn't know windows can move that way", and will be disappointed when other windows won't do the same.
* The experienced user has dragged enough windows that he won't spend a thought on dragging it anywhere else but the title bar.
* The hacker will use Alt+Space+M anyway since he's faster that way.
* The developer (you) will think "Hey, it's cool that I can move that window another way" ...

So while there are a few useful occassions for dragging by clicking everywhere (I can think only of transparent stay-on-top widgets without a titel bar, in most cases adding such a feature is only good for your ego, but does nothing for the customer, or even irritates him.

That's the reason why Window managers have been invented - to standarize usage of windows, to make it easier for users to use new applications, since they behave the way they know.

theo

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1935
How to move a window without the titlebar
« Reply #12 on: August 03, 2006, 01:59:38 pm »
Good posting CCRDude!
I completely agree with you.

Schaelle

  • New Member
  • *
  • Posts: 13
How to move a window without the titlebar
« Reply #13 on: August 03, 2006, 03:42:53 pm »
Quote from: "CCRDude"
The key is to give users what they expect, not what us programmers like ;)

A windows user expects Windows to move only when dragging the title bar.

* If you add code for moving by dragging any part of the window, a novice will stop and yell "hey, what did I do wrong, I just clicked that form and it moved!".
* The average user will say "Oh, I didn't know windows can move that way", and will be disappointed when other windows won't do the same.
* The experienced user has dragged enough windows that he won't spend a thought on dragging it anywhere else but the title bar.
* The hacker will use Alt+Space+M anyway since he's faster that way.
* The developer (you) will think "Hey, it's cool that I can move that window another way" ...

So while there are a few useful occassions for dragging by clicking everywhere (I can think only of transparent stay-on-top widgets without a titel bar, in most cases adding such a feature is only good for your ego, but does nothing for the customer, or even irritates him.

That's the reason why Window managers have been invented - to standarize usage of windows, to make it easier for users to use new applications, since they behave the way they know.


Hm, okay.

I didnt post what i realy want:

I want a Form without border. >> BorderStyle: bsNone; Ok with that settings there isnt a title bar.

Any other way to remove the border of the window, without lose the title bar?

matthijs

  • Hero Member
  • *****
  • Posts: 537
How to move a window without the titlebar
« Reply #14 on: August 03, 2006, 04:41:07 pm »
Do the borderstyles bsDialog, bsSingle or bsToolWindow help? Why do you want to remove the border?
What's in a sig? Would my posting look less if it didnot have a sig? (Free after William S.) :)

:( Why cannot I upload my own Avatar? :(

 

TinyPortal © 2005-2018