- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
关于 MSDN网站,我发现以下内容:
Calling SetWindowLongPtr with the GWLP_WNDPROC index creates a subclass of the window class used to create the window. An application can subclass a system class, but should not subclass a window class created by another process. The SetWindowLongPtr function creates the window subclass by changing the window procedure associated with a particular window class, causing the system to call the new window procedure instead of the previous one. An application must pass any messages not processed by the new window procedure to the previous window procedure by calling CallWindowProc. This allows the application to create a chain of window procedures.
这是否意味着,每次我用 GWLP_WNDPROC
调用 SetWindowLongPtr
时,都会创建新的子类,或者 Windows 是否足够聪明,如果相同的过程只创建一次子类作为参数传递多次?
最佳答案
术语“子类”在 winapi 中是概念性的。它最初是在 1983 年设计的,目的是针对 C 语言。当然,它不支持类(class)。
1983 年是软件开发的重要一年,面向对象的编程开始腾飞。那时 Bjarne Stroustrup 将他的“C with Classes”重命名为 C++。当 Xerox 向任何想要拷贝的人发布他们的 Smalltalk-80 实现时。鉴于 Smalltalk 专注于消息传递,它可能对 Windows 设计人员产生了强烈的启发。
因此,虽然 winapi 不能完全面向对象,但它确实吸取了这种技术的味道。 RegisterClass() 函数是最明显的,它就像一个基类,为从该类创建的任何窗口“对象”提供相同的行为。用 WNDCLASS.lpfnWndProc 指定的窗口过程就像一个可以被覆盖的虚拟方法。
因此,使用 RegisterClass() 注册的类的“子类”仅仅覆盖了 lpfnWndProc 函数。你用 SetWindowLongPtr() 来做到这一点,你必须自己带来新的功能。您必须像在 C++ 程序中重写虚函数时通常所做的那样调用“基本”函数。
这不是唯一的方法。 SubWindowSubclass() function是一个帮助函数来让它正确。 DefSubclassProc() function帮助您调用“基类”。推荐。
关于c++ - WinAPI SetWindowLongPtr - 改变 windowProc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37433559/
我是 win32 消息的新手。我想知道当 WindowProc 正在处理一条消息时,是否有可能被中断以处理另一条消息?以下面的例子为例,如果 [A] 和 [B] 都被执行,WindowProc 是否有
是否可以在 WindowProc 回调中捕获错误? try/catch 不起作用。看起来 __try __except 和硬件异常(例如 AV)也不起作用。 更新: 我发现确实可以在 WindowPr
我想问一下,当我在MFC 中编程时,消息映射和覆盖windowproc 之间有什么区别?在哪些情况下我必须覆盖 windowproc? 例如,我什么时候必须使用消息 ON_WM_CHAR,什么时候我必
我遇到了一个奇怪的问题,switch/case 将到达 HandleEvent 但消息不会到达适当的 IF 语句。 例如,使用 HandleEvent 时,当我点击红色 X 时我的窗口不会关闭。消息将
我正在尝试用 Java 编写一个简单的应用程序,它将与 USB 设备进行通信。 USB 设备是我使用 Microchip 微 Controller 制作的。通信相当简单,因为 USB 设备来自 HID
在 a previous question我想实现 WndProc 来处理 WM_DEVICECHANGE 消息,以便了解我的 USB 设备何时连接或分离。 我设法解决了这个问题,但是......在某
我一直在学习 directx 编程教程,它从学习如何对窗口进行编程开始。 到目前为止,我已经有了这个,它创建了一个空白窗口: #if _WIN32_WINNT #include #in
在使用 SetWindowLong() 更改 ListView 控件之前,它的默认 WindowProc 是什么? 最佳答案 这是系统在注册窗口类时决定的。它大概是在 comctl32 中实现的。 在
在关于 WindowProc 的 MSDN Win32-Api 文档(位于 http://msdn.microsoft.com/en-us/library/ms633573%28VS.85%29.as
我如何在 c# 中为 .net compact Framework 3.5 获取表单的 windowproc, 我想知道如何获取特定形式的窗口过程。 默认情况下,我们无法在 c# 3.5 compac
关于 MSDN网站,我发现以下内容: Calling SetWindowLongPtr with the GWLP_WNDPROC index creates a subclass of the wi
我正在使用 WINAPI 开发 GUI,我有一个问题。我用相应的程序制作了一个自定义进度条来处理它的消息。我自己画进度条。对于进度条百分比,我使用一个静态变量,我使用自定义消息更新该变量,然后使用 I
Win32 API 是否提供任何方法来检索 struct MSG WindowProc 的值当前正在处理,从 proc 内部? 附言我不能使用像 static 这样臭名昭著的全局结构,它以后肯定会咬我
如果我在 WindowProc 中使用 try/catch 覆盖 MFC 窗口/ View 类,则会影响性能。为什么会这样,还有什么替代方案? 这是我通过分析发现的。删除 block 使函数消耗更少的
我尝试使用 Visual Studio 2013 为 x64 构建我的 Win32 API 项目。但是路由的 WindowProc 回调无法正常工作。我将 SetWindowLongPtr/GetWi
这个问题在这里已经有了答案: What is an undefined reference/unresolved external symbol error and how do I fix it?
我是一名优秀的程序员,十分优秀!