详细的能帖就帖了,机器不能上网,写大概的吧------------usercontrol------------------ Dim Event MessageArrive()........................'有若干的过程和属性 ---------------------------------------- ----------模块-------------------------- Public Sub WinProc(hwnd as Long , uMsg as long ,lParam as long ,wParam as long )'子类化的窗体程序.对uMsg处理.必须在模块中. '有窗体消息传入时.RaiseEvent MessageArrive 但是VB提示无效.......End Sub 大概就是这样吧.
思想就是..在类里,就是usercontrol模块里-----类命名MsgSwitch prevWindowProc=SetWindowLong ......WndProc (位于模块) 再有个WindowProc(在类里)必须申明为Friend Friend Function WindowProc (..........) As Long RaiseEvent ......... CallWindowProc prevWindowProc,.......................... End Function
模块里的 WndProc函数 是这样 Public Function WndProc(.............) As Long WndProc=GetObject(.......自己写的函数,不是API).WindowProc(.........) CallWindowProc prevWindowProc,.......................... End Function GetObject 申明为 Private Function GetObject(hWnd as Long) As MsgSwitch 函数关键的代码 Dim Obj As XWatcher Dim pObj As Long pObj = GetWindowLong(hWnd, GWL_USERDATA) CopyMemory Obj, pObj, 4 Set GetObject = Obj CopyMemory Obj, 0&, 4 End Function
访问的时候什么格式????
行不行?
Dim something As Object
Set something= New Usercontrol1
something.property
呢
另一个就是想在模块里的过程触发usercontrol的一个定义好的事件,该怎样??使用raiseevent 也不行。哪位仁兄想想办法啊。继续加分。。
usercontrol如果是一个工程的一部分,那么模块从属于usercontrol根本是错的,模块是从属于工程的,
Dim Event MessageArrive()........................'有若干的过程和属性
----------------------------------------
----------模块--------------------------
Public Sub WinProc(hwnd as Long , uMsg as long ,lParam as long ,wParam as long )'子类化的窗体程序.对uMsg处理.必须在模块中.
'有窗体消息传入时.RaiseEvent MessageArrive 但是VB提示无效.......End Sub
大概就是这样吧.
prevWindowProc=SetWindowLong ......WndProc (位于模块)
再有个WindowProc(在类里)必须申明为Friend
Friend Function WindowProc (..........) As Long
RaiseEvent .........
CallWindowProc prevWindowProc,..........................
End Function
模块里的 WndProc函数 是这样
Public Function WndProc(.............) As Long
WndProc=GetObject(.......自己写的函数,不是API).WindowProc(.........)
CallWindowProc prevWindowProc,..........................
End Function
GetObject 申明为 Private Function GetObject(hWnd as Long) As MsgSwitch
函数关键的代码
Dim Obj As XWatcher
Dim pObj As Long
pObj = GetWindowLong(hWnd, GWL_USERDATA)
CopyMemory Obj, pObj, 4
Set GetObject = Obj
CopyMemory Obj, 0&, 4
End Function