joe_pool_is
Contributor
How can I load a System Resource image into a PictureBox with the CLR?
(This is actually C++ code, but I'm not sure if there is a C++ tag, so I borrowed the CS tag)
I can't seem to find any way of loading one of the Resource images.
--
Product: Visual C++ 2005 Express
(This is actually C++ code, but I'm not sure if there is a C++ tag, so I borrowed the CS tag)
C#:
System::Windows::Forms::PictureBox^ PictureBox1;
System::IO::Stream^ resource;
System::Void Button_Click(System::Object^ sender, System::EventArgs^ e)
{
resource = Assembly::GetManifestResourceStream("MyNamespace.Fido.jpg");
// Error is
// "error C2352:
// 'System::Reflection::Assembly::GetManifestResourceStream' :
// illegal call of non-static member function"
PictureBox1->Image = gcnew
Image::FromStream(Assembly::GetManifestResourceStream("MyNamespace.Fido.jpg"));
// Error is
// "error C2061:
// syntax error : identifier 'FromStream'"
System::Reflection::Assembly^ ExeAss;
ExeAss = Assembly::GetExecutingAssembly();
Bitmap^ image = gcnew Bitmap(ExeAss->GetManifestResourceStream("MyNamespace.Fido.jpg"));
// image is always null
PictureBox1->Image = image;
}
--
Product: Visual C++ 2005 Express