Hello everyone
We're trying to show animated window icons in our game. The animation flickers... When debugging this I noticed a bug in the code when setting a new icon. In WindowsDisplay.java, function setIcon():
freeSmallIcon();
small_icon = createIcon(small_icon_size, small_icon_size, icon.asIntBuffer());
sendMessage(hwnd, WM_SETICON, ICON_SMALL, small_icon);
As you can see it first calls freeSmallIcon() (or freeLargeIcon()) before setting the new icon. This function in the end calls DestroyIcon. The documentation of this function (http://msdn.microsoft.com/en-us/library/ms648063(VS.85).aspx) states that "The icon must not be in use.".
Ideally the code should therefore be written like this
long new_icon = createIcon(small_icon_size, small_icon_size, icon.asIntBuffer());
sendMessage(hwnd, WM_SETICON, ICON_SMALL, new_icon);
freeSmallIcon();
small_icon = new_icon;
and similarily for large_icon a few lines below.
Cheers,
Simon