diff --git a/EveRefinery/EveRefinery/EveRefinery.csproj b/EveRefinery/EveRefinery/EveRefinery.csproj
index ed8c1a4..693583f 100644
--- a/EveRefinery/EveRefinery/EveRefinery.csproj
+++ b/EveRefinery/EveRefinery/EveRefinery.csproj
@@ -162,6 +162,7 @@
+
diff --git a/EveRefinery/EveRefinery/FrmMain.cs b/EveRefinery/EveRefinery/FrmMain.cs
index 06c5a31..163a941 100644
--- a/EveRefinery/EveRefinery/FrmMain.cs
+++ b/EveRefinery/EveRefinery/FrmMain.cs
@@ -77,7 +77,19 @@ public FrmMain()
m_RunningListUpdates = 0;
InitializeComponent();
- }
+
+ MouseWheelHook.MouseWheelUp += MouseWheelUp;
+ MouseWheelHook.MouseWheelDown += MouseWheelDown;
+
+ Activated += (sender, args) => MouseWheelHook.Stop();
+ Deactivate += (sender, args) =>
+ {
+ if (TopMost)
+ {
+ MouseWheelHook.Start();
+ }
+ };
+ }
abstract class CompareItemBase : IComparer
{
@@ -1061,6 +1073,24 @@ private void TlbChkAlwaysOnTop_CheckedChanged(object sender, EventArgs e)
TopMost = !TopMost;
}
+ private void MouseWheelUp(object sender, EventArgs e)
+ {
+ int curItem = LstRefinery.TopItem.Index;
+ if (curItem > 0)
+ {
+ LstRefinery.TopItem = LstRefinery.Items[curItem - 1];
+ }
+ }
+
+ private void MouseWheelDown(object sender, EventArgs e)
+ {
+ int curItem = LstRefinery.TopItem.Index;
+ if (curItem < LstRefinery.Items.Count)
+ {
+ LstRefinery.TopItem = LstRefinery.Items[curItem + 1];
+ }
+ }
+
private void TlbBtnExport_Click(object sender, EventArgs e)
{
SaveFileDialog fileDialog = new SaveFileDialog();
diff --git a/EveRefinery/EveRefinery/MouseWheelHook.cs b/EveRefinery/EveRefinery/MouseWheelHook.cs
new file mode 100644
index 0000000..1598b49
--- /dev/null
+++ b/EveRefinery/EveRefinery/MouseWheelHook.cs
@@ -0,0 +1,87 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace EveRefinery
+{
+ public static class MouseWheelHook
+
+ {
+ public static event EventHandler MouseWheelUp = delegate { };
+ public static event EventHandler MouseWheelDown = delegate { };
+
+ public static void Start()
+ {
+ _hookId = SetHook(Proc);
+ }
+
+ public static void Stop()
+ {
+ UnhookWindowsHookEx(_hookId);
+ }
+
+ private static readonly LowLevelMouseProc Proc = HookCallback;
+ private static IntPtr _hookId = IntPtr.Zero;
+
+ private static IntPtr SetHook(LowLevelMouseProc proc)
+ {
+ {
+ IntPtr hook = SetWindowsHookEx(14, proc, GetModuleHandle("user32"), 0);
+ if (hook == IntPtr.Zero) throw new Win32Exception();
+ return hook;
+ }
+ }
+
+ private delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);
+
+ private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
+ {
+ //intercept only WM_MOUSEWHEEL
+ if (nCode >= 0 && (IntPtr) 0x020A == wParam)
+ {
+ MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT) Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
+ if (hookStruct.mouseData > 0)
+ {
+ MouseWheelUp(null, new EventArgs());
+ }
+ else
+ {
+ MouseWheelDown(null, new EventArgs());
+ }
+ }
+
+ return CallNextHookEx(_hookId, nCode, wParam, lParam);
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct MSLLHOOKSTRUCT
+ {
+ public POINT pt;
+ public int mouseData;
+ public uint flags;
+ public uint time;
+ public IntPtr dwExtraInfo;
+ }
+
+ private struct POINT
+ {
+ public int x;
+ public int y;
+ }
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern IntPtr SetWindowsHookEx(int idHook,
+ LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId);
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool UnhookWindowsHookEx(IntPtr hhk);
+
+ [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
+ IntPtr wParam, IntPtr lParam);
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ private static extern IntPtr GetModuleHandle(string lpModuleName);
+ }
+}
\ No newline at end of file