Use the wm_nchittest message to determine the location of the window where the mouse is located

Source: Internet
Author: User
In this example:


After the message wm_nchittest is returned, the result parameter indicates the part of the window where the mouse is located.

Form Design Steps: after creating a project, add a menu; set the autoscroll attribute of the form to true, and add a panel to an appropriate position to display a scroll bar in the window.

Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, extctrls, stdctrls, menus; Type tform1 = Class (tform) Panel1: tpanel; mainmenu1: tmainmenu; mnufile: tmenuitem; Private Procedure mymsg (var msg: twmnchittest); message wm_nchittest; end; var form1: tform1; implementation {$ R *. DFM} const arr: array [-2 .. 21] of string = ('ignore', 'httransparent', 'htnowhere', 'htclient-customer region', 'htcaption-title', 'htsysmenu-System Menu ', 'htgrowbox', 'htmenu-menu ', 'hthscroll-horizontal scroll bar', 'htvscroll-vertical scroll bar ', 'htminbutton-minimization button', 'htmaxbutton-maximization button ', 'htleft-left boundary ', 'htrig-right boundary', 'httop-top boundary ', 'httopleft-top-left corner', 'htbottom-bottom boundary ', 'htbottomleft-lower-left corner ', 'htbottomrig-lower-right corner', 'htborder', 'hobject', 'htclose-close button ', 'hthelp'); Procedure tform1.mymsg (var msg: twmnchittest); var I: integer; begin inherited; I: = MSG. result; text: = format ('% d: % s', [I, arr [I]); end.
 
   
 // A list of all possible values of the result parameter in the wm_nchittest message is attached: Error =-2; httransparent =-1; htnowhere = 0; htclient = 1; htcaption = 2; htsysmenu = 3; htgrowbox = 4; htsize = htgrowbox; htmenu = 5; hthscroll = 6; htvscroll = 7; htminbutton = 8; htmaxbutton = 9; htleft = 10; htright = 11; httop = 12; httopleft = 13; httopright = 14; htbottom = 15; htbottomleft = $10; htbottomright = 17; htborder = 18; htreduce = htminbutton; htzoom = htmaxbutton; htsizefirst = htleft; htsizelast = htbottomright; htobject = 19; htclose = 20; hthelp = 21;
  
   
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.