在c#
中,我可以使用 NativeWindow
类在与执行代码相同的进程内“劫持”窗口的WndProc
,使我能够覆盖某些消息并让其他消息通过。
这是一个例子:
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
应用程序中完成同样的事情?我什至不知道从哪里开始或者正确的术语是什么。
最佳答案
您可以使用 WindowProc任何 HWND
的 C++ 回调。
有关完整的详细信息和选项(在 WIndows API 中有很多方法可以做到这一点),请参阅 Using Windows Procedures 。最接近 C# 选项的是 Subclass a Window 。请注意,子类化 Window 的新改进机制是使用 SetWindowSubclass .
关于c# - NativeWindow 等效项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23300525/