Icon weirdness

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
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:

case WM_INITDIALOG :
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?