_wintctitle variable

May 20, 2008
450
2
#1
I could use 'window top' before getting the title of the TCMD window from _winfgwindow, but I would like to be able to use the activate command to resize the TCMD window without bringing it to the front. Having a _wintctitle variable with the title of the TCMD window would allow for that.
 
#2
I could use 'window top' before getting the title of the TCMD window from _winfgwindow, but I would like to be able to use the activate command to resize the TCMD window without bringing it to the front. Having a _wintctitle variable with the title of the TCMD window would allow for that.
I'm tempted to try that in a plugin (say _TCHOSTWIN) but I don't have a vision of exactly how it should work or how it could be done. What if TCC is not in a TCMD tab or more than one TCMD exist? If TCC is in a TCMD tab (easy to detect with _TCTAB) there's no guarantee that TCMD is TCC's parent process so it's not clear how to get from knowing TCC is in a tab to the title of its host TCMD's main window. Any ideas? I'll see if TakeCpmmandIPC() can be of any value.
 
#3
TakeCommandIPC() turned out to be just what was needed. I have this (below); commments are welcome.

In a standalone TCC ...
Code:
v:\> help _TCHOSTWIN
Title of TCMD host's main window
 
v:\> echo %_tchostwin
-1
In a TCMD tab ...
Code:
v:\> echo %_wintitle
14.02  [336]  v:\

v:\> echo %_tchostwin
TC 14.0 - 14.02  [336]  v:\
It works like this.
Code:
INT WINAPI _TCHOSTWIN ( WCHAR *psz )
{
    HWND hWndTCMD;
    Sprintf(psz, L"-1");
    WCHAR szBuffer[32] = L"%_TCTAB";
    ExpandVariables(szBuffer, 1);
    if ( szBuffer[0] == L'1'
            && TakeCommandIPC(L"HWND", szBuffer) == 0
            && (hWndTCMD = (HWND) wcstoul(szBuffer, NULL, 10)) != NULL )
        GetWindowText(hWndTCMD, psz, 4096);
    return 0;
}
 
May 20, 2008
450
2
#4
Would something like this work to move/resize the parent TCMD window?

C:\>activate "%_tchostwin" /POS=...

This is a variable I would like to have built in. My reason for wanting this is the switching of my laptop between the built-in screen and when using an attached 24" LCD. When I start up TCMD using one or the other, I would like to detect screen size and move/resize TCMD to fit that visible area. With multiple apps starting together, even calling window top immediately before getting _winfgwindow can sometimes get the name of another app. The last time, when my start.btm ran, it resized my Lotus Notes window instead, not quite what I wanted. ;)

Tim
 
#5
Would something like this work to move/resize the parent TCMD window?

C:\>activate "%_tchostwin" /POS=...

This is a variable I would like to have built in. My reason for wanting this is the switching of my laptop between the built-in screen and when using an attached 24" LCD. When I start up TCMD using one or the other, I would like to detect screen size and move/resize TCMD to fit that visible area. With multiple apps starting together, even calling window top immediately before getting _winfgwindow can sometimes get the name of another app. The last time, when my start.btm ran, it resized my Lotus Notes window instead, not quite what I wanted. ;)

Tim
That ought to work (it works here). If you want to try it, I uploaded new 4UTILS plugins to ftp://lucky.syr.edu/4plugins/

It was easy enough to do. Rex might include it in a future version.

You might even be able to make a user-defined function, say %TCHOSTWIN[], using @WINAPI[] and the functions TakeCommandIPC() (from TAKECMD.DLL) and GetWindowText() (from USER32.DLL).
 
May 20, 2008
450
2
#9
The @capi usage fails with incorrect function, though the @winapi usage of takecmd.dll worked fine. I did tweak the path location to be: %@path[%_cmdspec]takecmd.dll to make it a bit more generic.

Thanks again.
 
#10
The @capi usage fails with incorrect function, though the @winapi usage of takecmd.dll worked fine. I did tweak the path location to be: %@path[%_cmdspec]takecmd.dll to make it a bit more generic.

Thanks again.
Hmmm! @CAPI works here and it is the appropriate one. TakeCommandIPC is not a WINAPI function. Using the wrong one is likely to lead to corruption.