C# 无边框窗体开发窗体伸缩功能(windows消息)

c# 无边框窗体开发窗体伸缩功能1 protected override void WndProc(ref Message m)2 {3 switch (m.Msg)4 {5 case 0x84:6 base.WndPro...

c# 无边框窗体开发窗体伸缩功能

 1         protected override void WndProc(ref Message m)
 2         {
 3             switch (m.Msg)
 4             {
 5                 case 0x84:
 6                     base.WndProc(ref m);
 7                     Point lpint = new Point((int)m.LParam);
 8                     lpint.Offset(-Left, -Top);
 9                     Rectangle tBoder = new Rectangle(3, 0, Width-6, 3);
10                     Rectangle lBorder = new Rectangle(0, 3, 3, Height-6);
11                     Rectangle rBorder = new Rectangle(Width-3, 3, 3, Height-6);
12                     Rectangle bBorder = new Rectangle(3, Height-3, Width-6, 3);
13                     Rectangle tlBorder = new Rectangle(0, 0, 3, 3);
14                     Rectangle tbBorder = new Rectangle(0, Height-3, 3, 3);
15                     Rectangle trBorder = new Rectangle(Width-3, 0, 3, 3);
16                     Rectangle brBorder = new Rectangle(Width - 3, Height-3, 3, 3);
17                     if (tBoder.Contains(lpint))//上-缩放
18                     {
19                         m.Result = (IntPtr)0xC;
20                         return;
21                     }
22                     if (lBorder.Contains(lpint))//左-缩放
23                     {
24                         m.Result = (IntPtr)0xA;
25                         return;
26                     }
27                     if (rBorder.Contains(lpint))//右-缩放
28                     {
29                         m.Result = (IntPtr)0xB;
30                         return;
31                     }
32                     if (bBorder.Contains(lpint))//下-缩放
33                     {
34                         m.Result = (IntPtr)0xF;
35                         return;
36                     }
37                     if (tlBorder.Contains(lpint))//左上-缩放
38                     {
39                         m.Result = (IntPtr)0xD;
40                         return;
41                     }
42                     if (tbBorder.Contains(lpint))//左下-缩放
43                     {
44                         m.Result = (IntPtr)0x10;
45                         return;
46                     }
47                     if (trBorder.Contains(lpint))//右上-缩放
48                     {
49                         m.Result = (IntPtr)0xE;
50                         return;
51                     }
52                     if (brBorder.Contains(lpint))//右下-缩放
53                     {
54                         m.Result = (IntPtr)0x11;
55                         return;
56                     }
57                     return;
58             }
59             base.WndProc(ref m);
60         }    
View Code

 

本文标题为:C# 无边框窗体开发窗体伸缩功能(windows消息)

基础教程推荐