Refactored native message codes in separate classes for nicer syntax.

This commit is contained in:
Lorenz Cuno Klopfenstein 2010-07-01 13:05:27 +02:00
parent 3924fa7d0b
commit 3673ba6a17
13 changed files with 144 additions and 98 deletions

View file

@ -138,14 +138,14 @@ namespace OnTopReplica {
/// Improved with code from: http://stoyanoff.info/blog/2010/06/27/resizing-forms-while-keeping-aspect-ratio/
/// </summary>
protected override void WndProc(ref Message m) {
if (KeepAspectRatio && m.Msg == MessagingMethods.WM_SIZING) {
if (KeepAspectRatio && m.Msg == WM.SIZING) {
var rc = (Native.NRectangle)Marshal.PtrToStructure(m.LParam, typeof(Native.NRectangle));
int res = m.WParam.ToInt32();
int width = (rc.Right - rc.Left) - clientSizeConversionWidth - ExtraPadding.Horizontal;
int height = (rc.Bottom - rc.Top) - clientSizeConversionHeight - ExtraPadding.Vertical;
if (res == MessagingMethods.WMSZ_LEFT || res == MessagingMethods.WMSZ_RIGHT) {
if (res == WMSZ.LEFT || res == WMSZ.RIGHT) {
//Left or right resize, adjust top and bottom
int targetHeight = (int)(width / AspectRatio);
int diffHeight = height - targetHeight;
@ -153,7 +153,7 @@ namespace OnTopReplica {
rc.Top += (int)(diffHeight / 2.0);
rc.Bottom = rc.Top + targetHeight + ExtraPadding.Vertical + clientSizeConversionHeight;
}
else if (res == MessagingMethods.WMSZ_TOP || res == MessagingMethods.WMSZ_BOTTOM) {
else if (res == WMSZ.TOP || res == WMSZ.BOTTOM) {
//Up or down resize, adjust left and right
int targetWidth = (int)(height * AspectRatio);
int diffWidth = width - targetWidth;
@ -161,11 +161,11 @@ namespace OnTopReplica {
rc.Left += (int)(diffWidth / 2.0);
rc.Right = rc.Left + targetWidth + ExtraPadding.Horizontal + clientSizeConversionWidth;
}
else if (res == MessagingMethods.WMSZ_RIGHT + MessagingMethods.WMSZ_BOTTOM || res == MessagingMethods.WMSZ_LEFT + MessagingMethods.WMSZ_BOTTOM) {
else if (res == WMSZ.RIGHT + WMSZ.BOTTOM || res == WMSZ.LEFT + WMSZ.BOTTOM) {
//Lower corner resize, adjust bottom
rc.Bottom = rc.Top + (int)(width / AspectRatio) + ExtraPadding.Vertical + clientSizeConversionHeight;
}
else if (res == MessagingMethods.WMSZ_LEFT + MessagingMethods.WMSZ_TOP || res == MessagingMethods.WMSZ_RIGHT + MessagingMethods.WMSZ_TOP) {
else if (res == WMSZ.LEFT + WMSZ.TOP || res == WMSZ.RIGHT + WMSZ.TOP) {
//Upper corner resize, adjust top
rc.Top = rc.Bottom - (int)(width / AspectRatio) - ExtraPadding.Vertical - clientSizeConversionHeight;
}

View file

@ -34,15 +34,16 @@
this.switchToWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.selectRegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.forwardClicksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clickthroughToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dualWindowModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clickForwardingToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.clickThroughToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupSwitchModeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuContextOpacity = new System.Windows.Forms.ToolStripMenuItem();
this.menuOpacity = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripMenuItem();
this.fullOpacityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.resizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuResize = new System.Windows.Forms.ContextMenuStrip(this.components);
this.doubleToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
@ -68,7 +69,6 @@
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuContextClose = new System.Windows.Forms.ToolStripMenuItem();
this.fullSelectWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.fullOpacityToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.danskToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.menuFullscreenContext = new System.Windows.Forms.ContextMenuStrip(this.components);
this.enableClickthroughToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@ -98,7 +98,7 @@
this.aboutToolStripMenuItem,
this.menuContextClose});
this.menuContext.Name = "menuContext";
this.menuContext.Size = new System.Drawing.Size(169, 274);
this.menuContext.Size = new System.Drawing.Size(169, 296);
this.menuContext.Opening += new System.ComponentModel.CancelEventHandler(this.Menu_opening);
//
// menuContextWindows
@ -115,13 +115,14 @@
this.menuWindows.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.noneToolStripMenuItem});
this.menuWindows.Name = "menuWindows";
this.menuWindows.Size = new System.Drawing.Size(153, 48);
this.menuWindows.OwnerItem = this.fullSelectWindowToolStripMenuItem;
this.menuWindows.Size = new System.Drawing.Size(118, 26);
this.menuWindows.Opening += new System.ComponentModel.CancelEventHandler(this.Menu_Windows_opening);
//
// noneToolStripMenuItem
//
this.noneToolStripMenuItem.Name = "noneToolStripMenuItem";
this.noneToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.noneToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
this.noneToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuWindowsNone;
//
// switchToWindowToolStripMenuItem
@ -146,38 +147,37 @@
// advancedToolStripMenuItem
//
this.advancedToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.forwardClicksToolStripMenuItem,
this.clickthroughToolStripMenuItem,
this.dualWindowModeToolStripMenuItem});
this.clickForwardingToolStripMenuItem,
this.clickThroughToolStripMenuItem,
this.groupSwitchModeToolStripMenuItem});
this.advancedToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.xiao_wrench;
this.advancedToolStripMenuItem.Name = "advancedToolStripMenuItem";
this.advancedToolStripMenuItem.Size = new System.Drawing.Size(168, 22);
this.advancedToolStripMenuItem.Text = Strings.MenuAdvanced;
this.advancedToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuAdvanced;
//
// forwardClicksToolStripMenuItem
// clickForwardingToolStripMenuItem
//
this.forwardClicksToolStripMenuItem.Name = "forwardClicksToolStripMenuItem";
this.forwardClicksToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.forwardClicksToolStripMenuItem.Text = Strings.MenuClickForwarding;
this.forwardClicksToolStripMenuItem.ToolTipText = Strings.MenuClickForwardingTT;
this.forwardClicksToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuClickForwardingTT;
this.forwardClicksToolStripMenuItem.Click += new System.EventHandler(this.Menu_ClickForwarding_click);
this.clickForwardingToolStripMenuItem.Name = "clickForwardingToolStripMenuItem";
this.clickForwardingToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.clickForwardingToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuClickForwarding;
this.clickForwardingToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuClickForwardingTT;
this.clickForwardingToolStripMenuItem.Click += new System.EventHandler(this.Menu_ClickForwarding_click);
//
// clickthroughToolStripMenuItem
// clickThroughToolStripMenuItem
//
this.clickthroughToolStripMenuItem.Name = "clickthroughToolStripMenuItem";
this.clickthroughToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.clickthroughToolStripMenuItem.Text = Strings.MenuClickThrough;
this.clickthroughToolStripMenuItem.ToolTipText = Strings.MenuClickThroughTT;
this.clickthroughToolStripMenuItem.Click += new System.EventHandler(this.Menu_ClickThrough_click);
this.clickThroughToolStripMenuItem.Name = "clickThroughToolStripMenuItem";
this.clickThroughToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.clickThroughToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuClickThrough;
this.clickThroughToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuClickThroughTT;
this.clickThroughToolStripMenuItem.Click += new System.EventHandler(this.Menu_ClickThrough_click);
//
// dualWindowModeToolStripMenuItem
// groupSwitchModeToolStripMenuItem
//
this.dualWindowModeToolStripMenuItem.Name = "dualWindowModeToolStripMenuItem";
this.dualWindowModeToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.dualWindowModeToolStripMenuItem.Text = Strings.MenuGroupSwitch;
this.dualWindowModeToolStripMenuItem.ToolTipText = Strings.MenuGroupSwitchTT;
this.dualWindowModeToolStripMenuItem.Click += new System.EventHandler(this.Menu_GroupSwitchMode_click);
this.groupSwitchModeToolStripMenuItem.Name = "groupSwitchModeToolStripMenuItem";
this.groupSwitchModeToolStripMenuItem.Size = new System.Drawing.Size(199, 22);
this.groupSwitchModeToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuGroupSwitch;
this.groupSwitchModeToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuGroupSwitchTT;
this.groupSwitchModeToolStripMenuItem.Click += new System.EventHandler(this.Menu_GroupSwitchMode_click);
//
// menuContextOpacity
//
@ -195,7 +195,7 @@
this.toolStripMenuItem3,
this.toolStripMenuItem4});
this.menuOpacity.Name = "menuOpacity";
this.menuOpacity.OwnerItem = this.fullOpacityToolStripMenuItem;
this.menuOpacity.OwnerItem = this.menuContextOpacity;
this.menuOpacity.ShowCheckMargin = true;
this.menuOpacity.ShowImageMargin = false;
this.menuOpacity.Size = new System.Drawing.Size(154, 92);
@ -239,6 +239,13 @@
this.toolStripMenuItem4.ToolTipText = global::OnTopReplica.Strings.MenuOp25TT;
this.toolStripMenuItem4.Click += new System.EventHandler(this.Menu_Opacity_click);
//
// fullOpacityToolStripMenuItem
//
this.fullOpacityToolStripMenuItem.DropDown = this.menuOpacity;
this.fullOpacityToolStripMenuItem.Name = "fullOpacityToolStripMenuItem";
this.fullOpacityToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.fullOpacityToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuOpacity;
//
// resizeToolStripMenuItem
//
this.resizeToolStripMenuItem.DropDown = this.menuResize;
@ -444,15 +451,8 @@
this.fullSelectWindowToolStripMenuItem.DropDown = this.menuWindows;
this.fullSelectWindowToolStripMenuItem.Name = "fullSelectWindowToolStripMenuItem";
this.fullSelectWindowToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.fullSelectWindowToolStripMenuItem.Text = Strings.MenuWindows;
this.fullSelectWindowToolStripMenuItem.ToolTipText = Strings.MenuWindowsTT;
//
// fullOpacityToolStripMenuItem
//
this.fullOpacityToolStripMenuItem.DropDown = this.menuOpacity;
this.fullOpacityToolStripMenuItem.Name = "fullOpacityToolStripMenuItem";
this.fullOpacityToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.fullOpacityToolStripMenuItem.Text = Strings.MenuOpacity;
this.fullSelectWindowToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuWindows;
this.fullSelectWindowToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuWindowsTT;
//
// danskToolStripMenuItem
//
@ -477,8 +477,8 @@
//
this.enableClickthroughToolStripMenuItem.Name = "enableClickthroughToolStripMenuItem";
this.enableClickthroughToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
this.enableClickthroughToolStripMenuItem.Text = Strings.MenuClickThrough;
this.enableClickthroughToolStripMenuItem.ToolTipText = Strings.MenuClickThroughTT;
this.enableClickthroughToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuClickThrough;
this.enableClickthroughToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuClickThroughTT;
this.enableClickthroughToolStripMenuItem.Click += new System.EventHandler(this.Menu_ClickThrough_click);
//
// fullExitToolStripMenuItem
@ -486,7 +486,7 @@
this.fullExitToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.close_new;
this.fullExitToolStripMenuItem.Name = "fullExitToolStripMenuItem";
this.fullExitToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
this.fullExitToolStripMenuItem.Text = Strings.MenuQuitFullscreen;
this.fullExitToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuQuitFullscreen;
this.fullExitToolStripMenuItem.Click += new System.EventHandler(this.Menu_Fullscreen_ExitFullscreen_click);
//
// MainForm
@ -555,9 +555,9 @@
private System.Windows.Forms.ToolStripMenuItem fullOpacityToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem fullExitToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem advancedToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem forwardClicksToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem clickthroughToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem dualWindowModeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem clickForwardingToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem clickThroughToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem groupSwitchModeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem enableClickthroughToolStripMenuItem;
}
}

View file

@ -114,8 +114,10 @@ namespace OnTopReplica {
protected override void OnMouseWheel(MouseEventArgs e) {
base.OnMouseWheel(e);
int change = (int)(e.Delta / 6.0); //assumes a mouse wheel "tick" is in the 80-120 range
AdjustSize(change);
if (!IsFullscreen) {
int change = (int)(e.Delta / 6.0); //assumes a mouse wheel "tick" is in the 80-120 range
AdjustSize(change);
}
}
protected override void OnMouseDoubleClick(MouseEventArgs e) {
@ -140,9 +142,9 @@ namespace OnTopReplica {
_msgPumpManager.PumpMessage(m);
switch (m.Msg) {
case MessagingMethods.WM_NCRBUTTONUP:
case WM.NCRBUTTONUP:
//Open context menu if right button clicked on caption (i.e. all of the window area because of glass)
if (m.WParam.ToInt32() == MessagingMethods.HTCAPTION) {
if (m.WParam.ToInt32() == HT.CAPTION) {
OpenContextMenu();
m.Result = IntPtr.Zero;
@ -150,9 +152,9 @@ namespace OnTopReplica {
}
break;
case MessagingMethods.WM_NCLBUTTONDBLCLK:
case WM.NCLBUTTONDBLCLK:
//Toggle fullscreen mode if double click on caption (whole glass area)
if (m.WParam.ToInt32() == MessagingMethods.HTCAPTION) {
if (m.WParam.ToInt32() == HT.CAPTION) {
IsFullscreen = !IsFullscreen;
m.Result = IntPtr.Zero;
@ -160,10 +162,10 @@ namespace OnTopReplica {
}
break;
case MessagingMethods.WM_NCHITTEST:
case WM.NCHITTEST:
//Make transparent to hit-testing if in click through mode
if (ClickThroughEnabled) {
m.Result = (IntPtr)MessagingMethods.HTTRANSPARENT;
m.Result = (IntPtr)HT.TRANSPARENT;
return;
}
break;

View file

@ -21,9 +21,11 @@ namespace OnTopReplica {
switchToWindowToolStripMenuItem.Enabled = showing;
resizeToolStripMenuItem.Enabled = showing;
chromeToolStripMenuItem.Checked = (FormBorderStyle == FormBorderStyle.Sizable);
forwardClicksToolStripMenuItem.Checked = _thumbnailPanel.ReportThumbnailClicks;
clickForwardingToolStripMenuItem.Checked = _thumbnailPanel.ReportThumbnailClicks;
chromeToolStripMenuItem.Enabled = showing;
advancedToolStripMenuItem.Enabled = showing;
clickThroughToolStripMenuItem.Enabled = showing;
clickForwardingToolStripMenuItem.Enabled = showing;
}
private void Menu_Windows_opening(object sender, CancelEventArgs e) {

14
OnTopReplica/Native/HT.cs Normal file
View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OnTopReplica.Native {
/// <summary>
/// Native Win32 Hit Testing codes.
/// </summary>
static class HT {
public const int TRANSPARENT = -1;
public const int CLIENT = 1;
public const int CAPTION = 2;
}
}

14
OnTopReplica/Native/MK.cs Normal file
View file

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OnTopReplica.Native {
/// <summary>
/// Native Mouse click codes.
/// </summary>
static class MK {
public const int LBUTTON = 0x0001;
public const int RBUTTON = 0x0002;
public const int MBUTTON = 0x0010;
}
}

View file

@ -9,14 +9,6 @@ namespace OnTopReplica.Native {
/// </summary>
static class MessagingMethods {
public const int WM_GETICON = 0x7f;
public const int WM_SIZING = 0x214;
public const int WMSZ_LEFT = 1;
public const int WMSZ_RIGHT = 2;
public const int WMSZ_TOP = 3;
public const int WMSZ_BOTTOM = 6;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
@ -34,26 +26,6 @@ namespace OnTopReplica.Native {
[DllImport("user32.dll", SetLastError = false)]
public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
public const int HTTRANSPARENT = -1;
public const int HTCLIENT = 1;
public const int HTCAPTION = 2;
public const int WM_NCHITTEST = 0x84;
public const int WM_NCPAINT = 0x0085;
public const int WM_LBUTTONDOWN = 0x0201;
public const int WM_LBUTTONUP = 0x0202;
public const int WM_LBUTTONDBLCLK = 0x0203;
public const int WM_NCLBUTTONUP = 0x00A2;
public const int WM_NCLBUTTONDOWN = 0x00A1;
public const int WM_NCLBUTTONDBLCLK = 0x00A3;
public const int WM_NCRBUTTONUP = 0x00A5;
public const int MK_LBUTTON = 0x0001;
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MAXIMIZE = 61458;
public const int SC_RESTORE = 61490;
public static IntPtr MakeLParam(int LoWord, int HiWord) {
return new IntPtr((HiWord << 16) | (LoWord & 0xffff));
}

23
OnTopReplica/Native/WM.cs Normal file
View file

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OnTopReplica.Native {
/// <summary>
/// Native Windows Message codes.
/// </summary>
static class WM {
public const int GETICON = 0x7f;
public const int SIZING = 0x214;
public const int NCHITTEST = 0x84;
public const int NCPAINT = 0x0085;
public const int LBUTTONDOWN = 0x0201;
public const int LBUTTONUP = 0x0202;
public const int LBUTTONDBLCLK = 0x0203;
public const int NCLBUTTONUP = 0x00A2;
public const int NCLBUTTONDOWN = 0x00A1;
public const int NCLBUTTONDBLCLK = 0x00A3;
public const int NCRBUTTONUP = 0x00A5;
public const int SYSCOMMAND = 0x0112;
}
}

View file

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace OnTopReplica.Native {
/// <summary>
/// Native Win32 sizing codes (used by WM_SIZING message).
/// </summary>
static class WMSZ {
public const int LEFT = 1;
public const int RIGHT = 2;
public const int TOP = 3;
public const int BOTTOM = 6;
}
}

View file

@ -148,11 +148,15 @@
<Compile Include="Native\ErrorMethods.cs" />
<Compile Include="Native\HookMethods.cs" />
<Compile Include="Native\HotKeyMethods.cs" />
<Compile Include="Native\HT.cs" />
<Compile Include="Native\MessagingMethods.cs" />
<Compile Include="Native\MK.cs" />
<Compile Include="Native\Point.cs" />
<Compile Include="Native\Rectangle.cs" />
<Compile Include="Native\WindowManagerMethods.cs" />
<Compile Include="Native\WindowMethods.cs" />
<Compile Include="Native\WM.cs" />
<Compile Include="Native\WMSZ.cs" />
<Compile Include="SidePanel.cs">
<SubType>UserControl</SubType>
</Compile>

View file

@ -136,10 +136,10 @@ namespace OnTopReplica {
base.WndProc(ref m);
//Make transparent to hit-testing if clicks must not be registered
if (m.Msg == MessagingMethods.WM_NCHITTEST && m.Result.ToInt32() == MessagingMethods.HTCLIENT &&
if (m.Msg == WM.NCHITTEST && m.Result.ToInt32() == HT.CLIENT &&
!DrawMouseRegions && !ReportThumbnailClicks) {
m.Result = new IntPtr(MessagingMethods.HTTRANSPARENT);
m.Result = new IntPtr(HT.TRANSPARENT);
}
}

View file

@ -32,11 +32,11 @@ namespace OnTopReplica {
private static void InjectLeftMouseClick(IntPtr child, Native.NPoint clientLocation) {
IntPtr lParamClickLocation = MessagingMethods.MakeLParam(clientLocation.X, clientLocation.Y);
MessagingMethods.PostMessage(child, MessagingMethods.WM_LBUTTONDOWN,
new IntPtr(MessagingMethods.MK_LBUTTON), lParamClickLocation);
MessagingMethods.PostMessage(child, WM.LBUTTONDOWN,
new IntPtr(MK.LBUTTON), lParamClickLocation);
MessagingMethods.PostMessage(child, MessagingMethods.WM_LBUTTONUP,
new IntPtr(MessagingMethods.MK_LBUTTON), lParamClickLocation);
MessagingMethods.PostMessage(child, WM.LBUTTONUP,
new IntPtr(MK.LBUTTON), lParamClickLocation);
#if DEBUG
Console.WriteLine("Left click on window #" + child.ToString() + " at " + clientLocation.ToString());
@ -46,8 +46,8 @@ namespace OnTopReplica {
private static void InjectDoubleLeftMouseClick(IntPtr child, NPoint clientLocation) {
IntPtr lParamClickLocation = MessagingMethods.MakeLParam(clientLocation.X, clientLocation.Y);
MessagingMethods.PostMessage(child, MessagingMethods.WM_LBUTTONDBLCLK,
new IntPtr(MessagingMethods.MK_LBUTTON), lParamClickLocation);
MessagingMethods.PostMessage(child, WM.LBUTTONDBLCLK,
new IntPtr(MK.LBUTTON), lParamClickLocation);
#if DEBUG
Console.WriteLine("Double left click on window #" + child.ToString() + " at " + clientLocation.ToString());

View file

@ -30,7 +30,7 @@ namespace OnTopReplica {
//Fetch icon from window
IntPtr hIcon;
if (MessagingMethods.SendMessageTimeout(_handle, MessagingMethods.WM_GETICON, new IntPtr(2), new IntPtr(0),
if (MessagingMethods.SendMessageTimeout(_handle, WM.GETICON, new IntPtr(2), new IntPtr(0),
MessagingMethods.SendMessageTimeoutFlags.AbortIfHung | MessagingMethods.SendMessageTimeoutFlags.Block, 500, out hIcon) == IntPtr.Zero)
hIcon = IntPtr.Zero;