Removed NativeMethods - not used as we allow multiple instances now; changed tray icon hover text

This commit is contained in:
szporowolik
2019-10-20 13:40:53 +02:00
parent c35c216c78
commit 2ad1a531b8
4 changed files with 4 additions and 25 deletions

View File

@@ -1,13 +0,0 @@
// This class just wraps some Win32 stuff that we're going to use for blocking of multiple instances
using System;
using System.Runtime.InteropServices;
internal class NativeMethods
{
public const int HWND_BROADCAST = 0xffff;
public static readonly int WM_SHOWME = RegisterWindowMessage("WM_SHOWME");
[DllImport("user32")]
public static extern bool PostMessage(IntPtr hwnd, int msg, IntPtr wparam, IntPtr lparam);
[DllImport("user32")]
public static extern int RegisterWindowMessage(string message);
}

View File

@@ -497,7 +497,6 @@
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "form_Main";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Perun for DCS World";

View File

@@ -187,6 +187,9 @@ namespace Perun_v1
// Set title bar
this.Text = "[#"+ con_txt_dcs_instance.Text + "] " + Globals.strPerunTitleText;
// Set notification icon text
trayIconMain.Text = this.Text;
}
private void con_Button_Listen_OFF_Click(object sender, EventArgs e)
@@ -232,6 +235,7 @@ namespace Perun_v1
// Set title bar
this.Text = Globals.strPerunTitleText;
trayIconMain.Text = this.Text;
// Set globals
Globals.intInstanceId = 0;
@@ -300,16 +304,6 @@ namespace Perun_v1
}
}
protected override void WndProc(ref Message m)
{
// Try to run of 2nd instance
if (m.Msg == NativeMethods.WM_SHOWME)
{
form_Main_BringFromTray();
}
base.WndProc(ref m);
}
private void form_Main_SendToTray()
{
// Sends app to system tray

View File

@@ -129,7 +129,6 @@
<Compile Include="01_Classes\Globals.cs" />
<Compile Include="01_Classes\DatabaseController.cs" />
<Compile Include="01_Classes\PerunHelper.cs" />
<Compile Include="01_Classes\NativeMethods.cs" />
<Compile Include="02_Forms\form_Main.cs">
<SubType>Form</SubType>
</Compile>