-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowHelper.cs
More file actions
41 lines (37 loc) · 1.25 KB
/
Copy pathWindowHelper.cs
File metadata and controls
41 lines (37 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace DocAtHome
{
internal static class WindowHelper
{
[DllImport("user32.dll", EntryPoint = "ReleaseCapture")]
private static extern void ReleaseCapture();
[DllImport("user32.dll", EntryPoint = "SendMessage")]
private static extern void SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
public static void StartDrag(IntPtr handle)
{
ReleaseCapture();
SendMessage(handle, 0x112, 0xf012, 0);
}
// Toggle between normal size and working-area fullscreen.
// Saves the current bounds in f.Tag so restore is exact.
public static void ToggleMaximize(Form f, Button btn = null)
{
if (f.Tag is Rectangle saved)
{
f.Bounds = saved;
f.Tag = null;
if (btn != null) btn.Text = "□";
}
else
{
f.Tag = f.Bounds;
Rectangle wa = Screen.FromControl(f).WorkingArea;
f.SetBounds(wa.X, wa.Y, wa.Width, wa.Height);
if (btn != null) btn.Text = "❐";
}
}
}
}