Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
53X Again 9!
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor authored and Taiizor committed Apr 11, 2021
1 parent 20ab538 commit cd75bdd
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 20 deletions.
70 changes: 57 additions & 13 deletions src/Taskbar/Taskbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,34 @@ 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
{
throw new Exception(Values.Exception);
}
}

/// <summary>
/// Gets a data value.
/// </summary>
public static Structs.Data Data
{
get
{
try
{
return Values.BarData;
}
catch
{
throw new Exception(Values.Exception);
}
}
}

/// <summary>
/// Gets a value indicating whether the taskbar is always on top of other windows.
/// </summary>
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -304,7 +325,7 @@ public static Enums.LocationType Position
{
try
{
if (RefreshBoundsAndPosition)
if (RefreshAll())
{
return (Enums.LocationType)Values.BarData.uEdge;
}
Expand Down Expand Up @@ -488,22 +509,45 @@ public static Dictionary<int, Rectangle> FindDockedTaskbarsDictionary
}

/// <summary>
///
/// Refresh data value.
/// </summary>
/// <returns></returns>
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);
}
}

/// <summary>
/// Refresh all value.
/// </summary>
/// <returns></returns>
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);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Taskbar/Taskbar.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<!--<TargetFramework>net48</TargetFramework>-->
<!--<TargetFrameworks>net48;net5.0-windows;net6.0-windows</TargetFrameworks>-->
<!--<TargetFrameworks>net40;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;net5.0-windows;net6.0-windows</TargetFrameworks>-->
<!--<TargetFrameworks>net40;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netcoreapp3.0-windows;netcoreapp3.1-windows;net5.0-windows;net6.0-windows</TargetFrameworks>-->
<TargetFrameworks>net40;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;netcoreapp3.0-windows;netcoreapp3.1-windows;net5.0-windows;net6.0-windows</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>Resources\ICO.ico</ApplicationIcon>
<Version>1.0.0.3</Version>
Expand Down
2 changes: 1 addition & 1 deletion src/Taskbar/Value/Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Values
/// <summary>
///
/// </summary>
public const string ClassName = "Shell_TrayWnd";
internal const string ClassName = "Shell_TrayWnd";

/// <summary>
///
Expand Down
41 changes: 40 additions & 1 deletion src/Taskbar_CR/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions src/Taskbar_CR/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
8 changes: 7 additions & 1 deletion src/Taskbar_CR/Main.resx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@
<metadata name="button10.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<metadata name="button11.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button12.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="button13.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Expand Down
4 changes: 2 additions & 2 deletions src/Taskbar_CR/Taskbar_CR.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<!--<TargetFramework>net48</TargetFramework>-->
<!--<TargetFrameworks>net48;net5.0-windows;net6.0-windows</TargetFrameworks>-->
<!--<TargetFrameworks>net48;netcoreapp3.0-windows;netcoreapp3.1-windows;net5.0-windows;net6.0-windows</TargetFrameworks>-->
<TargetFrameworks>net48;netcoreapp3.0-windows;netcoreapp3.1-windows;net5.0-windows;net6.0-windows</TargetFrameworks>
<OutputType>WinExe</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
Expand Down

0 comments on commit cd75bdd

Please sign in to comment.