项目资源
Resources of project
我需要在文件中更改图片框的图像。h,我写这本书:
mass[oldcord.first - 1, oldcord.second + 1]->Image = Image::FromFile("EMPTY.png");
但是,如果我不是从文件夹中运行项目,我会遇到一个错误,因为如果找不到图像,因为我不是从项目文件夹中执行它。我如何使用"资源"不是从我的表单中使用的,而是从这样的其他文件中使用:
this->MainField->Image = (cli::safe_cast<System::Drawing::Image^>(resources->GetObject(L"Field")));
我希望我的应用程序从任何地方执行,不仅是从我的文件夹中执行的。
我试图通过构造函数传递形式资源,但是我失败了
加法:
#pragma once
#include "MainForm.h"
#include <string>
using namespace std;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
enum TYPE { EMPTY, BLACK, WHITE };
ref class Figure
{
public:
Figure()
{
color = EMPTY;
active = 0;
king = 0;
}
Figure(int x, int y, TYPE color)
{
this->color = color;
this->color = color;
active = 0;
king = 0;
}
void MoveTo(pair<int,int> newcord, System::Windows::Forms::PictureBox^ current, TYPE turn) // ставит на место, меняет статус, цвет
{
current->Location = System::Drawing::Point(37 + newcord.second * 90, 37 + newcord.first * 90);
if (color == EMPTY)
color = turn;
else
color = EMPTY;
}
void make_king(System::Windows::Forms::PictureBox^% current, int i)
{
if (i == 0 && color == WHITE)
{
current->Image = Image::FromFile("WhiteKing.png");
king = true;
}
else if (i == 7 && color == BLACK)
{
current->Image = Image::FromFile("BlackKing.png");
king = true;
}
}
bool is_active()
{
return active;
}
void make_active(bool active)
{
this->active = active;
}
TYPE getColor()
{
return color;
}
void setColor(TYPE color)
{
this->color = color;
}
bool is_king()
{
return king;
}
private:
Graphics^ picture;
TYPE color;
bool active;
bool king;
};
您可以尝试使用boost :: program_options为此>
例如,您的程序可以拥有一个配置类,该类别具有可以在运行时间更改的配置选项(例如带有资源或任何您需要的路径(。
相关文章:
- 如何维护资源管理器项目视图中当前可见的项目列表
- Qt - 为什么Visual Studio 2019在qml资源中添加10Mb文件后无法再编译我的项目?
- Visual Studio 2015资源视图和资源编译器使用不同的方法在项目目录中查找图标文件.如何修复
- MSBuidel - 将资源文件添加到项目后静态库编译失败
- 通过命令行将RCDATA资源导入Visual Studio项目
- 将XML字符串资源嵌入C 项目
- 项目资源
- 如何在没有QT项目的情况下使用Visual Studio中的QT资源文件
- 从电子项目运行的可执行文件未加载资源
- Qt:项目资源中打开的.txt文件的 QFile 的空内容
- SHOpenFolder并选择资源管理器更换程序的项目
- 资源管理器在 TILE 视图模式下不显示 shell 命名空间扩展的项目详细信息
- Visual Studio 2010中新的ATL项目的资源ID差距
- 有没有一种简单的方法可以将多个资源添加到 Win32/C++ 项目
- qtmake-两个项目/目标之间的共享资源
- 从 WinAPI C 项目中的专用 DLL 加载图像资源
- 如果我在Visual Studio项目中将图像作为资源包含在内,这些图像是否会编译到可执行文件中
- 尝试在Visual Studio中重命名托管c ++项目,现在出现资源错误
- 在 Visual Studio 2015 的 dll 项目中包括自己的资源文件时出现链接器错误Microsoft
- 日食 :如何从项目资源管理器中隐藏文件