关于消息函数替换的一个问题
funxu 2012-02-01 10:43:29 delphi里很简单的两句代码,目的就是替换窗体默认的消息处理函数,转成C#后出现了错误,请问各位知道如何修改么?
WndProcDelegate newWndProc = new WndProcDelegate(NewWndProc);
SetWindowLong(this.Handle, GWL_WNDPROC, Marshal.GetFunctionPointerForDelegate(newWndProc));
//错误是经常出现以下提示,从提示看来知道了错误原因是垃圾回收器搞得鬼有谁知道如何修改么?
A callback was made on a garbage collected delegate of type 'WindowsFormsApplication2!WindowsFormsApplication2.Form1+WndProcDelegate::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is