0

I am using a form skin and instead of removing everything including the form skin I have been trying to make the form change the icon itself on startup. I have bitmap versions of my logo and when i try to reference those i get the error: Cannot implicitly convert type 'System.Drawing.Bitmap' to 'System.Drawing.Icon'

I have tried adding an icon to my resources and trying to reference it, however, only my bitmaps are able to be referenced.

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;
    }

I get the error: 'Resources' does not contain a definition for 'Logo' (Line 44)

1 Answers1

0

Check if your Icon in resources is really called Logo. You could change Bitmap to Icon, but I don't know if you will be satisfied with result.

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);
Pablo notPicasso
  • 3,031
  • 3
  • 17
  • 22
  • Where do i put this code and how do i actually initiate it, could you show me what the entire thing would look like –  Jan 04 '19 at 14:15