4 Replies - 2289 Views - Last Post: 13 November 2010 - 03:58 PM Rate Topic: -----

#1 MathiasVP  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 154
  • Joined: 08-August 10

BlockInput() to a single application?

Posted 13 November 2010 - 02:15 PM

Hey all!

I'm developing a small application that allows the user to modify window transparency, styles, position and all that stuff. All this is working now, but I have 1 problem.

To control the window transparency on a window, the user holds down Shift and scrolls with the mouse wheel to modify it.
The problem, however, is that when scrolling with the mousewheel to turn up the transparency, the mousewheel is affecting the foreground window which I am editing..

So for instance if I'm turning up the transparency in VLC Media Player by holding down shift and scrolling, I'm modifying the sound volume too.

Is there any neat way of preventing this? I was hoping that the Windows API had some kind of BlockInput() for 1 application only, instead of events to all applications.

I also tried using hooks, but after many days of wasted hours I discovered that I can't modify messages inside a hook's callback procedure

Anyone have any neat ideas?

Thanks in advance!

Is This A Good Question/Topic? 0
  • +

Replies To: BlockInput() to a single application?

#2 rs4  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 29
  • View blog
  • Posts: 153
  • Joined: 01-February 09

Re: BlockInput() to a single application?

Posted 13 November 2010 - 03:09 PM

I think you should be able to do this with hooks.

From MSDN

A hook is a point in the system message-handling mechanism where an application can install a subroutine to monitor the message traffic in the system and process certain types of messages before they reach the target window procedure.

A hook is a mechanism by which an application can intercept events, such as messages, mouse actions, and keystrokes. A function that intercepts a particular type of event is known as a hook procedure. A hook procedure can act on each event it receives, and then modify or discard the event.
Was This Post Helpful? 0
  • +
  • -

#3 MathiasVP  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 154
  • Joined: 08-August 10

Re: BlockInput() to a single application?

Posted 13 November 2010 - 03:35 PM

Hello rs4 and thank you for your reply!

You are right, I can use a hook to block the action from happening, the only problem is that if I block the scroll wheel message completely, I can't use it for my own application. So I need to block the scroll wheel message to 1 windows only, but let it go through to all the other applications

I made a quick hook callback procedure that looks like this:
LRESULT CALLBACK LowLevelMouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
	if(wParam == WM_MOUSEWHEEL)
		return 1;

	return CallNextHookEx(NULL, nCode, wParam, lParam);
}


But now I'm completely blocking the mouse wheel, which means that I'm also blocking it for my own application that have to receive it

Is there any other hook I can use to block it to 1 single application only?
Was This Post Helpful? 0
  • +
  • -

#4 rs4  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 29
  • View blog
  • Posts: 153
  • Joined: 01-February 09

Re: BlockInput() to a single application?

Posted 13 November 2010 - 03:54 PM

It appears that WH_MOUSE_LL is a global hook so will have to catch all mouse events, where as WH_MOUSE can be assigned to monitor only one thread set with SetWindowsHookEx().

However to just get it working it could be easier for your callback to send a message (SendMessage()) and create a application defined message that you can then process.

This post has been edited by rs4: 13 November 2010 - 03:55 PM

Was This Post Helpful? 1
  • +
  • -

#5 MathiasVP  Icon User is offline

  • D.I.C Head

Reputation: 27
  • View blog
  • Posts: 154
  • Joined: 08-August 10

Re: BlockInput() to a single application?

Posted 13 November 2010 - 03:58 PM

Hmm an Application-Defined Message certainly sounds interesting!

Will go work on it and report back on how it worked!

Thanks alot mate :bigsmile:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1