Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve handling of not found exception from GetViewForHwnd() and re-add TogglePin functions #14

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handle view not found
  • Loading branch information
sliddington authored Aug 21, 2016
commit f418c320e29a9ab00f9167cc9098988d3df7daf7
19 changes: 18 additions & 1 deletion source/VirtualDesktop/VirtualDesktop.static.pin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ public static bool IsPinnedWindow(IntPtr hWnd)
{
VirtualDesktopHelper.ThrowIfNotSupported();

return ComObjects.VirtualDesktopPinnedApps.IsViewPinned(hWnd.GetApplicationView());
var view = hWnd.GetApplicationView();

if (view == null)
{
throw new ArgumentException(nameof(hWnd));
}

return ComObjects.VirtualDesktopPinnedApps.IsViewPinned(view);
}

public static void PinWindow(IntPtr hWnd)
Expand All @@ -20,6 +27,11 @@ public static void PinWindow(IntPtr hWnd)

var view = hWnd.GetApplicationView();

if (view == null)
{
throw new ArgumentException(nameof(hWnd));
}

if (!ComObjects.VirtualDesktopPinnedApps.IsViewPinned(view))
{
ComObjects.VirtualDesktopPinnedApps.PinView(view);
Expand All @@ -32,6 +44,11 @@ public static void UnpinWindow(IntPtr hWnd)

var view = hWnd.GetApplicationView();

if (view == null)
{
throw new ArgumentException(nameof(hWnd));
}

if (ComObjects.VirtualDesktopPinnedApps.IsViewPinned(view))
{
ComObjects.VirtualDesktopPinnedApps.UnpinView(view);
Expand Down