Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Icon handling in b153

May
12,845
164
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"
 
vefatica wrote:

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

> On Thu, 06 Nov 2008 22:32:09 -0600, "JP Software Forums" <[email protected]>,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
 
On Fri, 07 Nov 2008 06:52:49 -0600, "JP Software Forums" <[email protected]>,rconn
<> wrote:


>---Quote---
>> On Thu, 06 Nov 2008 22:32:09 -0600, "JP Software Forums" <[email protected]>,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.
 
<[email protected]>

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
</[email protected]>
<[email protected]>HICON hOldIcon = GetConsoleIcon(); // with WM_GETICON</[email protected]>
<[email protected]>SetConsoleIcon(hMyIcon);</[email protected]>
<[email protected]></[email protected]>​
<[email protected]>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.



</[email protected]>
 
I said:

Experiment shows that after
<[email protected]>HICON hOldIcon = GetConsoleIcon(); // with WM_GETICON</[email protected]>
<[email protected]>SetConsoleIcon(hMyIcon);</[email protected]>
<[email protected]></[email protected]>​
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;
}
 
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.

<[email protected]></[email protected]><[email protected]></[email protected]><[email protected]></[email protected]>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;
}
 

Similar threads

Back
Top