Solved

Call caption messages

Posted on 1998-12-05
23
227 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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
 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

10 Experts available now in Live!

Get 1:1 Help Now