diff --git a/src/Taskbar/Taskbar.cs b/src/Taskbar/Taskbar.cs
index 3e63cba..b94b7f5 100644
--- a/src/Taskbar/Taskbar.cs
+++ b/src/Taskbar/Taskbar.cs
@@ -180,6 +180,9 @@ static Advanced()
cbSize = (uint)Marshal.SizeOf(typeof(Structs.Data)),
hWnd = FindWindow(Values.ClassName, null)
};
+
+ //Get the taskbar window rect in screen coordinates
+ GetWindowRect(Values.BarData.hWnd, ref Values.BarData.Rect);
}
catch
{
@@ -187,6 +190,24 @@ static Advanced()
}
}
+ ///
+ /// Gets a data value.
+ ///
+ public static Structs.Data Data
+ {
+ get
+ {
+ try
+ {
+ return Values.BarData;
+ }
+ catch
+ {
+ throw new Exception(Values.Exception);
+ }
+ }
+ }
+
///
/// Gets a value indicating whether the taskbar is always on top of other windows.
///
@@ -263,7 +284,7 @@ public static Rectangle DisplayBounds
{
try
{
- if (RefreshBoundsAndPosition)
+ if (RefreshAll())
{
return Rectangle.FromLTRB(Values.BarData.Rect.Left, Values.BarData.Rect.Top, Values.BarData.Rect.Right, Values.BarData.Rect.Bot);
}
@@ -304,7 +325,7 @@ public static Enums.LocationType Position
{
try
{
- if (RefreshBoundsAndPosition)
+ if (RefreshAll())
{
return (Enums.LocationType)Values.BarData.uEdge;
}
@@ -488,22 +509,45 @@ public static Dictionary FindDockedTaskbarsDictionary
}
///
- ///
+ /// Refresh data value.
///
///
- private static bool RefreshBoundsAndPosition
+ public static bool RefreshData()
{
- get
+ try
{
- try
- {
- //! SHAppBarMessage returns IntPtr.Zero **if it fails**
- return SHAppBarMessage(Enums.MessageType.GetTaskbarPos, ref Values.BarData) != IntPtr.Zero;
- }
- catch
+ Values.BarData = new Structs.Data
{
- throw new Exception(Values.Exception);
- }
+ cbSize = (uint)Marshal.SizeOf(typeof(Structs.Data)),
+ hWnd = FindWindow(Values.ClassName, null)
+ };
+
+ //Get the taskbar window rect in screen coordinates
+ return GetWindowRect(Values.BarData.hWnd, ref Values.BarData.Rect);
+ }
+ catch
+ {
+ throw new Exception(Values.Exception);
+ }
+ }
+
+ ///
+ /// Refresh all value.
+ ///
+ ///
+ public static bool RefreshAll()
+ {
+ try
+ {
+ //! SHAppBarMessage returns IntPtr.Zero **if it fails**
+ //return SHAppBarMessage(Enums.MessageType.GetTaskbarPos, ref Values.BarData) != IntPtr.Zero;
+ SHAppBarMessage(Enums.MessageType.GetTaskbarPos, ref Values.BarData);
+
+ return RefreshData();
+ }
+ catch
+ {
+ throw new Exception(Values.Exception);
}
}
}
diff --git a/src/Taskbar/Taskbar.csproj b/src/Taskbar/Taskbar.csproj
index df4a52c..d8de4a7 100644
--- a/src/Taskbar/Taskbar.csproj
+++ b/src/Taskbar/Taskbar.csproj
@@ -1,10 +1,10 @@
- net48
+
-
+ net40;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netcoreapp3.0-windows;netcoreapp3.1-windows;net5.0-windows;net6.0-windows
true
Resources\ICO.ico
1.0.0.3
diff --git a/src/Taskbar/Value/Values.cs b/src/Taskbar/Value/Values.cs
index 49d1665..b2056c4 100644
--- a/src/Taskbar/Value/Values.cs
+++ b/src/Taskbar/Value/Values.cs
@@ -30,7 +30,7 @@ public class Values
///
///
///
- public const string ClassName = "Shell_TrayWnd";
+ internal const string ClassName = "Shell_TrayWnd";
///
///
diff --git a/src/Taskbar_CR/Main.Designer.cs b/src/Taskbar_CR/Main.Designer.cs
index 1367f92..74e2fc9 100644
--- a/src/Taskbar_CR/Main.Designer.cs
+++ b/src/Taskbar_CR/Main.Designer.cs
@@ -39,6 +39,9 @@ private void InitializeComponent()
this.button8 = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
+ this.button11 = new System.Windows.Forms.Button();
+ this.button12 = new System.Windows.Forms.Button();
+ this.button13 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
@@ -141,11 +144,44 @@ private void InitializeComponent()
this.button10.UseVisualStyleBackColor = true;
this.button10.Click += new System.EventHandler(this.Button10_Click);
//
+ // button11
+ //
+ this.button11.Location = new System.Drawing.Point(168, 236);
+ this.button11.Name = "button11";
+ this.button11.Size = new System.Drawing.Size(150, 64);
+ this.button11.TabIndex = 10;
+ this.button11.Text = "Advanced\r\nData Taskbar Value";
+ this.button11.UseVisualStyleBackColor = true;
+ this.button11.Click += new System.EventHandler(this.Button11_Click);
+ //
+ // button12
+ //
+ this.button12.Location = new System.Drawing.Point(12, 306);
+ this.button12.Name = "button12";
+ this.button12.Size = new System.Drawing.Size(150, 64);
+ this.button12.TabIndex = 11;
+ this.button12.Text = "Advanced\r\nRefresh All";
+ this.button12.UseVisualStyleBackColor = true;
+ this.button12.Click += new System.EventHandler(this.Button12_Click);
+ //
+ // button13
+ //
+ this.button13.Location = new System.Drawing.Point(324, 236);
+ this.button13.Name = "button13";
+ this.button13.Size = new System.Drawing.Size(150, 64);
+ this.button13.TabIndex = 12;
+ this.button13.Text = "Advanced\r\nRefresh Data";
+ this.button13.UseVisualStyleBackColor = true;
+ this.button13.Click += new System.EventHandler(this.Button13_Click);
+ //
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
- this.ClientSize = new System.Drawing.Size(486, 312);
+ this.ClientSize = new System.Drawing.Size(486, 382);
+ this.Controls.Add(this.button13);
+ this.Controls.Add(this.button12);
+ this.Controls.Add(this.button11);
this.Controls.Add(this.button10);
this.Controls.Add(this.button9);
this.Controls.Add(this.button8);
@@ -180,5 +216,8 @@ private void InitializeComponent()
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button10;
+ private System.Windows.Forms.Button button11;
+ private System.Windows.Forms.Button button12;
+ private System.Windows.Forms.Button button13;
}
}
\ No newline at end of file
diff --git a/src/Taskbar_CR/Main.cs b/src/Taskbar_CR/Main.cs
index f4833b1..0b36363 100644
--- a/src/Taskbar_CR/Main.cs
+++ b/src/Taskbar_CR/Main.cs
@@ -83,5 +83,20 @@ private void Button10_Click(object sender, EventArgs e)
MessageBox.Show("Screen " + Var.Key + " =>\n" + "\tX: " + Var.Value.X + "\n\tY: " + Var.Value.Y + "\n\tWidth: " + Var.Value.Width + "\n\tHeight: " + Var.Value.Height);
}
}
+
+ private void Button11_Click(object sender, EventArgs e)
+ {
+ MessageBox.Show(Advanced.Data.Rect.Left + "\n" + Advanced.Data.Rect.Top + "\n" + Advanced.Data.Rect.Right + "\n" + Advanced.Data.Rect.Bot);
+ }
+
+ private void Button13_Click(object sender, EventArgs e)
+ {
+ Advanced.RefreshData();
+ }
+
+ private void Button12_Click(object sender, EventArgs e)
+ {
+ Advanced.RefreshAll();
+ }
}
}
\ No newline at end of file
diff --git a/src/Taskbar_CR/Main.resx b/src/Taskbar_CR/Main.resx
index 90b8ec8..1aa57f5 100644
--- a/src/Taskbar_CR/Main.resx
+++ b/src/Taskbar_CR/Main.resx
@@ -147,7 +147,13 @@
True
-
+
+ True
+
+
+ True
+
+
True
diff --git a/src/Taskbar_CR/Taskbar_CR.csproj b/src/Taskbar_CR/Taskbar_CR.csproj
index fd9eb1e..83db1ea 100644
--- a/src/Taskbar_CR/Taskbar_CR.csproj
+++ b/src/Taskbar_CR/Taskbar_CR.csproj
@@ -1,8 +1,8 @@
- net48
+
-
+ net48;netcoreapp3.0-windows;netcoreapp3.1-windows;net5.0-windows;net6.0-windows
WinExe
false
true