MouseButtons

  • Thread starter Thread starter dragonslayer008
  • Start date Start date
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?
 
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.
 
Back
Top