Context Menu Not Refreshing

G

Guest

I have a system tray icon for my application. Each time the user pastes some
text into the application, I add a submenu item in the system tray's context
menu. The first time I right-click the icon in the system tray, the submenu
item is there. After that, any subsequent right-clicks only show the same
menu that was displayed at the first right-click. In other words, it's as if
the menu is loaded into memory somewhere on the first right-click, and after
that, any changes made to the menu programatically, are not shown.

By stopping the code and checking the value of the submenu item's text after
I change it, I have found that the new values are accepted, but again, the
GUI just doesn't reflect the new values.

Here is the code where I add a submenu item. I start with all 5 submenu
items having .Text = "Empty". New items are added at the top of the list of
submenu items. If the number of items to be added is less than 5, the new
items are added, then the remaining items (to bring the total to 5) are added
with the value "Empty":

' Put the last 5 into the SysTray Icon's menu
For Index = 1 To 5
If Index <= gcolLastFiveAddrs.Count Then
MenuItem = gcolLastFiveAddrs(Index).Street & " " & _
gcolLastFiveAddrs(Index).City & " " & _
gcolLastFiveAddrs(Index).State & " " & _
gcolLastFiveAddrs(Index).Zip
Else
MenuItem = "Empty"
End If
SysTrayMenu.MenuItems.Item(5).MenuItems.Item(Index - 1).Text = _
CStr(Index) & ". " & MenuItem
SysTrayMenu.MenuItems.Item(6).MenuItems.Item(Index - 1).Text = _
CStr(Index) & ". " & MenuItem
Next
 
G

Guest

force the control me.refersh or repaint on the lowest level first the
control, then try the form .

Joe
 
G

Guest

I did Me.Refresh() but that didn't work.

How do I repaint?

Can I refresh the Context Menu somehow?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top