Parameter definition
1 classNativeMethods2 {3 Public Const intWm_nchittest =0x84;4 Public Const intHtcaption =2;5 Public Const intHtleft =Ten;6 Public Const intHtright = One;7 Public Const intHttop = A;8 Public Const intHttopleft = -;9 Public Const intHttopright = -;Ten Public Const intHtbottom = the; One Public Const intHtbottomleft = -; A Public Const intHtbottomright = -; -}
Add Hook
1 New Windowinterophelper (Win). Handle; 2 HwndSource Windowsource = Hwndsource.fromhwnd (windowhandle); 3 Windowsource.removehook (WndProc);
1 Private StaticINTPTR WndProc (INTPTR hwnd,intMSG, IntPtr WParam, IntPtr LParam,ref BOOLhandled)2 {3 intGripsize = -;4 intBordersize =7;5Window win =(Window) System.Windows.Interop.HwndSource.FromHwnd (HWND). rootvisual;6 if(msg = =nativemethods.wm_nchittest)7 {8 intx = Lparam.toint32 () << ->> -, y = Lparam.toint32 () >> -;9Point pos = win. Pointfromscreen (NewPoint (x, y));Ten One //Bottom A if(Pos. X > Gripsize && -Pos. X < win. Actualwidth-gripsize && -Pos. Y >= win. ActualHeight-bordersize) the { -handled =true; - return(INTPTR) nativemethods.htbottom; - } + - // Right + if(Pos. Y > Gripsize && APos. X > win. Actualwidth-bordersize && atPos. Y < win. ActualHeight-gripsize) - { -handled =true; - return(INTPTR) nativemethods.htright; - } - in //Top, left, right, corners, ETC. - //Htbottomright to if(Pos. X > win. Actualwidth-gripsize && +Pos. Y >= win. ActualHeight-gripsize) - { thehandled =true; * return(INTPTR) nativemethods.htbottomright; $ }Panax Notoginseng } - the returnIntPtr.Zero; +}
WPF Custom Borderless Form Resize implementation