Solved

Call caption messages

Posted on 1998-12-05
23
218 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
loading dll from external path 1 209
Comparing dates in Delphi. Greater than/ Less than 3 110
Reconfigure Delphi Install? 2 45
Convert a string into a TDateTime 5 50
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

932 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

15 Experts available now in Live!

Get 1:1 Help Now