Hi, I´m trying to prevent some mouse messages to be forwarded to some
applications, but the mouse driver gives me the absolute mouse coordinates.

How could I convert them to screen coordinates?

Thanks for helping me out, Dani

Re: How to convert absolute mouse coordinates to normal positions relative a window? by Paul

Paul
Wed May 25 14:30:45 CDT 2005

Well, based on the documentation of mouse_event(), it *sounds* like the
absolute coordinate range is 0-65535 and that corresponds to 0-<screen width
or height>, so it should be a simple division problem:

screenx = round( ( absolutex / 65535.0 ) * screenwidth );

should be pretty close, I think.

Paul T.

"Daniel Mattsson" <danmat378852@bredband.net> wrote in message
news:OoI$Y2VYFHA.616@TK2MSFTNGP12.phx.gbl...
> Hi, I´m trying to prevent some mouse messages to be forwarded to some
> applications, but the mouse driver gives me the absolute mouse
> coordinates.
>
> How could I convert them to screen coordinates?
>
> Thanks for helping me out, Dani
>
>
>



Re: How to convert absolute mouse coordinates to normal positions relative a window? by Daniel

Daniel
Wed May 25 15:07:20 CDT 2005

Thanks, you are probably right.

How to include the round() function to the driver, I get an error

error C3861: 'round': identifier not found, even with argument-dependent
lookup

And the help section shows no requirements or header file for that function?

Any ideas?

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
wrote in message news:OuAW0AWYFHA.2796@TK2MSFTNGP09.phx.gbl...
> Well, based on the documentation of mouse_event(), it *sounds* like the
> absolute coordinate range is 0-65535 and that corresponds to 0-<screen
> width or height>, so it should be a simple division problem:
>
> screenx = round( ( absolutex / 65535.0 ) * screenwidth );
>
> should be pretty close, I think.
>
> Paul T.
>
> "Daniel Mattsson" <danmat378852@bredband.net> wrote in message
> news:OoI$Y2VYFHA.616@TK2MSFTNGP12.phx.gbl...
>> Hi, I´m trying to prevent some mouse messages to be forwarded to some
>> applications, but the mouse driver gives me the absolute mouse
>> coordinates.
>>
>> How could I convert them to screen coordinates?
>>
>> Thanks for helping me out, Dani
>>
>>
>>
>
>



Re: How to convert absolute mouse coordinates to normal positions relative a window? by Paul

Paul
Wed May 25 15:13:50 CDT 2005

Here's how I implement round():

#define round(d) (int)( (d < 0) ? (d-0.5) : (d + 0.5) )

Paul T.

"Daniel Mattsson" <danmat378852@bredband.net> wrote in message
news:eksaWVWYFHA.1796@TK2MSFTNGP15.phx.gbl...
> Thanks, you are probably right.
>
> How to include the round() function to the driver, I get an error
>
> error C3861: 'round': identifier not found, even with argument-dependent
> lookup
>
> And the help section shows no requirements or header file for that
> function?
>
> Any ideas?
>
> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
> wrote in message news:OuAW0AWYFHA.2796@TK2MSFTNGP09.phx.gbl...
>> Well, based on the documentation of mouse_event(), it *sounds* like the
>> absolute coordinate range is 0-65535 and that corresponds to 0-<screen
>> width or height>, so it should be a simple division problem:
>>
>> screenx = round( ( absolutex / 65535.0 ) * screenwidth );
>>
>> should be pretty close, I think.
>>
>> Paul T.
>>
>> "Daniel Mattsson" <danmat378852@bredband.net> wrote in message
>> news:OoI$Y2VYFHA.616@TK2MSFTNGP12.phx.gbl...
>>> Hi, I´m trying to prevent some mouse messages to be forwarded to some
>>> applications, but the mouse driver gives me the absolute mouse
>>> coordinates.
>>>
>>> How could I convert them to screen coordinates?
>>>
>>> Thanks for helping me out, Dani
>>>
>>>
>>>
>>
>>
>
>



Re: How to convert absolute mouse coordinates to normal positions relative a window? by Daniel

Daniel
Wed May 25 15:25:35 CDT 2005

Thanks Paul, I did a typecast to int and it seems to work as expected:

screenx = (int)( ( absolutex / 65535.0 ) * screenwidth );

but your solution is perhaps better.



"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
wrote in message news:ufRg5YWYFHA.3184@TK2MSFTNGP15.phx.gbl...
> Here's how I implement round():
>
> #define round(d) (int)( (d < 0) ? (d-0.5) : (d + 0.5) )
>
> Paul T.
>
> "Daniel Mattsson" <danmat378852@bredband.net> wrote in message
> news:eksaWVWYFHA.1796@TK2MSFTNGP15.phx.gbl...
>> Thanks, you are probably right.
>>
>> How to include the round() function to the driver, I get an error
>>
>> error C3861: 'round': identifier not found, even with argument-dependent
>> lookup
>>
>> And the help section shows no requirements or header file for that
>> function?
>>
>> Any ideas?
>>
>> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
>> wrote in message news:OuAW0AWYFHA.2796@TK2MSFTNGP09.phx.gbl...
>>> Well, based on the documentation of mouse_event(), it *sounds* like the
>>> absolute coordinate range is 0-65535 and that corresponds to 0-<screen
>>> width or height>, so it should be a simple division problem:
>>>
>>> screenx = round( ( absolutex / 65535.0 ) * screenwidth );
>>>
>>> should be pretty close, I think.
>>>
>>> Paul T.
>>>
>>> "Daniel Mattsson" <danmat378852@bredband.net> wrote in message
>>> news:OoI$Y2VYFHA.616@TK2MSFTNGP12.phx.gbl...
>>>> Hi, I´m trying to prevent some mouse messages to be forwarded to some
>>>> applications, but the mouse driver gives me the absolute mouse
>>>> coordinates.
>>>>
>>>> How could I convert them to screen coordinates?
>>>>
>>>> Thanks for helping me out, Dani
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: How to convert absolute mouse coordinates to normal positions relative a window? by Paul

Paul
Wed May 25 15:37:59 CDT 2005

It's maximum error if you just truncate is 0.9999 of a pixel, so you might
not get exactly what you thought was right, but I'd be surprised if anyone
actually noticed.

Paul T.

"Daniel Mattsson" <danmat378852@bredband.net> wrote in message
news:OW7fdfWYFHA.2508@TK2MSFTNGP15.phx.gbl...
> Thanks Paul, I did a typecast to int and it seems to work as expected:
>
> screenx = (int)( ( absolutex / 65535.0 ) * screenwidth );
>
> but your solution is perhaps better.
>
>
>
> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
> wrote in message news:ufRg5YWYFHA.3184@TK2MSFTNGP15.phx.gbl...
>> Here's how I implement round():
>>
>> #define round(d) (int)( (d < 0) ? (d-0.5) : (d + 0.5) )
>>
>> Paul T.
>>
>> "Daniel Mattsson" <danmat378852@bredband.net> wrote in message
>> news:eksaWVWYFHA.1796@TK2MSFTNGP15.phx.gbl...
>>> Thanks, you are probably right.
>>>
>>> How to include the round() function to the driver, I get an error
>>>
>>> error C3861: 'round': identifier not found, even with argument-dependent
>>> lookup
>>>
>>> And the help section shows no requirements or header file for that
>>> function?
>>>
>>> Any ideas?
>>>
>>> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
>>> wrote in message news:OuAW0AWYFHA.2796@TK2MSFTNGP09.phx.gbl...
>>>> Well, based on the documentation of mouse_event(), it *sounds* like the
>>>> absolute coordinate range is 0-65535 and that corresponds to 0-<screen
>>>> width or height>, so it should be a simple division problem:
>>>>
>>>> screenx = round( ( absolutex / 65535.0 ) * screenwidth );
>>>>
>>>> should be pretty close, I think.
>>>>
>>>> Paul T.
>>>>
>>>> "Daniel Mattsson" <danmat378852@bredband.net> wrote in message
>>>> news:OoI$Y2VYFHA.616@TK2MSFTNGP12.phx.gbl...
>>>>> Hi, I´m trying to prevent some mouse messages to be forwarded to some
>>>>> applications, but the mouse driver gives me the absolute mouse
>>>>> coordinates.
>>>>>
>>>>> How could I convert them to screen coordinates?
>>>>>
>>>>> Thanks for helping me out, Dani
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>



Re: How to convert absolute mouse coordinates to normal positions relative a window? by Daniel

Daniel
Wed May 25 16:10:15 CDT 2005

Thanks, I will keep that in mind, Dani

"Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
wrote in message news:eCU9YmWYFHA.3584@TK2MSFTNGP12.phx.gbl...
> It's maximum error if you just truncate is 0.9999 of a pixel, so you might
> not get exactly what you thought was right, but I'd be surprised if anyone
> actually noticed.
>
> Paul T.
>
> "Daniel Mattsson" <danmat378852@bredband.net> wrote in message
> news:OW7fdfWYFHA.2508@TK2MSFTNGP15.phx.gbl...
>> Thanks Paul, I did a typecast to int and it seems to work as expected:
>>
>> screenx = (int)( ( absolutex / 65535.0 ) * screenwidth );
>>
>> but your solution is perhaps better.
>>
>>
>>
>> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT com>
>> wrote in message news:ufRg5YWYFHA.3184@TK2MSFTNGP15.phx.gbl...
>>> Here's how I implement round():
>>>
>>> #define round(d) (int)( (d < 0) ? (d-0.5) : (d + 0.5) )
>>>
>>> Paul T.
>>>
>>> "Daniel Mattsson" <danmat378852@bredband.net> wrote in message
>>> news:eksaWVWYFHA.1796@TK2MSFTNGP15.phx.gbl...
>>>> Thanks, you are probably right.
>>>>
>>>> How to include the round() function to the driver, I get an error
>>>>
>>>> error C3861: 'round': identifier not found, even with
>>>> argument-dependent lookup
>>>>
>>>> And the help section shows no requirements or header file for that
>>>> function?
>>>>
>>>> Any ideas?
>>>>
>>>> "Paul G. Tobey [eMVP]" <ptobey no spam AT no instrument no spam DOT
>>>> com> wrote in message news:OuAW0AWYFHA.2796@TK2MSFTNGP09.phx.gbl...
>>>>> Well, based on the documentation of mouse_event(), it *sounds* like
>>>>> the absolute coordinate range is 0-65535 and that corresponds to
>>>>> 0-<screen width or height>, so it should be a simple division problem:
>>>>>
>>>>> screenx = round( ( absolutex / 65535.0 ) * screenwidth );
>>>>>
>>>>> should be pretty close, I think.
>>>>>
>>>>> Paul T.
>>>>>
>>>>> "Daniel Mattsson" <danmat378852@bredband.net> wrote in message
>>>>> news:OoI$Y2VYFHA.616@TK2MSFTNGP12.phx.gbl...
>>>>>> Hi, I´m trying to prevent some mouse messages to be forwarded to some
>>>>>> applications, but the mouse driver gives me the absolute mouse
>>>>>> coordinates.
>>>>>>
>>>>>> How could I convert them to screen coordinates?
>>>>>>
>>>>>> Thanks for helping me out, Dani
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>