I gave it a try and this trivial solution works for me (XP sp2):
void MyDocumentWindow::setIcon(const Image *imageToUse)
ComponentPeer *peer = getPeer();
This gives me consistent icons on Alt-Tab as well as the task bar - provided the window is on the desktop when the icon is set, and stays there.
A more general solution would need to cope with the situation where the peer is created after the icon was set.
Don’t rush for my sake, I’ve got a solution that works for me, but IMO this should be standard behaviour of DocumentWindow::setIcon() - having one icon on the title bar and another on the task bar is a thing to avoid.
I wonder if the problem with the windowing stuff you seem to remember could be related to one of the other platforms; on my XP it just works.