window resizing (not working yet)

This commit is contained in:
lempamo 2017-07-28 10:58:58 -04:00
parent a2e42d26db
commit 9205136293
2 changed files with 36 additions and 1 deletions

View file

@ -159,6 +159,7 @@ private void InitializeComponent()
this.toprightcorner.Name = "toprightcorner";
this.toprightcorner.Size = new System.Drawing.Size(4, 4);
this.toprightcorner.TabIndex = 6;
this.toprightcorner.MouseDown += new System.Windows.Forms.MouseEventHandler(border_MouseDown);
//
// bottomrightcorner
//
@ -169,6 +170,7 @@ private void InitializeComponent()
this.bottomrightcorner.Name = "bottomrightcorner";
this.bottomrightcorner.Size = new System.Drawing.Size(4, 4);
this.bottomrightcorner.TabIndex = 4;
this.bottomrightcorner.MouseDown += new System.Windows.Forms.MouseEventHandler(border_MouseDown);
//
// bottomleftcorner
//
@ -178,6 +180,7 @@ private void InitializeComponent()
this.bottomleftcorner.Name = "bottomleftcorner";
this.bottomleftcorner.Size = new System.Drawing.Size(4, 4);
this.bottomleftcorner.TabIndex = 2;
this.bottomleftcorner.MouseDown += new System.Windows.Forms.MouseEventHandler(border_MouseDown);
//
// topleftcorner
//
@ -186,6 +189,7 @@ private void InitializeComponent()
this.topleftcorner.Name = "topleftcorner";
this.topleftcorner.Size = new System.Drawing.Size(4, 4);
this.topleftcorner.TabIndex = 1;
this.topleftcorner.MouseDown += new System.Windows.Forms.MouseEventHandler(border_MouseDown);
//
// left
//
@ -195,6 +199,7 @@ private void InitializeComponent()
this.left.Name = "left";
this.left.Size = new System.Drawing.Size(4, 292);
this.left.TabIndex = 3;
this.left.MouseDown += new System.Windows.Forms.MouseEventHandler(border_MouseDown);
//
// bottom
//
@ -206,6 +211,7 @@ private void InitializeComponent()
this.bottom.Name = "bottom";
this.bottom.Size = new System.Drawing.Size(296, 4);
this.bottom.TabIndex = 5;
this.bottom.MouseDown += new System.Windows.Forms.MouseEventHandler(border_MouseDown);
//
// right
//
@ -216,6 +222,7 @@ private void InitializeComponent()
this.right.Name = "right";
this.right.Size = new System.Drawing.Size(4, 296);
this.right.TabIndex = 7;
this.right.MouseDown += new System.Windows.Forms.MouseEventHandler(border_MouseDown);
//
// top
//
@ -226,6 +233,7 @@ private void InitializeComponent()
this.top.Name = "top";
this.top.Size = new System.Drawing.Size(300, 4);
this.top.TabIndex = 8;
this.top.MouseDown += new System.Windows.Forms.MouseEventHandler(border_MouseDown);
//
// WinClassic
//

View file

@ -10,6 +10,7 @@ public partial class WinClassic : Form
public WinClassic()
{
InitializeComponent();
DoubleBuffered = true;
}
public System.Drawing.Font fnt;
@ -17,8 +18,19 @@ public WinClassic()
public bool closeDisabled = false;
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int WM_SYSCOMMAND = 0x0112;
public const int HT_CAPTION = 0x2;
private const int
HTLEFT = 10,
HTRIGHT = 11,
HTTOP = 12,
HTTOPLEFT = 13,
HTTOPRIGHT = 14,
HTBOTTOM = 15,
HTBOTTOMLEFT = 16,
HTBOTTOMRIGHT = 17;
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd,
int Msg, int wParam, int lParam);
@ -114,5 +126,20 @@ private void button_MouseLeave(object sender, EventArgs e)
var c = (Button)sender;
c.UseVisualStyleBackColor = true;
}
private void border_MouseDown(object sender, EventArgs e)
{
var cursor = this.PointToClient(Cursor.Position);
if (topleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF004, 0);
else if (toprightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF005, 0);
else if (bottomleftcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF007, 0);
else if (bottomrightcorner.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF008, 0);
else if (top.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF003, 0);
else if (left.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF001, 0);
else if (right.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF002, 0);
else if (bottom.ClientRectangle.Contains(cursor)) SendMessage(Handle, WM_SYSCOMMAND, 0xF006, 0);
}
}
}