To detect the mouse position over your form in the non client area  

Send By: Q3 Team
Web : http://www.q3.nu
Email: dlib@q3.nu
Date: 02/07/99

Tip accessed 482 times

 


For example, over the title bar, the close button, etc.

We will make it capturing the WM_NCMOUSEMOVE message:

Add this line in the private part of the form to capture the message


        type
        TForm1 = class(TForm)
        private
           {Esta linea / This line }
           procedure WMNCMOUSEMOVE(var Message: TMessage);
             message WM_NCMOUSEMOVE;
          { Private declarations }
        public
          { Public declarations }
        end;




And later, in the implementation part we put the next procedure:



        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;