程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> JSP編程 >> 關於JSP >> 一份很有價值的子類化的源代碼!

一份很有價值的子類化的源代碼!

編輯:關於JSP

' 新建一個 ActiveX DLL 工程,名稱 SmartSubClassLib
' 以下代碼放在標准模塊裡,模塊名 mSmartSubClass
' ----------------------------------------------------
' Module mSmartSubClass
'
' Version... 1.0
' Date...... 24 April 2001
'
' Copyright (C) 2001 Andr轶 Pons ([email protected])
' ----------------------------------------------------
'API declarations:
Option Explicit
Public Const SSC_OLDPROC = "SSC_OLDPROC"
Public Const SSC_OBJADDR = "SSC_OBJADDR"
Private Declare Function GetProp Lib "user32" Alias "GetPropA" ( _
ByVal hWnd As Long, _
ByVal lpString As String) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
Destination As Any, _
Source As Any, _
ByVal Length As Long)
'
' Function StartSubclassWindowProc()
'
' This is the first windowproc that receives messages
' for all subclassed windows.
' The aim of this function is to just collect the message
' and deliver it to the right SmartSubClass instance.
'
Public Function SmartSubClassWindowProc( _
ByVal hWnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Dim lRet As Long
Dim oSmartSubClass As SmartSubClass
'Get the memory address of the class instance...
lRet = GetProp(hWnd, SSC_OBJADDR)

If lRet <> 0 Then
'oSmartSubClass will point to the class instance
'without incrementing the class reference counter...
CopyMemory oSmartSubClass, lRet, 4
'Send the message to the class instance...
SmartSubClassWindowProc = oSmartSubClass.WindowProc(hWnd, _
uMsg, wParam, lParam)

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved