When develope with Windows Forms Application, loading a bitmap files in resource is
different , comparing with API/MFC windows application.
Each Form has its own resouce file(.resx) and it can be added new resouce file(.resx).
So we shoud add a resoure , such a bitmap ,text, or icon within a .resx file.
Following image is added two bitmaps in MineForm.resx .
Next, When we are going to load a bitmap in resx , we should use a ResourceManager class.
Following codes show how to load a bitmap in resx resource item.
Reflection::Assembly^ assem = Reflection::Assembly::GetExecutingAssembly();
Resources::ResourceManager^ rm = gcnew Resources::ResourceManager
("MineSearcher.MineForm",assem);
System::Drawing::Bitmap^ frontBMP = safe_cast<Bitmap^>(rm->GetObject("itemimg"));
System::Drawing::Bitmap^ backBMP = safe_cast<Bitmap^>(rm->GetObject("backimg"));
No comments:
Post a Comment