急!VC++2005 的问题
//窗体的MouseDoubleClick事件
private: System::Void WM_OnMouseDoubleClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
PictureBox ^pictureBox = gcnew PictureBox();
pictureBox->Location = Point(e->X-(pictureBox->Width/2),e->Y(pictureBox->Height/2));
Image ^image = Image::FromFile("BoxOn.jpg");
pictureBox->BackgroundImage = image;
pictureBox->BackgroundImageLayout = ImageLayout::Stretch;
this->Controls->Add( pictureBox );
//动态调用Form1的Paint事件
this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this,
&Form1::WM_OnPaint);
Invalidate(false);//重绘
}
//窗体Paint事件
private: System::Void WM_OnPaint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)
{
Graphics ^line = e->Graphics;
//这里的问号是我想传递的刚才动态生成的pictureBox的坐标.请问该怎么做?
line->DrawLine( Pens::White, 0, 0, ?, ? );
}
还有就是为什么动态控件的某一事件如果与窗体事件相同(比如都有Paint事件)该怎么处理,使他们不冲突?
例子如下:
窗体的MouseDoubleClick事件处理函数
private: System::Void WM_OnMouseDoubleClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)
{
treeNode->MouseDoubleClick += gcnew
System::Windows::Forms::MouseEventHandler(this,&Form1::Paint);
}
中加入PictrueBox ^treeNode的MouseDoubleClick事件申明,却与Form1 的事件申明发生冲突。
怎么解决?