在c#中,我可以在与执行代码相同的进程中“劫持”窗口的WndProc,使用NativeWindow类,使我能够覆盖某些消息并让其他消息传递。
下面是一个示例:
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case WM_ENABLE:
//do default thing
base.WndProc(ref m);
//then do my thing
break;
case WM_PAINT:
//don't even call base.WndProc, I'll handle painting.
break;
default:
//all other messages...
base.WndProc(ref m);
break;
}
}如何在c++ Win32应用程序中完成相同的任务?我甚至不知道该从哪里开始,也不知道正确的术语是什么。
发布于 2014-04-25 18:37:13
对于任何WindowProc,您都可以在C++中使用HWND回调。
有关详细信息和选项(在WIndows API中有很多种方法可以这样做),请参见使用Windows程序。与C#选项最接近的是窗口的子类。注意,新的、改进的窗口子类机制是使用SetWindowSubclass。
https://stackoverflow.com/questions/23300525
复制相似问题