dotnet / dotnet-api-docs

.NET API reference documentation (.NET 5+, .NET Core, .NET Framework)
https://docs.microsoft.com/dotnet/api/
Other
688 stars 1.53k forks source link

Error with Screen.FromControls(this).WorkingArea; #10022

Open johnsone006 opened 2 months ago

johnsone006 commented 2 months ago

5480

private void ScreenshotAutoPlusUI_Load(object sender, EventArgs e) { Rectangle screenRect = Screen.FromControl(this).WorkingArea; this.DesktopBounds = screenRect; int heightSidePanelNeedsToBe = screenRect.Height - HeightOfAreAboveViewport; screenshotAutoTop_Panel.Height = HeightOfAreAboveViewport; screenshotAutoSide_Panel.Height = heightSidePanelNeedsToBe; this.TopMost = true; backgroundWorker1.WorkerSupportsCancellation = true; processUpdates_RTB.Text = "Process status: Opened."; } When I use the code above, the screenshotAutoSide_Panel ends up overlapping the search bar in the taskbar by a few pixels. But my taskbar isn't set to AutoHide. It shouldn't overlap at all; otherwise, what would be the point of having both the Bounds and WorkingArea properties? Indeed, when I used the debugger to see what screenRect was assigned to, the size was the same as the resolution of the monitor the panel appeared on.

dotnet-issue-labeler[bot] commented 2 months ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-issue-labeler[bot] commented 2 months ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

dotnet-policy-service[bot] commented 3 weeks ago

Tagging subscribers to this area: @dotnet/wpf-developers

johnsone006 commented 3 weeks ago

Appreciate the assistance, but I think I should clarify that I was working with a windows forms application, not WPF.

johnsone006 commented 3 weeks ago

Update: so the Bounds and WorkingArea properties of both of my screens now return rectangles with different heights, as they should, because my taskbar is docked at the bottom. I suspect I fixed that problem when I realized that the Top property value of my two screens were not only different, but the the top value of my secondary screen was a negative number (-3, I think, if I remember correctly).