changing application icon at runtime without recompiling
-
Hi there, I hope that every .net programmer knows about app.ico. If not then create a windows application in c# and check out the working folder. You could see such a file there. This file is the picture file that is displayed in the exe file(check out debug folder of your application). Now what i need is, i want to change this app.ico through c# coding. Is it possible for changing the application icon at runtime without re-compiling? When i mention a .ico file, at runtime, this new .ico file should replace the existing default app.ico file and my .exe file in debug folder should also posses this image. How can this be made?
-
Hi there, I hope that every .net programmer knows about app.ico. If not then create a windows application in c# and check out the working folder. You could see such a file there. This file is the picture file that is displayed in the exe file(check out debug folder of your application). Now what i need is, i want to change this app.ico through c# coding. Is it possible for changing the application icon at runtime without re-compiling? When i mention a .ico file, at runtime, this new .ico file should replace the existing default app.ico file and my .exe file in debug folder should also posses this image. How can this be made?
Bitmap bmp = (Bitmap)resources.GetObject("myBMP.bmp"); IntPtr Hicon = bmp.GetHicon(); Icon newIcon = Icon.FromHandle(Hicon); This code here can change ur icon at run time. instead of the first ;line try getting the bmp image from file as for replacing the app.ico well I dont know...
-
Bitmap bmp = (Bitmap)resources.GetObject("myBMP.bmp"); IntPtr Hicon = bmp.GetHicon(); Icon newIcon = Icon.FromHandle(Hicon); This code here can change ur icon at run time. instead of the first ;line try getting the bmp image from file as for replacing the app.ico well I dont know...
can you please tell me what this 'resources' is- in first line? The error i get with this code is: "The type or namespace name 'resources' could not be found (are you missing a using directive or an assembly reference?)"
-
can you please tell me what this 'resources' is- in first line? The error i get with this code is: "The type or namespace name 'resources' could not be found (are you missing a using directive or an assembly reference?)"
well lets just forget what that resources was here. Im giving u this actual function that I wrote. public static void change_Icon(string iconName, System.Windows.Forms.Form This) { try { //MessageBox.Show(Environment.CurrentDirectory); string c = Environment.CurrentDirectory; //MessageBox.Show(c + "\n" + c.IndexOf("ATech").ToString() + "\n " + c.Substring(0, (c.IndexOf("ATech") + 6)).ToString()); string path = c.Substring(0, (c.IndexOf("ATech") + 6)) + @"Resources\Icons\" + iconName; Bitmap bmp = new Bitmap(Image.FromFile(path)); IntPtr Hicon = bmp.GetHicon(); Icon newIcon = Icon.FromHandle(Hicon); This.Icon = newIcon; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } well in this I'm just making out the correct path to the resources folder. 'Atech ' is the name of tyhe project and its main directory. The actual images were stored in ......\Atech\Resources\icons folder so I had to get them from there. tell me if u get hold of this code. I think its pretty straight forward. hope it helps Rocky
-
Hi there, I hope that every .net programmer knows about app.ico. If not then create a windows application in c# and check out the working folder. You could see such a file there. This file is the picture file that is displayed in the exe file(check out debug folder of your application). Now what i need is, i want to change this app.ico through c# coding. Is it possible for changing the application icon at runtime without re-compiling? When i mention a .ico file, at runtime, this new .ico file should replace the existing default app.ico file and my .exe file in debug folder should also posses this image. How can this be made?
is very simple only you need keep in a loop for instance this: System .Drawing .Icon nuevo=new Icon (@"D:\MyIconNow.ico"); Random manual=new Random (); int p = manual.Next (2); if (p == 1) base.Icon=nuevo; else base.Icon=null; of course, the loop is'nt the only way too keep that atach in execution, try with delegate... if you wanna know anything write me :laugh::laugh::laugh: