Icon handling in b153

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

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#2
vefatica wrote:

> When issued in a TCC console (or batch file), this command,
>
> TYPE [URL='http://weather.noaa.gov/weath...://weather.noaa.gov/weather/current/KSYR.html[/URL] | 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"
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
On Thu, 06 Nov 2008 22:32:09 -0600, "JP Software Forums" <neil@jpsoft.com>,rconn
<> wrote:


>> echo foo | ffind /t"foo"
>---End Quote---
>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.
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.
 

rconn

Administrator
Staff member
May 14, 2008
10,100
85
#4
vefatica wrote:

> On Thu, 06 Nov 2008 22:32:09 -0600, "JP Software Forums" <neil@jpsoft.com>,rconn
> <> wrote:
>
>
>
> ---Quote---
>>> echo foo | ffind /t"foo"
>> ---End Quote---
>> 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.
> ---End Quote---
> 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.
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
On Fri, 07 Nov 2008 06:52:49 -0600, "JP Software Forums" <neil@jpsoft.com>,rconn
<> wrote:


>---Quote---
>> On Thu, 06 Nov 2008 22:32:09 -0600, "JP Software Forums" <neil@jpsoft.com>,rconn
>> <> wrote:
>>
>>
>>
>> ---Quote---
>>>> echo foo | ffind /t"foo"
>>> ---End Quote---
>>> 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.
>> ---End Quote---
>> 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.
>---End Quote---
>TCC does not restore the default console icon, it restores the icon
>originally set (by Windows) for TCC at startup.
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
<neil@jpsoft.com>

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.
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
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
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.

<neil@jpsoft.com></neil@jpsoft.com><neil@jpsoft.com></neil@jpsoft.com><neil@jpsoft.com></neil@jpsoft.com>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;
}