cdoverlaw Posted January 15, 2004 Posted January 15, 2004 My program uses a notifyicon but if the icon isnt in the my documents folder it wont work Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load NotifyIcon1.Icon = New _ System.Drawing.Icon(System.Environment.GetFolderPath _ (System.Environment.SpecialFolder.Personal) _ & "/Icon.ico") NotifyIcon1.Visible = True NotifyIcon1.Text = "WHM & CP Launcher" End Sub how can i get it to work where ever the program is installed Jonathan Quote
Administrators PlausiblyDamp Posted January 15, 2004 Administrators Posted January 15, 2004 You could put the icon in the applications directory and use a path of Application.StartupPath & "\icon.ico" or alternatively you could embed the icon into the executable. http://www.xtremedotnettalk.com/showthread.php?s=&threadid=75889&highlight=embedded+resource Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted January 15, 2004 Author Posted January 15, 2004 hmm, ok so what code would make the icon work if i embed it Quote
Administrators PlausiblyDamp Posted January 15, 2004 Administrators Posted January 15, 2004 Just a rehash of the link I posted... Dim ico As Icon ico = New Icon(([Assembly].GetExecutingAssembly().GetManifestResourceStream("WindowsApplication1.Icon1.ico"))) Me.Icon = ico you will need to change WindowsApplication1 to the namespace for your application and Icon1.ico to whatever the icon is called. Also add Imports System.Reflection to the top of the module Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted January 15, 2004 Author Posted January 15, 2004 (edited) it says name 'Assembly' not declared what is the problem with this UPDATE: I cant work out how to get this to work, i basically need all files to work from whatever directory they are in, they dont have to be embedded i just want it to work Edited January 15, 2004 by cdoverlaw Quote
Administrators PlausiblyDamp Posted January 16, 2004 Administrators Posted January 16, 2004 Did you add the imports statement I mentioned as well - it should work if you did. Also did you try using Application.SartupPath and putting them in the same directory as the executable? Either of those ways should work. If you are having problems then posting the code in question or the errors raised will give people more chance to help. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted January 16, 2004 Author Posted January 16, 2004 (edited) Basicly i dont understand where to add that code in the subroutine which regards this notify icon I have currently Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load NotifyIcon1.Icon = New _ System.Drawing.Icon(System.Environment.GetFolderPath _ (System.Environment.SpecialFolder.Personal) _ & "/Icon.ico") NotifyIcon1.Visible = True NotifyIcon1.Text = "WHM & CP Launcher" End Sub Edited January 16, 2004 by cdoverlaw Quote
Administrators PlausiblyDamp Posted January 16, 2004 Administrators Posted January 16, 2004 You could replace your form_load code with the code from above Dim ico As Icon ico = New Icon(([Assembly].GetExecutingAssembly().GetManifestResourceStream("WindowsApplication1.Icon1.ico"))) Me.Icon = ico or if you just want to drop them in the application directory use Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load NotifyIcon1.Icon = New _ System.Drawing.Icon(Application.StartupPath & "\Icon1.ico") NotifyIcon1.Visible = True NotifyIcon1.Text = "WHM & CP Launcher" End Sub although the second way isn't always 100% reliable - a short-cut could have an alternate startup directory which would break this. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
cdoverlaw Posted January 16, 2004 Author Posted January 16, 2004 Ok thanks now that is working, Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.