היי, מצאתי HOOK מעולה שעובד על שדות טקסט!
אבל אני לא מצליח לממש אותו על נגן הפלאש, הינה הקוד של הפורם:Option Explicit Private Sub Form_Load() flashplayer1.Movie = App.Path & "\" & "GameMenu1.swf" Command1.Caption = "Hook flashplayer1" Command2.Caption = "Unhook" End Sub Private Sub Command1_Click()
Call Hook(flashplayer1.hwnd) End Sub Private Sub Command2_Click()
Call UnHook(flashplayer1.hwnd) End Sub Private Sub Form_Unload(Cancel As Integer)
'just in case, assure the 'textbox is unhooked before exiting Call UnHook(flashplayer1.hwnd) End Sub Private Sub Text1_MouseUp(Button As Integer, _ Shift As Integer, _ X As Single, Y As Single) 'this executes only when the window is unhooked 'and shows the default behaviour - first the 'generic textbox menu is shown, then on closing 'the custom textbox popup appears If defWndProc = 0 Then If Button = vbRightButton Then PopupMenu mnuPopup End If End If End Sub
|
והינה הקוד של המודול עצמו:
Option Explicit '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copyright ©1996-2006 VBnet, Randy Birch, All Rights Reserved. ' Some pages may also contain other copyrights by the author. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Distribution: You can freely use this code in your own ' applications, but you may not reproduce ' or publish this code on any web site, ' online service, or distribute as source ' on any media without express permission. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Declare Function CallWindowProc Lib "user32" _ Alias "CallWindowProcA" _ (ByVal lpPrevWndFunc As Long, _ ByVal hwnd As Long, _ ByVal Msg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long Private Declare Function SetWindowLong Lib "user32" _ Alias "SetWindowLongA" _ (ByVal hwnd As Long, _ ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Const GWL_WNDPROC As Long = (-4) Private Const WM_CONTEXTMENU As Long = &H7B Public defWndProc As Long Public Sub Hook(hwnd As Long)
If defWndProc = 0 Then defWndProc = SetWindowLong(hwnd, _ GWL_WNDPROC, _ AddressOf WindowProc) End If End Sub Public Sub UnHook(hwnd As Long)
If defWndProc > 0 Then Call SetWindowLong(hwnd, GWL_WNDPROC, defWndProc) defWndProc = 0 End If End Sub Public Function WindowProc(ByVal hwnd As Long, _ ByVal uMsg As Long, _ ByVal wParam As Long, _ ByVal lParam As Long) As Long
Select Case uMsg Case WM_CONTEXTMENU 'this executes when the window is hooked Form1.PopupMenu Form1.mnuPopup WindowProc = 1 Case Else WindowProc = CallWindowProc(defWndProc, _ hwnd, _ uMsg, _ wParam, _ lParam) End Select End Function
|
מישהו יודע מדוע זה לא עובד?
תודה.
“I love my haters, they rage and rage and all they do is spreading my word”
― J.Y