Notify Icon and Context Menu Probs...

linksanime2003
12-21-2004, 03:21 PM
What I'm trying to do is to change the items in a context menu after it has loaded.

A form is loaded, and it lets you change items in the context menu. It save these to a file, and tis file is then read to create the menu. Now, the first time this form is loaded, this change works great. However, when I load the form again and do the same thing, the menu items do not show up at all.

I don't know exactly what code is needed, but here is the stuff that actually changes the menu items.


Private Sub cmdClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClose.Click
Dim FriendsList As String = Application.StartupPath & "\friends.data"
Dim FriendsListFileStream As New System.IO.FileStream(FriendsList, IO.FileMode.Open)
Dim FriendsListReader As New System.IO.StreamReader(FriendsListFileStream)
Dim i As Integer = 0
Dim FriendsLine As String
MainForm.mnuNotifyFriends.MenuItems.Clear()
While i = 0
FriendsLine = FriendsListReader.ReadLine()
If FriendsLine = "" Then
' Nothing
Exit While
ElseIf FriendsLine <> "" Then
MainForm.mnuNotifyFriends.MenuItems.Add(FriendsLine)
End If
End While
FriendsListReader.Close()
FriendsListFileStream.Close()
Me.Close()
End Sub

linksanime2003
12-21-2004, 03:53 PM
If it helps out any, I think I know what is going on.

I kept on adding to the menu items without bringing up the context menu. I brought it up, and the last multiple changes were there and everything was fine. After I brought up the menu, and added/removed items again, the menu items would no longer show when I opened up the menu.

So really, I guess I need to find a way to like refresh or reload the notify icon and/or the context menu.

Any ideas?

(I tried using frmMain.Refresh, and it didn't work, unless there is more to it than that.)

Himo
12-22-2004, 01:30 AM
It's a known problem that .net Toolbars, webbrowsers and now context menus have a bit odd way of refreshing.
My way is to set the visibility false one statement and then set it back to true the next statement. I don't know if it works, but it does for me. :)

linksanime2003
12-22-2004, 02:46 PM
Thanks Himo. I didn't know that you could change visiblity on menu items. I tried doing the same thing, but with the actual notify icon.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum