Witam, poszukiwałem sposobu na zrobienie przeźroczystego pictureBoxa.
Znalazłem: http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/f43ed61e-6e15-41f8-801d-1e908810eed2
A, że potrzebuje to użyć w C++.NET próbowałem przełożyć:
#pragma once
ref class TransparentPictureBox :
public System::Windows::Forms::Control
{
private:
System::Windows::Forms::Timer^ refresher;
property System::Drawing::Image^ _image{
System::Drawing::Image^ get() { return _image; }
void set( System::Drawing::Image^ value ) { _image = value; __super::RecreateHandle();}
}
public:
TransparentPictureBox(void){
refresher = gcnew System::Windows::Forms::Timer();
refresher->Tick += gcnew System::EventHandler(this,&TransparentPictureBox::TimerOnTick);
refresher->Interval = 50;
refresher->Start();
}
void TimerOnTick(System::Object^ sender, System::EventArgs^ e) {
__super::RecreateHandle();
refresher->Stop();
}
virtual void OnPaint(System::Windows::Forms::PaintEventArgs^ e) override{
e->Graphics->DrawImage(_image, 0,0);
}
protected:
virtual System::Windows::Forms::CreateParams^ get() override{
System::Windows::Forms::CreateParams^ cp = __super::CreateParams;
cp->ExStyle |= 0x20;
return cp;
}
};
jednak przy próbie dodanie nowej kontrolki Visual Studio 2008 wiesza się. Czy ktoś dostrzega jakiś poważniejszy błąd w przekładzie? Albo może inna alternatywa, by widzieć innego PictureBoxa który jest pod moim PictureBoxem ?