Skip to content

Commit 4c89df9

Browse files
committed
Issue #43 Fixed delays when using some software 2
1 parent f7de3c6 commit 4c89df9

File tree

5 files changed

+4
-198
lines changed

5 files changed

+4
-198
lines changed

SmartSystemMenu/Hooks/CBTHook.cs

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,33 @@ namespace SmartSystemMenu.Hooks
55
{
66
class CBTHook : Hook
77
{
8-
private int _msgIdCbtHookReplaced;
9-
private int _msgIdCbtActivate;
108
private int _msgIdCbtCreateWnd;
119
private int _msgIdCbtDestroyWnd;
1210
private int _msgIdCbtMinMax;
1311
private int _msgIdCbtMoveSize;
14-
private int _msgIdCbtSetFocus;
15-
private int _msgIdCbtSysCommand;
1612

17-
public event EventHandler<EventArgs> HookReplaced;
18-
public event EventHandler<WindowEventArgs> WindowActivated;
1913
public event EventHandler<WindowEventArgs> WindowCreated;
2014
public event EventHandler<WindowEventArgs> WindowDestroyed;
2115
public event EventHandler<SysCommandEventArgs> MinMax;
2216
public event EventHandler<WindowEventArgs> MoveSize;
23-
public event EventHandler<WindowEventArgs> SetFocus;
24-
public event EventHandler<SysCommandEventArgs> SysCommand;
2517

2618
public CBTHook(IntPtr handle, int dragByMouseMenuItem) : base(handle, dragByMouseMenuItem)
2719
{
2820
}
2921

3022
protected override void OnStart()
3123
{
32-
_msgIdCbtHookReplaced = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_CBT_REPLACED");
33-
_msgIdCbtActivate = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HCBT_ACTIVATE");
3424
_msgIdCbtCreateWnd = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HCBT_CREATEWND");
3525
_msgIdCbtDestroyWnd = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HCBT_DESTROYWND");
3626
_msgIdCbtMinMax = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HCBT_MINMAX");
3727
_msgIdCbtMoveSize = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HCBT_MOVESIZE");
38-
_msgIdCbtSetFocus = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HCBT_SETFOCUS");
39-
_msgIdCbtSysCommand = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HCBT_SYSCOMMAND");
4028

4129
if (Environment.OSVersion.Version.Major >= 6)
4230
{
43-
NativeMethods.ChangeWindowMessageFilter(_msgIdCbtHookReplaced, NativeConstants.MSGFLT_ADD);
44-
NativeMethods.ChangeWindowMessageFilter(_msgIdCbtActivate, NativeConstants.MSGFLT_ADD);
4531
NativeMethods.ChangeWindowMessageFilter(_msgIdCbtCreateWnd, NativeConstants.MSGFLT_ADD);
4632
NativeMethods.ChangeWindowMessageFilter(_msgIdCbtDestroyWnd, NativeConstants.MSGFLT_ADD);
4733
NativeMethods.ChangeWindowMessageFilter(_msgIdCbtMinMax, NativeConstants.MSGFLT_ADD);
4834
NativeMethods.ChangeWindowMessageFilter(_msgIdCbtMoveSize, NativeConstants.MSGFLT_ADD);
49-
NativeMethods.ChangeWindowMessageFilter(_msgIdCbtSetFocus, NativeConstants.MSGFLT_ADD);
50-
NativeMethods.ChangeWindowMessageFilter(_msgIdCbtSysCommand, NativeConstants.MSGFLT_ADD);
5135
}
5236
NativeHookMethods.InitializeCbtHook(0, _handle, _dragByMouseMenuItem);
5337
}
@@ -59,15 +43,7 @@ protected override void OnStop()
5943

6044
public override void ProcessWindowMessage(ref System.Windows.Forms.Message m)
6145
{
62-
if (m.Msg == _msgIdCbtHookReplaced)
63-
{
64-
RaiseEvent(HookReplaced, EventArgs.Empty);
65-
}
66-
else if (m.Msg == _msgIdCbtActivate)
67-
{
68-
RaiseEvent(WindowActivated, new WindowEventArgs(m.WParam));
69-
}
70-
else if (m.Msg == _msgIdCbtCreateWnd)
46+
if (m.Msg == _msgIdCbtCreateWnd)
7147
{
7248
RaiseEvent(WindowCreated, new WindowEventArgs(m.WParam));
7349
}
@@ -83,14 +59,6 @@ public override void ProcessWindowMessage(ref System.Windows.Forms.Message m)
8359
{
8460
RaiseEvent(MoveSize, new WindowEventArgs(m.WParam));
8561
}
86-
else if (m.Msg == _msgIdCbtSetFocus)
87-
{
88-
RaiseEvent(SetFocus, new WindowEventArgs(m.WParam));
89-
}
90-
else if (m.Msg == _msgIdCbtSysCommand)
91-
{
92-
RaiseEvent(SysCommand, new SysCommandEventArgs(m.WParam, m.LParam));
93-
}
9462
}
9563
}
9664
}

SmartSystemMenu/Hooks/CallWndProcHook.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ class CallWndProcHook : Hook
77
{
88
private int _msgIdCallWndProc;
99
private int _msgIdCallWndProcParams;
10-
private int _msgIdCallWndProcHookReplaced;
1110
private IntPtr _cacheHandle;
1211
private IntPtr _cacheMessage;
1312

14-
public event EventHandler<EventArgs> HookReplaced;
1513
public event EventHandler<WndProcEventArgs> CallWndProc;
1614

1715
public CallWndProcHook(IntPtr handle, int dragByMouseMenuItem) : base(handle, dragByMouseMenuItem)
@@ -20,13 +18,11 @@ public CallWndProcHook(IntPtr handle, int dragByMouseMenuItem) : base(handle, dr
2018

2119
protected override void OnStart()
2220
{
23-
_msgIdCallWndProcHookReplaced = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_CALLWNDPROC_REPLACED");
2421
_msgIdCallWndProc = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_CALLWNDPROC");
2522
_msgIdCallWndProcParams = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_CALLWNDPROC_PARAMS");
2623

2724
if (Environment.OSVersion.Version.Major >= 6)
2825
{
29-
NativeMethods.ChangeWindowMessageFilter(_msgIdCallWndProcHookReplaced, NativeConstants.MSGFLT_ADD);
3026
NativeMethods.ChangeWindowMessageFilter(_msgIdCallWndProc, NativeConstants.MSGFLT_ADD);
3127
NativeMethods.ChangeWindowMessageFilter(_msgIdCallWndProcParams, NativeConstants.MSGFLT_ADD);
3228
}
@@ -54,10 +50,6 @@ public override void ProcessWindowMessage(ref System.Windows.Forms.Message m)
5450
_cacheHandle = IntPtr.Zero;
5551
_cacheMessage = IntPtr.Zero;
5652
}
57-
else if (m.Msg == _msgIdCallWndProcHookReplaced)
58-
{
59-
RaiseEvent(HookReplaced, EventArgs.Empty);
60-
}
6153
}
6254
}
6355
}

SmartSystemMenu/Hooks/GetMsgHook.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ class GetMsgHook : Hook
77
{
88
private int _msgIdGetMsg;
99
private int _msgIdGetMsgParams;
10-
private int _msgIdGetMsgHookReplaced;
1110
private IntPtr _cacheHandle;
1211
private IntPtr _cacheMessage;
1312

14-
public event EventHandler<EventArgs> HookReplaced;
1513
public event EventHandler<WndProcEventArgs> GetMsg;
1614

1715
public GetMsgHook(IntPtr handle, int dragByMouseMenuItem) : base(handle, dragByMouseMenuItem)
@@ -20,13 +18,11 @@ public GetMsgHook(IntPtr handle, int dragByMouseMenuItem) : base(handle, dragByM
2018

2119
protected override void OnStart()
2220
{
23-
_msgIdGetMsgHookReplaced = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_GETMSG_REPLACED");
2421
_msgIdGetMsg = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_GETMSG");
2522
_msgIdGetMsgParams = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_GETMSG_PARAMS");
2623

2724
if (Environment.OSVersion.Version.Major >= 6)
2825
{
29-
NativeMethods.ChangeWindowMessageFilter(_msgIdGetMsgHookReplaced, NativeConstants.MSGFLT_ADD);
3026
NativeMethods.ChangeWindowMessageFilter(_msgIdGetMsg, NativeConstants.MSGFLT_ADD);
3127
NativeMethods.ChangeWindowMessageFilter(_msgIdGetMsgParams, NativeConstants.MSGFLT_ADD);
3228
}
@@ -65,10 +61,6 @@ public override void ProcessWindowMessage(ref System.Windows.Forms.Message m)
6561
_cacheHandle = IntPtr.Zero;
6662
_cacheMessage = IntPtr.Zero;
6763
}
68-
else if (m.Msg == _msgIdGetMsgHookReplaced)
69-
{
70-
RaiseEvent(HookReplaced, EventArgs.Empty);
71-
}
7264
}
7365
}
7466
}

SmartSystemMenu/Hooks/ShellHook.cs

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,9 @@ namespace SmartSystemMenu.Hooks
55
{
66
class ShellHook : Hook
77
{
8-
private int _msgIdShellActivateShellWindow;
9-
private int _msgIdShellGetMinRect;
10-
private int _msgIdShellLanguage;
11-
private int _msgIdShellRedraw;
12-
private int _msgIdShellTaskman;
13-
private int _msgIdShellHookReplaced;
14-
private int _msgIdShellWindowActivated;
158
private int _msgIdShellWindowCreated;
169
private int _msgIdShellWindowDestroyed;
1710

18-
public event EventHandler<EventArgs> HookReplaced;
19-
public event EventHandler<EventArgs> ActivateShellWindow;
20-
public event EventHandler<WindowEventArgs> GetMinRect;
21-
public event EventHandler<WindowEventArgs> Language;
22-
public event EventHandler<WindowEventArgs> Redraw;
23-
public event EventHandler<EventArgs> Taskman;
24-
public event EventHandler<WindowEventArgs> WindowActivated;
2511
public event EventHandler<WindowEventArgs> WindowCreated;
2612
public event EventHandler<WindowEventArgs> WindowDestroyed;
2713

@@ -31,25 +17,11 @@ public ShellHook(IntPtr handle, int dragByMouseMenuItem) : base(handle, dragByMo
3117

3218
protected override void OnStart()
3319
{
34-
_msgIdShellHookReplaced = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_SHELL_REPLACED");
35-
_msgIdShellActivateShellWindow = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HSHELL_ACTIVATESHELLWINDOW");
36-
_msgIdShellGetMinRect = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HSHELL_GETMINRECT");
37-
_msgIdShellLanguage = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HSHELL_LANGUAGE");
38-
_msgIdShellRedraw = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HSHELL_REDRAW");
39-
_msgIdShellTaskman = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HSHELL_TASKMAN");
40-
_msgIdShellWindowActivated = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HSHELL_WINDOWACTIVATED");
4120
_msgIdShellWindowCreated = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HSHELL_WINDOWCREATED");
4221
_msgIdShellWindowDestroyed = NativeMethods.RegisterWindowMessage("SMART_SYSTEM_MENU_HOOK_HSHELL_WINDOWDESTROYED");
4322

4423
if (Environment.OSVersion.Version.Major >= 6)
4524
{
46-
NativeMethods.ChangeWindowMessageFilter(_msgIdShellHookReplaced, NativeConstants.MSGFLT_ADD);
47-
NativeMethods.ChangeWindowMessageFilter(_msgIdShellActivateShellWindow, NativeConstants.MSGFLT_ADD);
48-
NativeMethods.ChangeWindowMessageFilter(_msgIdShellGetMinRect, NativeConstants.MSGFLT_ADD);
49-
NativeMethods.ChangeWindowMessageFilter(_msgIdShellLanguage, NativeConstants.MSGFLT_ADD);
50-
NativeMethods.ChangeWindowMessageFilter(_msgIdShellRedraw, NativeConstants.MSGFLT_ADD);
51-
NativeMethods.ChangeWindowMessageFilter(_msgIdShellTaskman, NativeConstants.MSGFLT_ADD);
52-
NativeMethods.ChangeWindowMessageFilter(_msgIdShellWindowActivated, NativeConstants.MSGFLT_ADD);
5325
NativeMethods.ChangeWindowMessageFilter(_msgIdShellWindowCreated, NativeConstants.MSGFLT_ADD);
5426
NativeMethods.ChangeWindowMessageFilter(_msgIdShellWindowDestroyed, NativeConstants.MSGFLT_ADD);
5527
}
@@ -63,35 +35,7 @@ protected override void OnStop()
6335

6436
public override void ProcessWindowMessage(ref System.Windows.Forms.Message m)
6537
{
66-
if (m.Msg == _msgIdShellHookReplaced)
67-
{
68-
RaiseEvent(HookReplaced, EventArgs.Empty);
69-
}
70-
else if (m.Msg == _msgIdShellActivateShellWindow)
71-
{
72-
RaiseEvent(ActivateShellWindow, EventArgs.Empty);
73-
}
74-
else if (m.Msg == _msgIdShellGetMinRect)
75-
{
76-
RaiseEvent(GetMinRect, new WindowEventArgs(m.WParam));
77-
}
78-
else if (m.Msg == _msgIdShellLanguage)
79-
{
80-
RaiseEvent(Language, new WindowEventArgs(m.WParam));
81-
}
82-
else if (m.Msg == _msgIdShellRedraw)
83-
{
84-
RaiseEvent(Redraw, new WindowEventArgs(m.WParam));
85-
}
86-
else if (m.Msg == _msgIdShellTaskman)
87-
{
88-
RaiseEvent(Taskman, EventArgs.Empty);
89-
}
90-
else if (m.Msg == _msgIdShellWindowActivated)
91-
{
92-
RaiseEvent(WindowActivated, new WindowEventArgs(m.WParam));
93-
}
94-
else if (m.Msg == _msgIdShellWindowCreated)
38+
if (m.Msg == _msgIdShellWindowCreated)
9539
{
9640
RaiseEvent(WindowCreated, new WindowEventArgs(m.WParam));
9741
}

0 commit comments

Comments
 (0)