Subclassing and Hooking with Visual Basic

Stephen Teilhet

  • 出版商: O'Reilly
  • 出版日期: 2001-07-24
  • 售價: $1,980
  • 貴賓價: 9.5$1,881
  • 語言: 英文
  • 頁數: 704
  • 裝訂: Paperback
  • ISBN: 0596001185
  • ISBN-13: 9780596001186
  • 相關分類: Visual Basic
  • 海外代購書籍(需單獨結帳)

買這商品的人也買了...

商品描述

Subclassing & Hooking with Visual Basic offers developers a unique way to customize Windows behavior.

Windows is a message-based system. Every action you request creates one or more messages to carry out the action. These messages are passed between objects and carry with them information that gives the recipient more detail on how to interpret and act upon the message.

With Subclassing and the Windows hooking mechanism ("hooks"), you can manipulate, modify, or even discard messages bound for other objects within the operating system, in the process changing the way the system behaves. What kinds of results can you achieve using the power of subclassing and hooking? Here are just a few of the possibilities:

  • Determine when a window is being activated or deactivated and respond to this change.

  • Display descriptions of menu items as the mouse moves across them.

  • Disallow a user to move or resize a window.

  • Determine where the mouse cursor is and respond accordingly.

  • Determine when the display resolution has been changed.

  • Monitor the system for a low system resource condition.

  • Modify or disallow keystrokes sent to a window or a control.

  • Create an automated testing application.

  • Determine when an application is idle.


Along with this power comes responsibility; Windows is very unforgiving if subclassing and hooking are used incorrectly. Subclassing & Hooking with Visual Basic demonstrates the various techniques for intercepting messages bound for one or more windows or controls: the intercepted message can be left in its original state or modified; afterwards, the message can be sent to its original destination or discarded.

For both VB 6 and VB.NET developers, Subclassing & Hooking with Visual Basic opens up a wealth of possibilities that ordinarily would be completely unavailable, or at least not easy to implement.

商品描述(中文翻譯)

《Subclassing & Hooking with Visual Basic》提供開發人員一種獨特的方式來自定義Windows的行為。

Windows是一個基於消息的系統。您所請求的每個操作都會產生一個或多個消息來執行該操作。這些消息在對象之間傳遞,並攜帶著信息,以便接收者更詳細地解釋和執行該消息。

通過子類化和Windows掛鉤機制('hooks'),您可以操作、修改甚至丟棄發送給操作系統中其他對象的消息,從而改變系統的行為。使用子類化和掛鉤的強大功能,您可以實現哪些結果呢?以下只是其中幾個可能性:

- 確定窗口何時被激活或取消激活並對此進行響應。
- 在鼠標移動到菜單項目上時顯示描述。
- 禁止用戶移動或調整窗口大小。
- 確定鼠標光標的位置並相應響應。
- 確定顯示分辨率是否已更改。
- 監視系統是否存在低系統資源情況。
- 修改或禁止發送給窗口或控件的按鍵輸入。
- 創建自動化測試應用程序。
- 確定應用程序何時處於空閒狀態。

然而,這種強大的功能也帶來了責任;如果子類化和掛鉤使用不當,Windows會非常不寬容。《Subclassing & Hooking with Visual Basic》演示了拦截發送給一個或多個窗口或控件的消息的各種技術:拦截的消息可以保持原樣或進行修改;之後,可以將消息發送到其原始目的地或丟棄。

對於VB 6和VB.NET開發人員來說,《Subclassing & Hooking with Visual Basic》打開了一扇寶藏之門,通常情況下是完全無法使用的,或者至少不容易實現。