From ee38bf9546faba3dbb2eb7443c51043aae1a8f31 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Mon, 11 Dec 2017 02:13:54 +0100 Subject: [PATCH] Changes in FrmToolbox --- VAR.Toolbox/Code/User32.cs | 9 ++++++ VAR.Toolbox/UI/FrmToolbox.Designer.cs | 42 ++++++++++++++++++--------- VAR.Toolbox/UI/FrmToolbox.cs | 18 +++++++++++- VAR.Toolbox/UI/IFormWithIcon.cs | 6 ++++ VAR.Toolbox/VAR.Toolbox.csproj | 1 + 5 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 VAR.Toolbox/UI/IFormWithIcon.cs diff --git a/VAR.Toolbox/Code/User32.cs b/VAR.Toolbox/Code/User32.cs index 29b04f3..c96f2da 100644 --- a/VAR.Toolbox/Code/User32.cs +++ b/VAR.Toolbox/Code/User32.cs @@ -133,5 +133,14 @@ namespace VAR.Toolbox.Code public const int VK_MBUTTON = 0x04; public const int VK_LBUTTON = 0x01; public const int VK_RBUTTON = 0x02; + + public const int WM_NCLBUTTONDOWN = 0xA1; + public const int HT_CAPTION = 0x2; + + [DllImport("user32.dll")] + public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + [DllImport("user32.dll")] + public static extern bool ReleaseCapture(); } } \ No newline at end of file diff --git a/VAR.Toolbox/UI/FrmToolbox.Designer.cs b/VAR.Toolbox/UI/FrmToolbox.Designer.cs index ead5fda..df43358 100644 --- a/VAR.Toolbox/UI/FrmToolbox.Designer.cs +++ b/VAR.Toolbox/UI/FrmToolbox.Designer.cs @@ -28,11 +28,11 @@ /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmToolbox)); this.btnBase64 = new System.Windows.Forms.Button(); this.btnProxyCmd = new System.Windows.Forms.Button(); this.btnWebcam = new System.Windows.Forms.Button(); this.btnTunnelTCP = new System.Windows.Forms.Button(); + this.lblToolbox = new System.Windows.Forms.Label(); this.pnlSuspension1 = new VAR.Toolbox.UI.PnlSuspension(); this.pnlCover1 = new VAR.Toolbox.UI.PnlCover(); this.SuspendLayout(); @@ -41,10 +41,10 @@ // this.btnBase64.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.btnBase64.Location = new System.Drawing.Point(18, 18); + this.btnBase64.Location = new System.Drawing.Point(13, 80); this.btnBase64.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.btnBase64.Name = "btnBase64"; - this.btnBase64.Size = new System.Drawing.Size(278, 52); + this.btnBase64.Size = new System.Drawing.Size(238, 52); this.btnBase64.TabIndex = 0; this.btnBase64.Text = "Base64"; this.btnBase64.UseVisualStyleBackColor = true; @@ -54,10 +54,10 @@ // this.btnProxyCmd.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.btnProxyCmd.Location = new System.Drawing.Point(18, 80); + this.btnProxyCmd.Location = new System.Drawing.Point(13, 142); this.btnProxyCmd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.btnProxyCmd.Name = "btnProxyCmd"; - this.btnProxyCmd.Size = new System.Drawing.Size(278, 55); + this.btnProxyCmd.Size = new System.Drawing.Size(238, 55); this.btnProxyCmd.TabIndex = 1; this.btnProxyCmd.Text = "ProxyCmd"; this.btnProxyCmd.UseVisualStyleBackColor = true; @@ -67,10 +67,10 @@ // this.btnWebcam.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.btnWebcam.Location = new System.Drawing.Point(18, 145); + this.btnWebcam.Location = new System.Drawing.Point(13, 207); this.btnWebcam.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); this.btnWebcam.Name = "btnWebcam"; - this.btnWebcam.Size = new System.Drawing.Size(278, 55); + this.btnWebcam.Size = new System.Drawing.Size(238, 55); this.btnWebcam.TabIndex = 2; this.btnWebcam.Text = "Webcam"; this.btnWebcam.UseVisualStyleBackColor = true; @@ -80,37 +80,50 @@ // this.btnTunnelTCP.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.btnTunnelTCP.Location = new System.Drawing.Point(18, 208); + this.btnTunnelTCP.Location = new System.Drawing.Point(13, 270); this.btnTunnelTCP.Name = "btnTunnelTCP"; - this.btnTunnelTCP.Size = new System.Drawing.Size(278, 55); + this.btnTunnelTCP.Size = new System.Drawing.Size(238, 55); this.btnTunnelTCP.TabIndex = 5; this.btnTunnelTCP.Text = "TunnelTCP"; this.btnTunnelTCP.UseVisualStyleBackColor = true; this.btnTunnelTCP.Click += new System.EventHandler(this.btnTunnelTCP_Click); // + // lblToolbox + // + this.lblToolbox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lblToolbox.Font = new System.Drawing.Font("Arial Narrow", 28F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblToolbox.Location = new System.Drawing.Point(12, 9); + this.lblToolbox.Name = "lblToolbox"; + this.lblToolbox.Size = new System.Drawing.Size(239, 66); + this.lblToolbox.TabIndex = 6; + this.lblToolbox.Text = "Toolbox"; + this.lblToolbox.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // pnlSuspension1 // this.pnlSuspension1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pnlSuspension1.Location = new System.Drawing.Point(18, 432); + this.pnlSuspension1.Location = new System.Drawing.Point(18, 505); this.pnlSuspension1.Name = "pnlSuspension1"; - this.pnlSuspension1.Size = new System.Drawing.Size(278, 175); + this.pnlSuspension1.Size = new System.Drawing.Size(232, 175); this.pnlSuspension1.TabIndex = 4; // // pnlCover1 // this.pnlCover1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.pnlCover1.Location = new System.Drawing.Point(18, 278); + this.pnlCover1.Location = new System.Drawing.Point(18, 351); this.pnlCover1.Name = "pnlCover1"; - this.pnlCover1.Size = new System.Drawing.Size(278, 148); + this.pnlCover1.Size = new System.Drawing.Size(232, 148); this.pnlCover1.TabIndex = 3; // // FrmToolbox // this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(309, 619); + this.ClientSize = new System.Drawing.Size(263, 692); + this.Controls.Add(this.lblToolbox); this.Controls.Add(this.btnTunnelTCP); this.Controls.Add(this.pnlSuspension1); this.Controls.Add(this.pnlCover1); @@ -137,6 +150,7 @@ private PnlCover pnlCover1; private PnlSuspension pnlSuspension1; private System.Windows.Forms.Button btnTunnelTCP; + private System.Windows.Forms.Label lblToolbox; } } diff --git a/VAR.Toolbox/UI/FrmToolbox.cs b/VAR.Toolbox/UI/FrmToolbox.cs index 2022d5c..1ffe5c2 100644 --- a/VAR.Toolbox/UI/FrmToolbox.cs +++ b/VAR.Toolbox/UI/FrmToolbox.cs @@ -1,7 +1,8 @@ using System; using System.Collections.Generic; -using System.Windows.Forms; using System.Drawing; +using System.Windows.Forms; +using VAR.Toolbox.Code; namespace VAR.Toolbox.UI { @@ -10,6 +11,9 @@ namespace VAR.Toolbox.UI public FrmToolbox() { InitializeComponent(); + + MouseDown += DragWindow_MouseDown; + lblToolbox.MouseDown += DragWindow_MouseDown; } private void FrmToolbox_Load(object sender, EventArgs e) @@ -37,6 +41,14 @@ namespace VAR.Toolbox.UI CreateWindow(typeof(FrmTunnelTCP)); } + private void DragWindow_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) + { + if (e.Button == MouseButtons.Left) + { + User32.ReleaseCapture(); + User32.SendMessage(Handle, User32.WM_NCLBUTTONDOWN, User32.HT_CAPTION, 0); + } + } #region Window handling private Form CreateWindow(Type type) @@ -48,6 +60,10 @@ namespace VAR.Toolbox.UI } _forms.Add(frm); frm.FormClosing += frmChild_FormClosing; + if ((frm is IFormWithIcon) == false) + { + frm.Icon = Icon; + } frm.Show(); return frm; } diff --git a/VAR.Toolbox/UI/IFormWithIcon.cs b/VAR.Toolbox/UI/IFormWithIcon.cs new file mode 100644 index 0000000..fa5a45a --- /dev/null +++ b/VAR.Toolbox/UI/IFormWithIcon.cs @@ -0,0 +1,6 @@ +namespace VAR.Toolbox.UI +{ + public interface IFormWithIcon + { + } +} diff --git a/VAR.Toolbox/VAR.Toolbox.csproj b/VAR.Toolbox/VAR.Toolbox.csproj index e31b886..fde32c3 100644 --- a/VAR.Toolbox/VAR.Toolbox.csproj +++ b/VAR.Toolbox/VAR.Toolbox.csproj @@ -131,6 +131,7 @@ FrmWebcam.cs + UserControl