我使用的是表单皮肤,而不是删除包括表单皮肤在内的所有内容,我一直在尝试使表单在启动时更改图标本身。我有徽标的位图版本,当我尝试引用这些位图时,出现错误:无法将类型'System.Drawing.Bitmap'隐式转换为'System.Drawing.Icon'
我尝试将图标添加到资源中并尝试引用它,但是只能引用我的位图。
public Main2()
{
InitializeComponent();
Main2 f1 = new Main2();
f1.Text = "Chaos V2.0.1c";
f1.Icon = Properties.Resources.Logo; //problematic code (line 44)
//My Tab Controls
HomeTabControl.Visible = true;
FullLuaTabControl.Visible = false;
CommandTabControl.Visible = false;
VIPServerTabControl.Visible = false;
JailbreakTabControl.Visible = false;
PhantomForcesTabControl.Visible = false;
MM2TabControl.Visible = false;
RoCitizensTabControl.Visible = false;
BoogaBoogaTabControl.Visible = false;
PrisonLifeTabControl.Visible = false;
BuildABoatTabControl.Visible = false;
LumberTycoon2TabControl.Visible = false;
MeepCityTabControl.Visible = false;
VehicleSimulatorTabControl.Visible = false;
SuperPowerTrainingTabControl.Visible = false;
BeeSwarmSimulatorTabControl.Visible = false;
WeightLiftingTabControl.Visible = false;
MiningSimulatorTabControl.Visible = false;
BlobSimulatorTabControl.Visible = false;
IceCreamSimulatorTabControl.Visible = false;
PetSimulatorTabControl.Visible = false;
StrucidTabControl.Visible = false;
CounterBloxTabControl.Visible = false;
ApocalypseTabControl.Visible = false;
FullLuaScriptsTabControl.Visible = false;
SettingsTabControl.Visible = false;
}
我收到错误消息:“资源”不包含“徽标”的定义(第44行)
答案 0 :(得分:0)
检查资源中的图标是否真的称为徽标。 您可以将“位图”更改为“图标”,但是我不知道您是否会对结果满意。
public Icon ToIcon(Bitmap bmp)
{
IntPtr hicon = bmp.GetHicon();
Icon icon = Icon.FromHandle(hicon);
DestroyIcon(hicon); // prevent memory leak.
return icon;
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
extern static bool DestroyIcon(IntPtr handle);