It took only one day to solve the problem, although it was not a good solution. Refer to this article. Http://blog.sina.com.cn/s/blog_6ab738af0100juex.html
Thank you very much.
Paste the code and use it later
# Region wndproc // <summary> // rewrite wndproc // </Summary> const int SC _size = 0xf000; const int wm_nchittest = 0x0084; const int htleft = 10; const int htright = 11; const int httop = 12; const int httopleft = 13; const int httopright = 14; const int htbottom = 15; const int htbottomleft = 0x10; const int htbottomright = 17; [dllimport ("user32.dll")] public static extern bool releasecapture (); [DL Limport ("user32.dll")] public static extern bool sendmessage (intptr hwnd, int wmsg, int wparam, int lparam); Public const int wm_syscommand = 0x0112; public const int SC _move = 0xf010; Public const int htcaption = 0x0002; Public const int htclient = 0x1; Public const int wmsz_left = 0xf001; Public const int wmsz_right = 0xf002; public const int wmsz_top = 0xf003; Public const int wmsz_topleft = 0x F004; Public const int Destination = 0xf005; Public const int wmsz_bottom = 0xf006; Public const int Destination = 0xf007; Public const int wmsz_bottomright = 0xf008; protected override void wndproc (ref. windows. forms. message m) {Switch (M. MSG) {Case wm_nchittest: base. wndproc (ref m); point vpoint = new point (INT) M. lparam & 0 xFFFF, (INT) M. lparam> 16 & 0 xFFFF); vpoint = pointtoclie NT (vpoint); If (this. windowstate! = Formwindowstate. maximized) {If (vpoint. x <10) {If (vpoint. Y <10) {M. result = (intptr) httopleft;} else if (vpoint. y> This. height-10) {M. result = (intptr) htbottomleft;} else {M. result = (intptr) htleft ;}} else if (vpoint. x> This. width-10) {If (vpoint. Y <10) {M. result = (intptr) httopright;} else if (vpoint. y> This. height-10) {M. result = (intptr) htbottomright;} else {M. result = (intptr) htright ;}} else if (10 <vpoint. X & vpoint. x <this. width-10) {If (vpoint. Y <10) {M. result = (intptr) httop;} else if (vpoint. y> This. height-10) {M. result = (intptr) htbottom ;}} break;} base. wndproc (ref m);} # endregion
Then, when you press the mouse, sendmessage is ready.
private void pnlRight_MouseDown(object sender, MouseEventArgs e) { this.Cursor = Cursors.SizeWE; ReleaseCapture(); SendMessage(this.Handle, WM_SYSCOMMAND, WMSZ_RIGHT, 0); }
In other directions, change the parameters.
Then, if you want to dotted box, add ws_sizebox
Int ws_sysmenu = 0x00080000; // System Menu int ws_minimizebox = 0x20000; // int ws_sizebox = 0x00040000; int windowlong = (getwindowlong (New handleref (this, this. handle),-16); setwindowlong (New handleref (this, this. handle),-16, windowlong | ws_sysmenu | ws_minimizebox | ws_sizebox );
But it is not good to do this. After the size is changed, there are more boxes outside the window. I don't know how to remove it.
If you do not need to use the dotted box, remove ws_sizebox.