Subclassing is a technique that allows an application to intercept and process messages sent or posted to a particular window before the window has a chance to process them. This is typically done by replacing the Window Procedure for a window with application-defined window procedure.
子类化是一种允许应用程序在窗口处理发送或投递到它的消息之前进行拦截和处理的技术。这通常通过用自定义的窗口过程替换原来的窗口过程来实现。
这是Windows Message Handling - Part 4上的一段话,看过之后感觉这个功能挺不错。遂记之如下:
文中介绍了子类化的两种情况
SDK方式:
1、创建新的窗口处理函数NewWNDPROC 在新的窗口处理函数中做出特别的处理,之后把其余的交给旧窗口函数处理。使用CallWindowProc函数。
2、用新的窗口函数代替旧的窗口函数,并保存旧的,如使用SetWindowLong函数。
MFC方式: mfc方式需要创建目标父类的子类,并在其中改写感兴趣的消息函数。
一种方式是使用自定义子类直接关联父类控件
另外一种方式是生成子类对象实例,并调用对应的CWnd::SubclassWindow或CWnd::SubclassDlgItem函数。
除此之外,作者还提到了消息反射的问题,可惜作者没有详细解释。
分享到:
相关推荐
自定义-Android-ListView-Rows-by-Subclassing 使用 RelativeLayout 的子类来替换持有者模式
Subclassing and Hooking is a standard technique in Windows programming for customizing the behavior of a window. However, to wrap subclassing and hooking into virtual function overriding it is an ...
Demo中有一个KYRefreshControl的子类,仅重写了init方法,便做出来了一个像笔写字一样的下拉刷新效果。 A bare bone implementation of a pull to refresh. You can easily create your own style pull to refresh...
Subclassing the List View Control using MFC用MFC写的列表视图子类(3KB)
《Windows 95 程式设计指南》(Windows 95 : A Developer's Guide) 李書良译 侯捷总监 (原作者: Jeffrey Richter & Jonathan Locke) 第一章 从生到死 一个完整的Win32 程式 /001 第二章 详细剖析对话盒 /091 第三...
Windows Subclassing Subclassing MFC Objects About Object-Oriented Design Can You See My House from Here? Summary Chapter 8: Using the Windows Common Controls Overview Common Control Basics ...
A freeware MFC class to support MFC subclassing(19KB)
Subclassing QDialog Signals and Slots in Depth Rapid Dialog Design Shape-Changing Dialogs Dynamic Dialogs Built-in Widget and Dialog Classes Chapter 3. Creating Main Windows Subclassing...
This demonstrates hoe to write a subclassing control. And it has many examples as to how to use the control (included.)
Summerfield systematically introduces every core GUI development technique: from dialogs and windows to data handling; from events to printing; and more. Through the book's realistic examples you'll ...
ActiveX control licensing * Converting a VBX and subclassing Windows controls * 16-bit-to-32-bit and cross-platform issues * Microsoft guidelines for ActiveX Controls and control containers * Visual ...
· SpyWorks hook控件和子类控件(subclassing)的更新版本,支持Visual Studio .NET的最终版,包含相关的.NET Primary InterOp程序集。 · 支持从Visual Studio .NET程序集导出函数。 · 该更新版包含大量的样例 ...
二,使用VB6开发的一些项目,需要使用VB6开发环境本身不具备的 windows控件,特别是有些情况下需要支持unicode的控件,或需要子类化窗口做一些处理时. 三, 实际开发中,不能单只使用VB或VC一种开发工具的开发者,需要有一...
12. An Introduction to Swift Subclassing and Extensions 13. Working with Array and Dictionary Collections in Swift 14. Understanding Error Handling in Swift 3 15. The iOS 10-Application and ...
Master OOP concepts such as classes, objects, subclassing, and inheritance Connect to databases Who This Book Is For Programmers new to Ruby, and web developers interested in knowing the foundations ...
Core PyQt GUI programming techniques: dialogs, main windows, and custom file formats Using Qt Designer to design user interfaces, and to implement and test dialogs, events, the Clipboard, and drag-...
Understanding iOS 9 Views, Windows and the View Hierarchy Chapter 18. An Introduction to Auto Layout in iOS 9 Chapter 19. Working with iOS 9 Auto Layout Constraints in Interface Builder Chapter 20. ...
内容索引:VC/C++源码,系统相关,软键盘 基于Windows API实现的屏幕软键盘,一个比较有用的小程序,也是很好的编程参考资料,帮你更进一步了理解Windows API的使用方法。程序里面有Button的Subclassing两个东西,同时...
深入浅出ES6, epub格式 深入浅出 ES6(一):ES6 是什么 深入浅出 ES6(二):迭代器和 for-of 循环...深入浅出 ES6(十五):子类 Subclassing 深入浅出 ES6(十六):模块 Modules 深入浅出 ES6(十七):展望未来