Witam!
Piszę w c++/cli pewną aplikację w której PictureBox ma się poruszyć zgodnie z ruchem przytrzymanej na nim myszki.
PictureBox ma się tylko poruszać poziomo i tylko po danym obszarze. Udało mi się zrobić tak aby PictureBox się zatrzymywał ale gdy się już zatrzyma to nie można już nim w ogóle ruszać.
Mój kod:
bool _moving;
Point _startLocation;
private: System::Void PictureBox_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
_moving = true;
_startLocation = e->Location;
}
private: System::Void PictureBox_MouseUp(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
_moving = false;
}
private: System::Void PictureBox_MouseMove(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
if ((_moving == true) && (PictureBox->Location.X >= 146) && (PictureBox->Location.X <= 585))
{
PictureBox->Left += e->Location.X - _startLocation.X;
}
}
HELP!