1)在COM中注册一个消息
RegisterWindowMessage("MSG_NEWDATASOURCE")
2)在C#中也注册同一个消息
[DllImport("user32.dll")]
static extern uint RegisterWindowMessage(string lpString);
uint msgNewDataSource = RegisterWindowMessage("MSG_NEWDATASOURCE");
3)重载消息处理函数
protected override void WndProc(ref Message m)
{
if (m.Msg == (msgNewDataSource))
{
MessageBox.Show("MSG_NEWDATASOURCE Message from COM");
}
else
{
base.WndProc(ref m);
}
}
RegisterWindowMessage("MSG_NEWDATASOURCE")
2)在C#中也注册同一个消息
[DllImport("user32.dll")]
static extern uint RegisterWindowMessage(string lpString);
uint msgNewDataSource = RegisterWindowMessage("MSG_NEWDATASOURCE");
3)重载消息处理函数
protected override void WndProc(ref Message m)
{
if (m.Msg == (msgNewDataSource))
{
MessageBox.Show("MSG_NEWDATASOURCE Message from COM");
}
else
{
base.WndProc(ref m);
}
}