图片资源? [英] Image resources?

查看:133
本文介绍了图片资源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力想了解如何使用C ++ / CLI中的资源。我已经搞砸了resource.h / app.rc文件和托管的resx文件无效。

I've been struggling for hours trying to figure out how to use resources in C++/CLI. I've messed around with the resource.h/app.rc files along with the managed resx files to no avail.

我只有一对夫妇的PNG图像,我会喜欢使用PictureBox,但我似乎不知道如何设置资源...

I just have a couple PNG images that I would like to use with a PictureBox, but I can't seem to figure out how to setup the resources...

感谢您的帮助,

Alex

推荐答案


  • 创建窗体项目

  • 向项目中添加新资源文件(resx)

  • 打开该文件,资源编辑器出现在

  • 左上角切换到图片模式

  • 点击添加资源,然后在代码使用中添加图片

  • 这样:

    • create a windows forms project
    • add new resource file (resx) to the project
    • open that file, the resource editor appears
    • in the top left corner switch to image mode
    • at the top click to "Add resources", and add your images
    • in your code use it this way:

      using namespace System::Resources;
      
      ResourceManager^ rm = gcnew ResourceManager("ImageResources.MyResources", GetType()->Assembly);
      
      pictureBox1->Image = safe_cast<Image^>(rm->GetObject(L"MyImage");
      


    • 其中ImageResources是命名空间的名称,MyResources是resx文件的名称,MyImage 是资源文件中的图像的名称。

      Where "ImageResources" is the name of the namespace, the "MyResources" is the name of the resx file and the "MyImage" is the name of the image inside the resource file.

      这篇关于图片资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆