My application is in C # 3.5, Winforms, but this will most likely require P / Invoke, so this is not so strictly related to .NET.
I created user-created menu items through the ContextMenuand classes MenuItem. Everything works well, but for some elements I would like to create a little animation (showing that there is a process associated with the element). Unfortunately, the above two classes do not provide a method Invalidate()or something like that.
My best idea so far is to P / Invoke WindowFromDC()in the first OnDraw, save the resulting descriptor, and then periodically call InvalidateRect()on the descriptor until the menu is closed.
These seem to be hacks, although I haven't tried it yet and am wondering if there is a more elegant way.
source
share