1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Icon handling in b153

Discussion in 'Support' started by vefatica, Nov 6, 2008.

  1. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    When issued in a TCC console (or batch file), this command,

    TYPE http://weather.noaa.gov/weather/current/KSYR.html | GREPP /V "^ *$" > avetemp.txt

    causes the console icon to change to the default (CMD) icon and stay there. GREPP in a plugin command and I assure you it doesn't mess with any icons.

    In fact, this command does the same thing:

    echo foo | ffind /t"foo"
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,729
    Likes Received:
    80
    vefatica wrote:

    The change in 153 was the one you requested to have TCC set its icon
    back to the default when it exits. If you pipe to a child TCC process,
    it will reset the icon when the child exits.

    Rex Conn
    JP Software
     
  3. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    On Thu, 06 Nov 2008 22:32:09 -0600, "JP Software Forums" <neil@jpsoft.com>,rconn
    <> wrote:


    My suggestion was to, at exit time, reinstate (if possible) the icon found in
    the console at startup time. I don't think I mentioned the default console icon
    at all. TCC not displaying its icon is unacceptable. If you can't get it to
    restore the previous icon, then please leave the TCC icon.
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,729
    Likes Received:
    80
    vefatica wrote:

    TCC does not restore the default console icon, it restores the icon
    originally set (by Windows) for TCC at startup.

    Rex Conn
    JP Software
     
  5. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    On Fri, 07 Nov 2008 06:52:49 -0600, "JP Software Forums" <neil@jpsoft.com>,rconn
    <> wrote:


    Whatever the explanation, please return to the (long-time) behavior where the
    TCC icon always shows in the console when TCC is the only app running in the
    console.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    The recent change does not seem to have fixed anything. I don't have TSE, but in my experiments with k95.exe, after shelling to TCC and returning to K95, the K95 icon still fails to reappear. Now, instead of the TCC icon remaining, the default console icon remains (no better IMHO, worse considering that when the parent is TCC, it actually removes its own icon).

    Experiment shows that after
    </neil@jpsoft.com>
    <neil@jpsoft.com>HICON hOldIcon = GetConsoleIcon(); // with WM_GETICON</neil@jpsoft.com>
    <neil@jpsoft.com>SetConsoleIcon(hMyIcon);</neil@jpsoft.com>
    <neil@jpsoft.com></neil@jpsoft.com>​
    <neil@jpsoft.com>hOldIcon is invalid (SetConsoleIcon(hOldIcon) = 87). (hOldIcon *is* valid before the SetConsoleIcon().)

    So it would seem unreasonable to expect an app to restore another app's console icon after setting its own. It seems quite reasonable that each app be responsible for ensuring that its icon appears when appropriate. If a parent app doesn't re-set its own icon after a spawned app in the same console exits that's the parent's problem.



    </neil@jpsoft.com>
     
  7. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    I said:

    Experiment shows that after
    <neil@jpsoft.com>HICON hOldIcon = GetConsoleIcon(); // with WM_GETICON</neil@jpsoft.com>
    <neil@jpsoft.com>SetConsoleIcon(hMyIcon);</neil@jpsoft.com>
    <neil@jpsoft.com></neil@jpsoft.com>​
    hOldIcon is invalid (SetConsoleIcon(hOldIcon) = 87). (hOldIcon *is* valid before the SetConsoleIcon().)

    So it would seem unreasonable to expect an app to restore another app's console icon after setting its own.

    But the strategy apparently works if I get my own duplicate handle to the one I want to later restore. The little test app below, when run from TCC, sets the console icon to the default and then re-instates TCC's icon.

    INT wmain ( INT argc, WCHAR **argv ) {
    HICON hOldIcon = GetConsoleIcon(); // uses WM_GETICON
    HICON hMyOldIcon = DuplicateIcon(0, hOldIcon);

    DWORD (STDAPICALLTYPE * SetConsoleIcon) ( HICON );
    HMODULE hLib = GetModuleHandle(L"kernel32.dll");
    (FARPROC&) SetConsoleIcon = GetProcAddress(hLib, "SetConsoleIcon");

    // sets the icon to the default and apparently closes hOldIcon
    SetConsoleIcon(NULL);
    Sleep(5000);

    // this works to restore TCC's icon
    // without it TCC's icon is not restored at exit
    SetConsoleIcon(hMyOldIcon);
    Sleep(5000);
    return 0;
    }
     
  8. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,784
    Likes Received:
    29
    A couple notes: CopyIcon() seems to work as well as DuplicateIcon(). If you're using WM_GETICON to get the console icon when TCC starts, ICON_SMALL rarely works (don't know why). ICON_BIG and ICON_SMALL2 have worked in all my tests.

     

Share This Page