Главная страница | назад





Article #17944: Trapping messages in non client area of a form.

 Question and Answer Database
FAQ2944D.txt Trapping messages in non client area of a form.
Category :VCL
Platform :All
Product :All 32 bit
Question:
How can I trap messages in the non client areas of my form,
such as the title bar?
Answer:
Create a message handler for one of the variety of WM_NC
(non client) messages available to trap. (search the Windows
API help file for WM_NC). This example shows how to track
mouse movement in all of the non client areas of the form.
Example:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
private
procedure WMNCMOUSEMOVE(var Message: TMessage);
message WM_NCMOUSEMOVE;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WMNCMOUSEMOVE(var Message: TMessage);
var
s : string;
begin
case Message.wParam of
HTERROR : s := 'HTERROR';
HTTRANSPARENT : s := 'HTTRANSPARENT';
HTNOWHERE : s := 'HTNOWHERE';
HTCLIENT : s := 'HTCLIENT';
HTCAPTION : s := 'HTCAPTION';
HTSYSMENU : s := 'HTSYSMENU';
HTSIZE : s := 'HTSIZE';
HTMENU : s := 'HTMENU';
HTHSCROLL : s := 'HTHSCROLL';
HTVSCROLL : s := 'HTVSCROLL';
HTMINBUTTON : s := 'HTMINBUTTON';
HTMAXBUTTON : s := 'HTMAXBUTTON';
HTLEFT : s := 'HTLEFT';
HTRIGHT : s := 'HTRIGHT';
HTTOP : s := 'HTTOP';
HTTOPLEFT : s := 'HTTOPLEFT';
HTTOPRIGHT : s := 'HTTOPRIGHT';
HTBOTTOM : s := 'HTBOTTOM';
HTBOTTOMLEFT : s := 'HTBOTTOMLEFT';
HTBOTTOMRIGHT : s := 'HTBOTTOMRIGHT';
HTBORDER : s := 'HTBORDER';
HTOBJECT : s := 'HTOBJECT';
HTCLOSE : s := 'HTCLOSE';
HTHELP : s := 'HTHELP';
else s := '';
end;
Form1.Caption := s;
Message.Result := 0;
end;
end.
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99