Restored from previous forum. Originally posted by Art Sentinel.
Hi El_Choni, I think you would be interested to know that I have tested your right mouse hook code with the WebGadget. In fact, I tested it with several different ActiveX components. So far it seems to work exactly as I was hoping!
I made a tiny change. I set the WM_RBUTTONUP windows constant to WM_RBUTTONDOWN. I think you will see why that is so when you test the following code with the other constant in place.

I made a tiny improvement to your code?? Woo-hoo! Miracles never cease.. Hahaha...
I have been a professional multimedia developer and graphic artist for years, but with PureBasic, I am still at the 'fishing monkey' stage. Would you please explain a couple things to me?
Why is this line important, and what precisely does it do?
*ms.MOUSEHOOKSTRUCT = lParam
Besides, to set the text gadgets:
SetGadgetText(0, "x: "+Str(*ms\pt\x))
SetGadgetText(1, "y: "+Str(*ms\pt\y))
.
Also, I understand this command:
hhook = SetWindowsHookEx_(#WH_MOUSE, @MouseProc(), hInstance, lpdwProcessId)
But I am not clear as to why you added a '@' for the address part. And what exactly
GetModuleHandle_(0) does.
.
.

All I can say is that I know no one who understands PureBasic. It is great having this forum to connect to generous people who enjoy helping others (and learning new things along the way). Thank you.
Here is my code (It takes you to my website for testing since my site is loaded with ActiveX components):
.
.
Code: Select all
;Browser Gadget With Right-Click Disabler Test
;Art Sentinel, July 29, 2002
;HUGE thanks to El_Choni!
;Using PureBasic 3.20 (current)
;Initialize Environments
;empty for now..
;Set Variables and Constants
Global hhook.l
Global myRightClick.s
#WinW=760
#WinH=500
WinX.w=(GetSystemMetrics_(#SM_CXSCREEN)-#WinW)/2 ; Window centered horizontally.
WinY.w=(GetSystemMetrics_(#SM_CYSCREEN)-#WinH)/2 ; Window centered vertically.
;Declare Procedures
Procedure MouseProc(nCode, wParam, lParam)
If wParam = #WM_RBUTTONDOWN ;Most ActiveX components are set to process the right-mousedown event.
;If you use #WM_RBUTTONUP, you will see a brief flash of the component's
;r-click menu before PureBasic processes the hooked. By using #WM_RBUTTONDOWN
;you do not allow the web page components to access the click event at all.
result.b = 1
myRightClick = "Disabled"
Else
result.b = 0
EndIf
ProcedureReturn result
EndProcedure
;Open Window and center it on screen
hInstance = GetModuleHandle_(0)
If OpenWindow(0, WinX, WinY, 760, 500, #PB_Window_SystemMenu, "Browser Test")
WindowID = WindowID()
;Open Browser Gadget
If CreateGadgetList(WindowID())
WebGadget(0, 1, 1, 758, 498, "[url]http://www.artsentinel.net[/url]")
EndIf
lpdwProcessId = GetWindowThreadProcessId_(WindowID, 0)
hhook = SetWindowsHookEx_(#WH_MOUSE, @MouseProc(), hInstance, lpdwProcessId)
EndIf
;Main loop
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_EventCloseWindow
;Finish up
UnhookWindowsHookEx_(hhook)
End
--------------
Top Ten Reasons Not To Procrastinate:
Coming Soon...
Edited by - Art Sentinel on 29 July 2002 23:08:51