mirror of
https://github.com/LorenzCK/OnTopReplica.git
synced 2024-05-20 20:33:06 +12:00
Some changes to message pump processors.
Added TitleSetter processor (doesn't work).
This commit is contained in:
parent
1ae9effa6f
commit
82b8ed0319
|
@ -9,7 +9,7 @@ namespace OnTopReplica {
|
|||
|
||||
void Initialize(MainForm form);
|
||||
|
||||
void Process(Message msg);
|
||||
bool Process(ref Message msg);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
44
OnTopReplica/MainForm.Designer.cs
generated
44
OnTopReplica/MainForm.Designer.cs
generated
|
@ -31,7 +31,6 @@
|
|||
this.menuContextWindows = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuWindows = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.noneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fullSelectWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.switchToWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.selectRegionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.advancedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -44,7 +43,6 @@
|
|||
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();
|
||||
|
@ -69,6 +67,8 @@
|
|||
this.italianoToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
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();
|
||||
|
@ -115,7 +115,7 @@
|
|||
this.menuWindows.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.noneToolStripMenuItem});
|
||||
this.menuWindows.Name = "menuWindows";
|
||||
this.menuWindows.OwnerItem = this.menuContextWindows;
|
||||
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);
|
||||
//
|
||||
|
@ -125,15 +125,6 @@
|
|||
this.noneToolStripMenuItem.Size = new System.Drawing.Size(117, 22);
|
||||
this.noneToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuWindowsNone;
|
||||
//
|
||||
// fullSelectWindowToolStripMenuItem
|
||||
//
|
||||
this.fullSelectWindowToolStripMenuItem.DropDown = this.menuWindows;
|
||||
this.fullSelectWindowToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.list;
|
||||
this.fullSelectWindowToolStripMenuItem.Name = "fullSelectWindowToolStripMenuItem";
|
||||
this.fullSelectWindowToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.fullSelectWindowToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuWindows;
|
||||
this.fullSelectWindowToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuWindowsTT;
|
||||
//
|
||||
// switchToWindowToolStripMenuItem
|
||||
//
|
||||
this.switchToWindowToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.window_switch;
|
||||
|
@ -204,7 +195,7 @@
|
|||
this.toolStripMenuItem3,
|
||||
this.toolStripMenuItem4});
|
||||
this.menuOpacity.Name = "menuOpacity";
|
||||
this.menuOpacity.OwnerItem = this.menuContextOpacity;
|
||||
this.menuOpacity.OwnerItem = this.fullOpacityToolStripMenuItem;
|
||||
this.menuOpacity.ShowCheckMargin = true;
|
||||
this.menuOpacity.ShowImageMargin = false;
|
||||
this.menuOpacity.Size = new System.Drawing.Size(154, 92);
|
||||
|
@ -248,14 +239,6 @@
|
|||
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.Image = global::OnTopReplica.Properties.Resources.window_opacity;
|
||||
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;
|
||||
|
@ -456,6 +439,23 @@
|
|||
this.menuContextClose.Text = global::OnTopReplica.Strings.MenuClose;
|
||||
this.menuContextClose.Click += new System.EventHandler(this.Menu_Close_click);
|
||||
//
|
||||
// fullSelectWindowToolStripMenuItem
|
||||
//
|
||||
this.fullSelectWindowToolStripMenuItem.DropDown = this.menuWindows;
|
||||
this.fullSelectWindowToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.list;
|
||||
this.fullSelectWindowToolStripMenuItem.Name = "fullSelectWindowToolStripMenuItem";
|
||||
this.fullSelectWindowToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.fullSelectWindowToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuWindows;
|
||||
this.fullSelectWindowToolStripMenuItem.ToolTipText = global::OnTopReplica.Strings.MenuWindowsTT;
|
||||
//
|
||||
// fullOpacityToolStripMenuItem
|
||||
//
|
||||
this.fullOpacityToolStripMenuItem.DropDown = this.menuOpacity;
|
||||
this.fullOpacityToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.window_opacity;
|
||||
this.fullOpacityToolStripMenuItem.Name = "fullOpacityToolStripMenuItem";
|
||||
this.fullOpacityToolStripMenuItem.Size = new System.Drawing.Size(186, 22);
|
||||
this.fullOpacityToolStripMenuItem.Text = global::OnTopReplica.Strings.MenuOpacity;
|
||||
//
|
||||
// danskToolStripMenuItem
|
||||
//
|
||||
this.danskToolStripMenuItem.Image = global::OnTopReplica.Properties.Resources.flag_danish;
|
||||
|
@ -501,7 +501,7 @@
|
|||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.MaximizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(20, 20);
|
||||
this.MinimumSize = new System.Drawing.Size(20, 34);
|
||||
this.Name = "MainForm";
|
||||
this.TopMost = true;
|
||||
this.menuContext.ResumeLayout(false);
|
||||
|
|
|
@ -144,7 +144,8 @@ namespace OnTopReplica {
|
|||
}
|
||||
|
||||
protected override void WndProc(ref Message m) {
|
||||
_msgPumpManager.PumpMessage(m);
|
||||
if (_msgPumpManager.PumpMessage(ref m))
|
||||
return;
|
||||
|
||||
switch (m.Msg) {
|
||||
case WM.NCRBUTTONUP:
|
||||
|
@ -181,6 +182,8 @@ namespace OnTopReplica {
|
|||
|
||||
#endregion
|
||||
|
||||
const string Title = "OnTopReplica";
|
||||
|
||||
#region Keyboard event handling
|
||||
|
||||
void Form_KeyUp(object sender, KeyEventArgs e) {
|
||||
|
|
|
@ -42,10 +42,14 @@ namespace OnTopReplica {
|
|||
/// Run the registered message pump processors.
|
||||
/// </summary>
|
||||
/// <param name="msg">Message to process.</param>
|
||||
public void PumpMessage(Message msg) {
|
||||
/// <returns>True if the message has been handled internally.</returns>
|
||||
public bool PumpMessage(ref Message msg) {
|
||||
foreach (var processor in _processors.Values) {
|
||||
processor.Process(msg);
|
||||
if (processor.Process(ref msg))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace OnTopReplica.MessagePumpProcessors {
|
|||
Form = form;
|
||||
}
|
||||
|
||||
public abstract void Process(Message msg);
|
||||
public abstract bool Process(ref Message msg);
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ namespace OnTopReplica.MessagePumpProcessors {
|
|||
/// <summary>
|
||||
/// Processes the message pump.
|
||||
/// </summary>
|
||||
public override void Process(Message msg) {
|
||||
public override bool Process(ref Message msg) {
|
||||
if (_active && msg.Msg == HookMethods.WM_SHELLHOOKMESSAGE) {
|
||||
int hookCode = msg.WParam.ToInt32();
|
||||
if (hookCode == HookMethods.HSHELL_WINDOWACTIVATED ||
|
||||
|
@ -67,6 +67,8 @@ namespace OnTopReplica.MessagePumpProcessors {
|
|||
HandleForegroundWindowChange(activeHandle);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void HandleForegroundWindowChange(IntPtr activeWindow) {
|
||||
|
|
|
@ -26,14 +26,16 @@ namespace OnTopReplica.MessagePumpProcessors {
|
|||
_handlers[newKey] = handler;
|
||||
}
|
||||
|
||||
public override void Process(Message msg) {
|
||||
public override bool Process(ref Message msg) {
|
||||
if (msg.Msg == HotKeyMethods.WM_HOTKEY) {
|
||||
int keyId = msg.WParam.ToInt32();
|
||||
if (!_handlers.ContainsKey(keyId))
|
||||
return;
|
||||
return false;
|
||||
|
||||
_handlers[keyId].Invoke();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void Shutdown() {
|
||||
|
|
41
OnTopReplica/MessagePumpProcessors/TitleSetter.cs
Normal file
41
OnTopReplica/MessagePumpProcessors/TitleSetter.cs
Normal file
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using OnTopReplica.Native;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OnTopReplica.MessagePumpProcessors {
|
||||
class TitleSetter : BaseMessagePumpProcessor {
|
||||
|
||||
const string Title = "OnTopReplica";
|
||||
|
||||
public override bool Process(ref Message msg) {
|
||||
switch (msg.Msg) {
|
||||
case WM.GETTEXT: {
|
||||
Console.WriteLine("GetText");
|
||||
int maxLen = msg.WParam.ToInt32();
|
||||
byte[] strBytes = Encoding.UTF8.GetBytes(Title);
|
||||
byte[] termBytes = new byte[strBytes.Length + 1];
|
||||
strBytes.CopyTo(termBytes, 0);
|
||||
termBytes[strBytes.Length] = 0;
|
||||
|
||||
Marshal.Copy(termBytes, 0, msg.LParam, Math.Min(maxLen, Title.Length + 1));
|
||||
}
|
||||
goto case WM.GETTEXTLENGTH;
|
||||
|
||||
case WM.GETTEXTLENGTH:
|
||||
Console.WriteLine("GetTextLength");
|
||||
msg.Result = (IntPtr)Title.Length;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void Shutdown() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@ namespace OnTopReplica.MessagePumpProcessors {
|
|||
/// </summary>
|
||||
class WindowKeeper : BaseMessagePumpProcessor {
|
||||
|
||||
public override void Process(Message msg) {
|
||||
public override bool Process(ref Message msg) {
|
||||
if (Form.CurrentThumbnailWindowHandle != null &&
|
||||
msg.Msg == HookMethods.WM_SHELLHOOKMESSAGE) {
|
||||
int hookCode = msg.WParam.ToInt32();
|
||||
|
@ -27,6 +27,8 @@ namespace OnTopReplica.MessagePumpProcessors {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void Shutdown() {
|
||||
|
|
|
@ -22,5 +22,7 @@ namespace OnTopReplica.Native {
|
|||
public const int NCLBUTTONDBLCLK = 0x00A3;
|
||||
public const int NCRBUTTONUP = 0x00A5;
|
||||
public const int SYSCOMMAND = 0x0112;
|
||||
public const int GETTEXT = 0x000D;
|
||||
public const int GETTEXTLENGTH = 0x000E;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@
|
|||
<Compile Include="MessagePumpProcessors\GroupSwitchManager.cs" />
|
||||
<Compile Include="IMessagePumpProcessor.cs" />
|
||||
<Compile Include="MessagePumpProcessors\BaseMessagePumpProcessor.cs" />
|
||||
<None Include="MessagePumpProcessors\TitleSetter.cs" />
|
||||
<Compile Include="MessagePumpProcessors\WindowKeeper.cs" />
|
||||
<Compile Include="Native\ErrorMethods.cs" />
|
||||
<Compile Include="Native\HookMethods.cs" />
|
||||
|
|
Loading…
Reference in a new issue