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

Tech-Archive recommends: Fix windows errors by optimizing your registry



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@xxxxxxxxxxxxxxxxxxxxxxx
> Here's how I implement round():
>
> #define round(d) (int)( (d < 0) ? (d-0.5) : (d + 0.5) )
>
> Paul T.
>
> "Daniel Mattsson" <danmat378852@xxxxxxxxxxxx> wrote in message
> news:eksaWVWYFHA.1796@xxxxxxxxxxxxxxxxxxxxxxx
>> 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@xxxxxxxxxxxxxxxxxxxxxxx
>>> 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@xxxxxxxxxxxx> wrote in message
>>> news:OoI$Y2VYFHA.616@xxxxxxxxxxxxxxxxxxxxxxx
>>>> 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
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>


.



Relevant Pages