• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

Call caption messages

Hi!

I'm making an application without a caption but I want it to move on the desktop like a caption. I have tried various methods. I tried to use movewindow but the window was visible while it was dragged. So, I disabled the repaint and added it in the mouseup event but the image of the window was still on the desktop where the form originally was (I thought I could then use "rect" to paint the rectangle).

Finally, I want to know exactly How can I make windows think that I'm dragging a real caption using the window messages (WM_MOVING, WM_MOVE)in the onmousedown, onmousemove and onmouseup events.

Thanks in advance!
0
Yoni
Asked:
Yoni
  • 10
  • 6
  • 4
  • +2
1 Solution
 
TimYatesCommented:
Just to clear things in my mind...  

You have an application with no border...
You want to be able to define your own area where you can click and drag the window as if you clicked on the toolbar...

Correct?

Tim.
0
 
TimYatesCommented:
(by toolbar, I meant border title bar)...

heh...

Tim.
0
 
viktornetCommented:
Here is how it's done...

in OnMouseMove()

OnMouseMove()
begin
  if ssLeft in Shift then begin
    ReleaseCapture;
    FormName.Perform(WM_SYSCOMMAND, $F012, 0);
  end;
end;

That's all... You can put this code in any controls OnMouseMove() and the form will move if you try dragging that control whose OnMouseMove() has got the code above...

Cheers,
Viktor
0
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.

 
YoniAuthor Commented:
Sorry it doesn't work.I get a few errors
Illegal Charecter in input file: ''($A0)

(by the way Yes tim, that's exactly what I mean)
0
 
YoniAuthor Commented:
Sorry it doesn't work.I get a few errors
Illegal Charecter in input file: ''($A0)

(by the way Yes tim, that's exactly what I mean)
0
 
YoniAuthor Commented:
Sorry it doesn't work.I get a few errors
Illegal Charecter in input file: ''($A0)

(by the way Yes tim, that's exactly what I mean)
0
 
bruintjeCommented:
Hi Yoni,

Try this a form and a button

and this code in unit1

unit1;
interface

uses
  SysUtils,
  WinTypes,
  WinProcs,
  Messages,
  Classes,
  Controls,
  Forms,
  StdCtrls,
  ExtCtrls,
  Menus;

type
  TCapLessForm = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure CreateParams(var Params: TCreateParams); override;
    procedure WMNCHitTest(var Msg: TMessage);  message WM_NCHITTEST;
  end;

var
  CapLessForm: TCapLessForm;

implementation

{$R *.DFM}

procedure TCapLessForm.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams (Params);
  Params.Style := ws_Popup or ws_ClipChildren or ws_ClipSiblings or ws_Border;
end;

procedure TCapLessForm.WMNCHitTest(var Msg: TMessage);
begin
  if GetAsyncKeyState(VK_LBUTTON) < 0 then
    Msg.Result := HTCAPTION
  else
    Msg.Result := HTCLIENT;
end;

procedure TCapLessForm.Button1Click(Sender: TObject);
begin
  Close;
end;

end.

0
 
YoniAuthor Commented:
Sorry it doesn't work.I get a few errors
Illegal Charecter in input file: ''($A0)

(by the way Yes tim, that's exactly what I mean)
0
 
YoniAuthor Commented:
thanks bruintje! I'll try...
0
 
YoniAuthor Commented:
Illegal Charecter in input file: ''($A0)
Nope. I get this error message at the following lines:
unit1;
interface
uses
  SysUtils,
  WinTypes,
  WinProcs,
  Messages,
  Classes,
  Controls,
  Forms,
  StdCtrls,
  ExtCtrls,
  Menus;
type
  TCapLessForm = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure CreateParams(var Params: TCreateParams); override;
    procedure WMNCHitTest(var Msg: TMessage);  message WM_NCHITTEST; 2 Errors
  end;
var
  CapLessForm: TCapLessForm;
implementation
{$R *.DFM}
procedure TCapLessForm.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams (Params); Error
  Params.Style := ws_Popup or ws_ClipChildren or ws_ClipSiblings or ws_Border; Error
end;
procedure TCapLessForm.WMNCHitTest(var Msg: TMessage);
begin
  if GetAsyncKeyState(VK_LBUTTON) < 0 then   Error
    Msg.Result := HTCAPTION      Error
  else                           Error
    Msg.Result := HTCLIENT;      Error
end;
procedure TCapLessForm.Button1Click(Sender: TObject);
begin
  Close;    Error
end;
end.
0
 
YoniAuthor Commented:
Illegal Charecter in input file: ''($A0)
Nope. I get this error message at the following lines:
unit1;
interface
uses
  SysUtils,
  WinTypes,
  WinProcs,
  Messages,
  Classes,
  Controls,
  Forms,
  StdCtrls,
  ExtCtrls,
  Menus;
type
  TCapLessForm = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    procedure CreateParams(var Params: TCreateParams); override;
    procedure WMNCHitTest(var Msg: TMessage);  message WM_NCHITTEST; 2 Errors
  end;
var
  CapLessForm: TCapLessForm;
implementation
{$R *.DFM}
procedure TCapLessForm.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams (Params); Error
  Params.Style := ws_Popup or ws_ClipChildren or ws_ClipSiblings or ws_Border; Error
end;
procedure TCapLessForm.WMNCHitTest(var Msg: TMessage);
begin
  if GetAsyncKeyState(VK_LBUTTON) < 0 then   Error
    Msg.Result := HTCAPTION      Error
  else                           Error
    Msg.Result := HTCLIENT;      Error
end;
procedure TCapLessForm.Button1Click(Sender: TObject);
begin
  Close;    Error
end;
end.
0
 
bruintjeCommented:
Hi Yoni,

Looks like a lot of messages of the (T)Error type. I will take another look at it.

Bruintje
0
 
philipleighsCommented:
The illegal char thing happens when you paste code from IE (or Netscape) into Delphi. Try typing victornet's code, not pasting it, or search and replace $A0 with spaces in Delphi.
0
 
bruintjeCommented:
Hi philip,
Well I did that myself and did not experience this problem (Happy IE5 user)hahahahahahahahaahaha

Greetz.
0
 
YoniAuthor Commented:
Victor and Bruintje

It's my mistake. When I use your source On a blank form it works perfectly but it gives me the above error message when I add it to the project that I'm programming and in which I want to implement this feature...
0
 
bruintjeCommented:
Well, hope your problem is solved then....
0
 
viktornetCommented:
Yoni does it work now??
0
 
YoniAuthor Commented:
Ok. I've found the problem and it workes.

You can repost the answer for the points...
0
 
bruintjeCommented:
Hi Yoni,
Viktor had the first answer so give him the points....
If that solves your problem.

Bruintje
0
 
viktornetCommented:
Well, ok I'll answer the question then :)
10x bruintje and Yoni

Cheers,
Viktor
0
 
YoniAuthor Commented:
ok, Your very honest bruintje.
Bye!:-)
0
 
bruintjeCommented:
Well, that's just the way things work.........
:O)
0
 
viktornetCommented:
10x to philipleighs for identifying the problem with the $A0 char thing
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 10
  • 6
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now