Icon weirdness

May 20, 2008
Syracuse, NY, USA
My plugin does this in InitializePlugin():

pnid->hIcon = (HICON) SendMessage(hWndConsole, WM_GETICON, ICON_SMALL2, NULL);

My plugin command later opens a dialog box and does:

SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) pnid->hIcon);

Those are the only two times pnid->hIcon is mentioned in my code.

It works once; both the dialog and its tray minimization have the TCC icon. The second time my command is run, the dialog box gets a default icon, the tray gets no icon, and the console's icon reverts to the default CMD icon.

At first I thought the dialog box was closing the HICON (the console's icon) but that's not the case because the HANDLE will last indefinitely if I get it with LoadImage(). Rex, do you know what's going on?