mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 05:31:03 +00:00
Update WelsonJS.Toolkit
This commit is contained in:
parent
27d0521de5
commit
2a465de78f
|
@ -14,6 +14,7 @@
|
||||||
* - https://stackoverflow.com/questions/13547639/return-window-handle-by-its-name-title
|
* - https://stackoverflow.com/questions/13547639/return-window-handle-by-its-name-title
|
||||||
* - https://blog.naver.com/zlatmgpdjtiq/222016292758
|
* - https://blog.naver.com/zlatmgpdjtiq/222016292758
|
||||||
* - https://stackoverflow.com/questions/5427020/prompt-dialog-in-windows-forms
|
* - https://stackoverflow.com/questions/5427020/prompt-dialog-in-windows-forms
|
||||||
|
* - https://stackoverflow.com/questions/60203135/set-delta-in-a-wm-mousewheel-message-to-send-with-postmessage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
@ -56,6 +57,32 @@ namespace WelsonJS
|
||||||
WM_CHAR = 0x102, //char
|
WM_CHAR = 0x102, //char
|
||||||
WM_COMMAND = 0x111
|
WM_COMMAND = 0x111
|
||||||
}
|
}
|
||||||
|
public enum WinMsgMouseKey : int
|
||||||
|
{
|
||||||
|
MK_NONE = 0x0000,
|
||||||
|
MK_LBUTTON = 0x0001,
|
||||||
|
MK_RBUTTON = 0x0002,
|
||||||
|
MK_SHIFT = 0x0004,
|
||||||
|
MK_CONTROL = 0x0008,
|
||||||
|
MK_MBUTTON = 0x0010,
|
||||||
|
MK_XBUTTON1 = 0x0020,
|
||||||
|
MK_XBUTTON2 = 0x0040
|
||||||
|
}
|
||||||
|
|
||||||
|
public int directionUp = 1;
|
||||||
|
public int directionDown = -1;
|
||||||
|
public const uint WM_MOUSEWHEEL = 0x020A;
|
||||||
|
|
||||||
|
public IntPtr MAKEWPARAM(int direction, float multiplier, WinMsgMouseKey button)
|
||||||
|
{
|
||||||
|
int delta = (int)(SystemInformation.MouseWheelScrollDelta * multiplier);
|
||||||
|
return (IntPtr)(((delta << 16) * Math.Sign(direction) | (ushort)button));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr MAKELPARAM(int low, int high)
|
||||||
|
{
|
||||||
|
return (IntPtr)((high << 16) | (low & 0xFFFF));
|
||||||
|
}
|
||||||
|
|
||||||
public IntPtr QueryHandleWindow(string wName)
|
public IntPtr QueryHandleWindow(string wName)
|
||||||
{
|
{
|
||||||
|
@ -137,5 +164,39 @@ namespace WelsonJS
|
||||||
string result = WelsonJS.Prompt.ShowDialog(message, ApplicationName);
|
string result = WelsonJS.Prompt.ShowDialog(message, ApplicationName);
|
||||||
return (result == "" ? _default : result);
|
return (result == "" ? _default : result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ComVisible(true)]
|
||||||
|
public bool MouseWheelDown(string wName)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
IntPtr hWnd = QueryHandleWindow(wName);
|
||||||
|
if (hWnd != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
// Scrolls [Handle] down by 1/2 wheel rotation with Left Button pressed
|
||||||
|
IntPtr wParam = MAKEWPARAM(directionDown, .5f, WinMsgMouseKey.MK_LBUTTON);
|
||||||
|
IntPtr lParam = MAKELPARAM(Cursor.Position.X, Cursor.Position.Y);
|
||||||
|
result = PostMessage(hWnd, WM_MOUSEWHEEL, (int)wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ComVisible(true)]
|
||||||
|
public bool MouseWheelUp(string wName)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
IntPtr hWnd = QueryHandleWindow(wName);
|
||||||
|
if (hWnd != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
// Scrolls [Handle] up by 1/2 wheel rotation with Left Button pressed
|
||||||
|
IntPtr wParam = MAKEWPARAM(directionUp, .5f, WinMsgMouseKey.MK_LBUTTON);
|
||||||
|
IntPtr lParam = MAKELPARAM(Cursor.Position.X, Cursor.Position.Y);
|
||||||
|
result = PostMessage(hWnd, WM_MOUSEWHEEL, (int)wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user