From 9416b22f4690e197a71d8be840db6e402b962172 Mon Sep 17 00:00:00 2001 From: d3agle Date: Wed, 29 Jul 2015 12:17:19 -0500 Subject: [PATCH] Small fixes and prep for hotkeys --- Server/Core/Utilities/NativeMethods.cs | 6 ++++ Server/Forms/FrmRemoteDesktop.Designer.cs | 38 ++++++++++++++++------- Server/Forms/FrmRemoteDesktop.cs | 24 ++++++++++---- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/Server/Core/Utilities/NativeMethods.cs b/Server/Core/Utilities/NativeMethods.cs index 98c26e4a..083789cb 100644 --- a/Server/Core/Utilities/NativeMethods.cs +++ b/Server/Core/Utilities/NativeMethods.cs @@ -11,6 +11,12 @@ public static class NativeMethods [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam); + [DllImport("user32.dll")] + public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, int vk); + + [DllImport("user32.dll")] + public static extern bool UnregisterHotKey(IntPtr hWnd, int id); + [DllImport("uxtheme.dll", CharSet = CharSet.Unicode)] public extern static int SetWindowTheme(IntPtr hWnd, string pszSubAppName, string pszSubIdList); diff --git a/Server/Forms/FrmRemoteDesktop.Designer.cs b/Server/Forms/FrmRemoteDesktop.Designer.cs index 0fe9634d..bc2c33cb 100644 --- a/Server/Forms/FrmRemoteDesktop.Designer.cs +++ b/Server/Forms/FrmRemoteDesktop.Designer.cs @@ -36,11 +36,12 @@ private void InitializeComponent() this.lblQualityShow = new System.Windows.Forms.Label(); this.btnMouse = new System.Windows.Forms.Button(); this.panelTop = new System.Windows.Forms.Panel(); + this.btnKeyboard = new System.Windows.Forms.Button(); this.cbMonitors = new System.Windows.Forms.ComboBox(); this.btnHide = new System.Windows.Forms.Button(); this.btnShow = new System.Windows.Forms.Button(); this.picDesktop = new xServer.Controls.RapidPictureBox(); - this.btnKeyboard = new System.Windows.Forms.Button(); + this.chkForwardCommandKeys = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.barQuality)).BeginInit(); this.panelTop.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.picDesktop)).BeginInit(); @@ -69,7 +70,7 @@ private void InitializeComponent() // // barQuality // - this.barQuality.Location = new System.Drawing.Point(230, 3); + this.barQuality.Location = new System.Drawing.Point(206, -1); this.barQuality.Maximum = 100; this.barQuality.Minimum = 1; this.barQuality.Name = "barQuality"; @@ -81,7 +82,7 @@ private void InitializeComponent() // lblQuality // this.lblQuality.AutoSize = true; - this.lblQuality.Location = new System.Drawing.Point(188, 7); + this.lblQuality.Location = new System.Drawing.Point(167, 5); this.lblQuality.Name = "lblQuality"; this.lblQuality.Size = new System.Drawing.Size(46, 13); this.lblQuality.TabIndex = 4; @@ -90,7 +91,7 @@ private void InitializeComponent() // lblQualityShow // this.lblQualityShow.AutoSize = true; - this.lblQualityShow.Location = new System.Drawing.Point(242, 31); + this.lblQualityShow.Location = new System.Drawing.Point(220, 26); this.lblQualityShow.Name = "lblQualityShow"; this.lblQualityShow.Size = new System.Drawing.Size(52, 13); this.lblQualityShow.TabIndex = 5; @@ -99,7 +100,7 @@ private void InitializeComponent() // btnMouse // this.btnMouse.Image = global::xServer.Properties.Resources.mouse_delete; - this.btnMouse.Location = new System.Drawing.Point(312, 11); + this.btnMouse.Location = new System.Drawing.Point(302, 5); this.btnMouse.Name = "btnMouse"; this.btnMouse.Size = new System.Drawing.Size(28, 28); this.btnMouse.TabIndex = 6; @@ -109,6 +110,7 @@ private void InitializeComponent() // panelTop // this.panelTop.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.panelTop.Controls.Add(this.chkForwardCommandKeys); this.panelTop.Controls.Add(this.btnKeyboard); this.panelTop.Controls.Add(this.cbMonitors); this.panelTop.Controls.Add(this.btnHide); @@ -123,6 +125,15 @@ private void InitializeComponent() this.panelTop.Size = new System.Drawing.Size(384, 57); this.panelTop.TabIndex = 7; // + // btnKeyboard + // + this.btnKeyboard.Location = new System.Drawing.Point(336, 5); + this.btnKeyboard.Name = "btnKeyboard"; + this.btnKeyboard.Size = new System.Drawing.Size(28, 28); + this.btnKeyboard.TabIndex = 9; + this.btnKeyboard.UseVisualStyleBackColor = true; + this.btnKeyboard.Click += new System.EventHandler(this.btnKeyboard_Click); + // // cbMonitors // this.cbMonitors.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; @@ -171,14 +182,16 @@ private void InitializeComponent() this.picDesktop.MouseMove += new System.Windows.Forms.MouseEventHandler(this.picDesktop_MouseMove); this.picDesktop.MouseUp += new System.Windows.Forms.MouseEventHandler(this.picDesktop_MouseUp); // - // btnKeyboard + // chkForwardCommandKeys // - this.btnKeyboard.Location = new System.Drawing.Point(346, 11); - this.btnKeyboard.Name = "btnKeyboard"; - this.btnKeyboard.Size = new System.Drawing.Size(28, 28); - this.btnKeyboard.TabIndex = 9; - this.btnKeyboard.UseVisualStyleBackColor = true; - this.btnKeyboard.Click += new System.EventHandler(this.btnKeyboard_Click); + this.chkForwardCommandKeys.AutoSize = true; + this.chkForwardCommandKeys.Location = new System.Drawing.Point(234, 39); + this.chkForwardCommandKeys.Name = "chkForwardCommandKeys"; + this.chkForwardCommandKeys.Size = new System.Drawing.Size(149, 17); + this.chkForwardCommandKeys.TabIndex = 10; + this.chkForwardCommandKeys.Text = "Forward Command Keys"; + this.chkForwardCommandKeys.UseVisualStyleBackColor = true; + this.chkForwardCommandKeys.CheckedChanged += new System.EventHandler(this.chkForwardCommandKeys_CheckedChanged); // // FrmRemoteDesktop // @@ -220,5 +233,6 @@ private void InitializeComponent() private xServer.Controls.RapidPictureBox picDesktop; private System.Windows.Forms.ComboBox cbMonitors; private System.Windows.Forms.Button btnKeyboard; + private System.Windows.Forms.CheckBox chkForwardCommandKeys; } } \ No newline at end of file diff --git a/Server/Forms/FrmRemoteDesktop.cs b/Server/Forms/FrmRemoteDesktop.cs index f148d0cb..7f563bc9 100644 --- a/Server/Forms/FrmRemoteDesktop.cs +++ b/Server/Forms/FrmRemoteDesktop.cs @@ -212,7 +212,7 @@ private int GetRemoteHeight(int localY) private void picDesktop_MouseDown(object sender, MouseEventArgs e) { - if (picDesktop.Image != null && _enableMouseInput && !btnStart.Enabled && this.ContainsFocus) + if (picDesktop.Image != null && _enableMouseInput && IsStarted && this.ContainsFocus) { int local_x = e.X; int local_y = e.Y; @@ -236,7 +236,7 @@ private void picDesktop_MouseDown(object sender, MouseEventArgs e) private void picDesktop_MouseUp(object sender, MouseEventArgs e) { - if (picDesktop.Image != null && _enableMouseInput && !btnStart.Enabled && this.ContainsFocus) + if (picDesktop.Image != null && _enableMouseInput && IsStarted && this.ContainsFocus) { int local_x = e.X; int local_y = e.Y; @@ -260,7 +260,7 @@ private void picDesktop_MouseUp(object sender, MouseEventArgs e) private void picDesktop_MouseMove(object sender, MouseEventArgs e) { - if (picDesktop.Image != null && _enableMouseInput && !btnStart.Enabled && this.ContainsFocus) + if (picDesktop.Image != null && _enableMouseInput && IsStarted && this.ContainsFocus) { int local_x = e.X; int local_y = e.Y; @@ -277,7 +277,7 @@ private void picDesktop_MouseMove(object sender, MouseEventArgs e) private void MouseWheelEvent(object sender, MouseEventArgs e) { - if (picDesktop.Image != null && _enableMouseInput && !btnStart.Enabled && this.ContainsFocus) + if (picDesktop.Image != null && _enableMouseInput && IsStarted && this.ContainsFocus) { if (_connectClient != null) new Core.Packets.ServerPackets.DoMouseEvent(e.Delta == 120 ? MouseAction.ScrollUp : MouseAction.ScrollDown, false, 0, 0, cbMonitors.SelectedIndex).Execute(_connectClient); @@ -286,7 +286,7 @@ private void MouseWheelEvent(object sender, MouseEventArgs e) private void OnKeyDown(object sender, KeyEventArgs e) { - if (picDesktop.Image != null && !btnStart.Enabled && this.ContainsFocus) + if (picDesktop.Image != null && _enableKeyboardInput && IsStarted && this.ContainsFocus) { if (_connectClient != null) new Core.Packets.ServerPackets.DoKeyboardEvent((byte)e.KeyCode, true).Execute(_connectClient); @@ -295,7 +295,7 @@ private void OnKeyDown(object sender, KeyEventArgs e) private void OnKeyUp(object sender, KeyEventArgs e) { - if (picDesktop.Image != null && !btnStart.Enabled && this.ContainsFocus) + if (picDesktop.Image != null && _enableKeyboardInput && IsStarted && this.ContainsFocus) { if (_connectClient != null) new Core.Packets.ServerPackets.DoKeyboardEvent((byte)e.KeyCode, false).Execute(_connectClient); @@ -317,5 +317,17 @@ private void btnShow_Click(object sender, EventArgs e) btnHide.Visible = true; this.ActiveControl = picDesktop; } + + private void chkForwardCommandKeys_CheckedChanged(object sender, EventArgs e) + { + if (chkForwardCommandKeys.Checked) + { + //register hot keys for command keys such as Windows key and ALT + key combinations + } + else + { + + } + } } } \ No newline at end of file