🔒 Locked
Blocking Window Messages
Advertisement
Original Post
Is the window one from your own application? In that case... simply ignore those messages.
If you want to intercept messages sent to another application you could try using the PeekMessage-function to get them:
Use this to intercept the messages sent to the window (you need the handle, set wRemoveMsg ''PM_REMOVE''). Repost the messages that should get through and ''drop'' the ones you want to remove.
I guess it won''t work most of the time though.
The application itself will be reading its own messages with PeekMessage (probably). Depending on the scheduler either your programm or the target-application will be executed first, so your programm may or may not get to see the message before the application does.
What are you trying to do this for btw.? Preventing users to right clicking and/or using the context menu sounds like some vb "security" script to stop users from downloading images from a webpage (which is not worth the effort...).
If you want to intercept messages sent to another application you could try using the PeekMessage-function to get them:
BOOL PeekMessage(
LPMSG lpMsg,
HWND hWnd,
UINT wMsgFilterMin,
UINT wMsgFilterMax,
UINT wRemoveMsg
);
Use this to intercept the messages sent to the window (you need the handle, set wRemoveMsg ''PM_REMOVE''). Repost the messages that should get through and ''drop'' the ones you want to remove.
I guess it won''t work most of the time though.
The application itself will be reading its own messages with PeekMessage (probably). Depending on the scheduler either your programm or the target-application will be executed first, so your programm may or may not get to see the message before the application does.
What are you trying to do this for btw.? Preventing users to right clicking and/or using the context menu sounds like some vb "security" script to stop users from downloading images from a webpage (which is not worth the effort...).
The reason I want to do this, is because I am making a Mouse Gestures application that allows mouse gestures to be used in every program.
I have installed a system-wide mouse hook, and that works fine. The problem is, is if for example I do the gesture for minimize, the window minimizes, and then shows its context menu. Windows then flashes the window thinking its been updated in the background.
Ofcourse, I dont want this to happen, so im trying to prevent the context menu from showing up.
My current attempted at the solution (which isnt working), is that I override the WndProc of the window using SetWindowLong(hWnd, GWL_WNDPROC, MyNewWindowProcedureHere); and then I ignore WM_CONTEXTMENU, and WM_RBUTTONUP. However it isnt working.
Anymore ideas?
I have installed a system-wide mouse hook, and that works fine. The problem is, is if for example I do the gesture for minimize, the window minimizes, and then shows its context menu. Windows then flashes the window thinking its been updated in the background.
Ofcourse, I dont want this to happen, so im trying to prevent the context menu from showing up.
My current attempted at the solution (which isnt working), is that I override the WndProc of the window using SetWindowLong(hWnd, GWL_WNDPROC, MyNewWindowProcedureHere); and then I ignore WM_CONTEXTMENU, and WM_RBUTTONUP. However it isnt working.
Anymore ideas?
I''m fairly certain that windows security features will prevent you from doing this sort of thing, because it reeks of attempting to hack into the application for malicious use (from windows'' point of view).
The real issue is that you may be preventing some necessary functionality of the target app. That could cause a big problem.
The real issue is that you may be preventing some necessary functionality of the target app. That could cause a big problem.
I''d love to know the answer to this, too. I just finished up work on a school project of my own two days ago; this was an unresolved problem of mine as well.
Injecting the code into other apps'' memory space doesn''t seem like a good solution; who knows how many apps there might be that need to be injected. There has to be some way to disable the context menu entirely on a system-wide, low-level basis.
Anyone have any ideas?
Injecting the code into other apps'' memory space doesn''t seem like a good solution; who knows how many apps there might be that need to be injected. There has to be some way to disable the context menu entirely on a system-wide, low-level basis.
Anyone have any ideas?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement