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;