Subclassing and Hooking with Visual Basic
暫譯: 使用 Visual Basic 的子類別化與掛鉤技術

Stephen Teilhet

  • 出版商: O'Reilly
  • 出版日期: 2001-07-24
  • 售價: $2,050
  • 貴賓價: 9.5$1,948
  • 語言: 英文
  • 頁數: 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.

商品描述(中文翻譯)

《使用 Visual Basic 的子類別化與掛鉤》為開發者提供了一種獨特的方式來自訂 Windows 的行為。

Windows 是一個基於訊息的系統。您所請求的每一個動作都會產生一個或多個訊息來執行該動作。這些訊息在物件之間傳遞,並攜帶著信息,讓接收者能夠更詳細地解釋和執行該訊息。

透過子類別化和 Windows 的掛鉤機制('hooks'),您可以操控、修改,甚至丟棄發送給作業系統中其他物件的訊息,從而改變系統的行為。使用子類別化和掛鉤的力量,您可以達成什麼樣的結果呢?以下是一些可能性:

- 確定何時一個視窗被啟用或停用,並對此變化作出回應。
- 當滑鼠移動到選單項目上時,顯示該項目的描述。
- 不允許使用者移動或調整視窗大小。
- 確定滑鼠游標的位置並相應地作出回應。
- 確定何時顯示解析度已被更改。
- 監控系統以檢查系統資源不足的情況。
- 修改或禁止發送到視窗或控制項的按鍵輸入。
- 創建自動化測試應用程式。
- 確定何時應用程式處於閒置狀態。

隨著這種力量而來的是責任;如果不正確使用子類別化和掛鉤,Windows 將非常不寬容。《使用 Visual Basic 的子類別化與掛鉤》展示了攔截發送給一個或多個視窗或控制項的訊息的各種技術:被攔截的訊息可以保持原狀或被修改;之後,該訊息可以發送到其原始目的地或被丟棄。

對於 VB 6 和 VB.NET 開發者來說,《使用 Visual Basic 的子類別化與掛鉤》開啟了一個豐富的可能性,這些可能性通常是完全無法獲得的,或者至少不容易實現。