How to find out whether left button of a mouse is pressed

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello.<br/>
I use VS 2010, .NET, Windows Forms Application project
I wanna start action IF LEFT MOUSE BUTTON IS PRESSED. <br/>
accrording to<br/>
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousebuttons.aspx#Y0<br/>
<br/>
I have to do it like that<br/>

<pre class="prettyprint private: System::Void pictureBox1_MouseMove_1(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
if ( e->Button == ::MouseButtons::Left)
{
/* int x = pictureBox1->Cursor->Position.X - this->Location.X - pictureBox1->Location.X - SystemInformation::SizingBorderWidth - SystemInformation::BorderSize.Width;
int y = pictureBox1->Cursor->Position.Y - this->Location.Y - pictureBox1->Location.Y - SystemInformation::CaptionHeight - SystemInformation::BorderSize.Height-5;
Graphics^ g1 = pictureBox1->CreateGraphics();
g1->FillRectangle(gcnew SolidBrush(Color::FromArgb(255, 255, 255)), Rectangle(x, y, 50, 50));*/
}
}[/code]
<br/>
But I get stupid errors<br/>
MouseButtons: the symbol to the left of a :: must be a type <br/>
Left : is not a member of `global namespace <br/>
operator ==: all operands must have the same enumeration type
<br/>
<br/>
if I use<br/>

<pre class="prettyprint if ( e->Button == MouseButtons::Left)[/code]
than I get<br/>
Left : is not a member of System::Windows::Forms::Control::MouseButtons
<br/>
<br/>
<br/>
<br/>
<br/>


View the full article
 
Back
Top