MouseButtons

D

dragonslayer008

Petzolds C# book has code like this:

(mea.Button & MouseButtons.Right != 0)

I try the C++/CLI analog:

if( (e->Button & ::MouseButtons::Left) != 0 )

but get errors:

error C2678: binary '!=' : no operator found which takes a left-hand
operand of type 'System::Windows::Forms::MouseButtons' (or there is no
acceptable conversion)

why?
 
S

SvenC

Hi dragonslayer008,
Petzolds C# book has code like this:

(mea.Button & MouseButtons.Right != 0)

I try the C++/CLI analog:

if( (e->Button & ::MouseButtons::Left) != 0 )

but get errors:

error C2678: binary '!=' : no operator found which takes a left-hand
operand of type 'System::Windows::Forms::MouseButtons' (or there is no
acceptable conversion)

Use if((e->Button & ::MouseButtons::Left) == ::MouseButtons::Left) which
uses the same type on both sides of the operator. Otherwise you would need
to cast either of the two sides explicitly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top