Window-handleを持たんけどWndProcを処理したい、てこと?
eventで横流しし、ついでに呼んでみましょうか:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Listener ls = new Listener(listBox1.Items);
' WndProcが呼ばれたら Listener.WndProc もついでに呼んでね♪
WinMsgReceived += ls.WndProc;
}
public delegate void WinMsgHandler(ref Message m);
public event WinMsgHandler WinMsgReceived;
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
' ついでに呼ぶ
if (WinMsgReceived != null) WinMsgReceived(ref m);
}
}
public class Listener
{
private System.Collections.IList lst;
public Listener(System.Collections.IList l) { lst = l; }
' ついでに呼ばれる
public void WndProc(ref Message m)
{
lst.Add(m.ToString());
}
}