Skip to content

Commit

Permalink
Change the condition to perform QuickLook
Browse files Browse the repository at this point in the history
  • Loading branch information
shibayan committed Jan 19, 2016
1 parent e13c9e8 commit b9b4e66
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/WinQuickLook/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public partial class App

private QuickLookWindow _quickLookWindow;

private string _currentItem;

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
Expand Down Expand Up @@ -52,20 +54,21 @@ private void CancelQuickLook()

private void PerformQuickLook()
{
if (_quickLookWindow?.CloseIfActive() ?? false)
{
_quickLookWindow = null;

return;
}

var selectedItem = WinExplorerHelper.GetSelectedItem();

if (selectedItem == null)
if (selectedItem == null || selectedItem == _currentItem)
{
if (_quickLookWindow?.CloseIfActive() ?? false)
{
_currentItem = null;
_quickLookWindow = null;
}

return;
}

_currentItem = selectedItem;

_quickLookWindow?.Close();
_quickLookWindow = null;

Expand Down
3 changes: 3 additions & 0 deletions src/WinQuickLook/Interop/Consts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public static class Consts
public const int WM_KEYDOWN = 0x0100;

public const int MAX_PATH = 260;

public const int GWL_EXSTYLE = -20;
public const int WS_EX_NOACTIVATE = 0x8000000;
}

[Flags]
Expand Down
6 changes: 6 additions & 0 deletions src/WinQuickLook/Interop/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public static class NativeMethods
[DllImport("user32.dll")]
public static extern IntPtr CallNextHookEx(IntPtr hook, int nCode, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll")]
public static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

[DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);

Expand Down

0 comments on commit b9b4e66

Please sign in to comment.