Solved

Call caption messages

Posted on 1998-12-05
23
210 Views
Last Modified: 2010-04-04
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
Comment
Question by:Yoni
  • 10
  • 6
  • 4
  • +2
23 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 1349415
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
 
LVL 35

Expert Comment

by:TimYates
ID: 1349416
(by toolbar, I meant border title bar)...

heh...

Tim.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1349417
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
 

Author Comment

by:Yoni
ID: 1349418
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
 

Author Comment

by:Yoni
ID: 1349419
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
 

Author Comment

by:Yoni
ID: 1349420
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
 
LVL 44

Expert Comment

by:bruintje
ID: 1349421
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
 

Author Comment

by:Yoni
ID: 1349422
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
 

Author Comment

by:Yoni
ID: 1349423
thanks bruintje! I'll try...
0
 

Author Comment

by:Yoni
ID: 1349424
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
 

Author Comment

by:Yoni
ID: 1349425
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 44

Expert Comment

by:bruintje
ID: 1349426
Hi Yoni,

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

Bruintje
0
 
LVL 3

Expert Comment

by:philipleighs
ID: 1349427
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
 
LVL 44

Expert Comment

by:bruintje
ID: 1349428
Hi philip,
Well I did that myself and did not experience this problem (Happy IE5 user)hahahahahahahahaahaha

Greetz.
0
 

Author Comment

by:Yoni
ID: 1349429
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
 
LVL 44

Expert Comment

by:bruintje
ID: 1349430
Well, hope your problem is solved then....
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1349431
Yoni does it work now??
0
 

Author Comment

by:Yoni
ID: 1349432
Ok. I've found the problem and it workes.

You can repost the answer for the points...
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1349433
Hi Yoni,
Viktor had the first answer so give him the points....
If that solves your problem.

Bruintje
0
 
LVL 10

Accepted Solution

by:
viktornet earned 100 total points
ID: 1349434
Well, ok I'll answer the question then :)
10x bruintje and Yoni

Cheers,
Viktor
0
 

Author Comment

by:Yoni
ID: 1349435
ok, Your very honest bruintje.
Bye!:-)
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1349436
Well, that's just the way things work.........
:O)
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1349437
10x to philipleighs for identifying the problem with the $A0 char thing
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now