C#是否具有相当于Delphi的消息关键字?
发布时间:2020-12-15 17:44:00 所属栏目:百科 来源:网络整理
导读:在delphi中,我可以创建我自己的消息, const MY_MESSAGE = WM_USER+100;procedure MyMessage(var Msg: TMessage); message MY_MESSAGE;procedure TForm1.MyMessage(var Msg: TMessage);begin....end; 在c#中我可以这样做 public static uint ms;protected ove
在delphi中,我可以创建我自己的消息,
const MY_MESSAGE = WM_USER+100; procedure MyMessage(var Msg: TMessage); message MY_MESSAGE; procedure TForm1.MyMessage(var Msg: TMessage); begin .... end; 在c#中我可以这样做 public static uint ms; protected override void WndProc(ref Message m) { if(m.Msg == ms) MessageBox.Show("example"); else base.WndProc(ref m); } void Button1Click(object sender,EventArgs e) { PostMessage(HWND_BROADCAST,ms,IntPtr.Zero,IntPtr.Zero); } 但我不想覆盖WndProc(),我想创建我自己的MyMessage()函数,当我发布消息它将运行. 我怎样才能做到这一点? 解决方法
这是Delphi的一个特殊功能,在C#中没有模拟.在C#中,需要覆盖WndProc().
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |