Window sizing

May 29, 2008
565
4
Groton, CT
What's the algorithm to calculate the width and height of a window as
required by the /POS option of the WINDOW command, given the desired size in
columns and rows?

Here's an excerpt from a working bat-file I have:
Code:
    set activepos=%@winpos[%activewindow]
    iff %_? eq 0 then
      set left=%@word[1,%activepos]
      set top=%@word[0,%activepos]
      set bottom=%@word[2,%activepos]
      set right=%@word[3,%activepos]
      set activepos=%left,%top,%@eval[%right - %left],%@eval[%bottom - %top]
     else
      unset /q activepos activewindow
     endiff
In this code, %activewindow is the name of some window. This code sets %activepos to the correct parameter string for later use in ACTIVATE
(which should be the same as in WINDOW).
 

rconn

Administrator
Staff member
May 14, 2008
12,312
147
Steve Fábián wrote:

> What's the algorithm to calculate the width and height of a window as
> required by the /POS option of the WINDOW command, given the desired size in
> columns and rows?

Multiply the rows & columns by your font size, and add the title bar.

Or (much, much simpler) just drag the window to the size you want.

Rex Conn
JP Software
 
May 20, 2008
3,515
4
Elkridge, MD, USA
dcantor wrote:
...
| In this code, %activewindow is the name of some window. This code
| sets %activepos to the correct parameter string for later use in
| ACTIVATE (which should be the same as in WINDOW).

Thanks, it helps to force a window back to an earlier size, but not to force
it to a specific width and height in terms of rows and columns, as you can
do by clicking on the upper left corner, and going to Properties ->
Layout -> Window size.
--
Steve
 
May 20, 2008
3,515
4
Elkridge, MD, USA
rconn wrote:
| Steve Fábián wrote:
|| What's the algorithm to calculate the width and height of a window
|| as required by the /POS option of the WINDOW command, given the
|| desired size in columns and rows?

| Multiply the rows & columns by your font size, and add the title bar.

I thougt the font size is the character pixel array size, but that there is
space between them both vertically and horizontally, for which I also need
to account. How about vertical and / or horizontal scroll bar size? Are they
included in the /POS design?

|
| Or (much, much simpler) just drag the window to the size you want.

That requires experimenting to have the correct size. Using the window's
system icon requires less experimenting, but neither can be done
programmatically, only the /POS can do it. Maybe a future version could
include a /WINSIZE=rows,columns option (keeping the upper left corner
immobile).
--
Steve
 

rconn

Administrator
Staff member
May 14, 2008
12,312
147
rconn wrote:
| Steve Fábián wrote:
|| What's the algorithm to calculate the width and height of a window
|| as required by the /POS option of the WINDOW command, given the
|| desired size in columns and rows?

| Multiply the rows & columns by your font size, and add the title bar.


> I thougt the font size is the character pixel array size, but that there
is

> space between them both vertically and horizontally, for which I also need


> to account. How about vertical and / or horizontal scroll bar size? Are
they

> included in the /POS design?

The font size includes the pixels above & below.

If you want to resize a TCC window in Take Command, it's vastly simpler to
drag it; you'll see the current size updated in the status bar. If you want
to resize a stand-alone TCC window, click on the icon on the title bar and
use the Windows console manager (which is going to be doing it anyway).

Rex Conn
JP Software
 
May 20, 2008
11,285
95
Syracuse, NY, USA
On Tue, 15 Sep 2009 20:27:57 -0500, Steve Fábián <> wrote:

|I thougt the font size is the character pixel array size, but that there is
|space between them both vertically and horizontally, for which I also need
|to account. How about vertical and / or horizontal scroll bar size? Are they
|included in the /POS design?

Font sizes are in pixels; so are window sizes. What's the problem. Where are
there spaces ... not between console characters.

If you want to get very technical (and accurate) the height is

FontHeight * rows + 2 * (SM_CYSIZEFRAME + SM_CYEDGE) + SM_CYCAPTION
[+ SM_CYHSCROLL]

and the width is

FontWidth * columns + 2 * (SM_CXSIZEFRAME + SM_CXEDGE) [+ SM_CXVSCROLL]

Those SM_* values can be gotten with @WINMETRICS. The parameter values for
@WINMETRICS (ultimately for GetSystemMetrics()) are:

CXSIZEFRAME 32
CXEDGE 45
CXVSCROLL 2

CYSIZEFRAME 33
CYEDGE 46
CYCAPTION 4
CYHSCROLL 3

Figure out if there are scroll bars by comparing screen buffer size and window
size, both in characters, horizontally and vertically).
--
- Vince
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Window sizing (help error)

On Tue, 15 Sep 2009 21:12:13 -0500, vefatica <> wrote:

The help has "2" erroneously described as "Width of arrow bitmap on horizontal
scroll bar". MS says:

SM_CXVSCROLL
2
The width of a vertical scroll bar, in pixels.

And "3" might be better described by, simply

SM_CYHSCROLL
3
The height of a horizontal scroll bar, in pixels.
--
- Vince
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Window sizing (help error)

On Tue, 15 Sep 2009 22:24:32 -0500, vefatica <> wrote:

And the @WINMETRICS help fails to document 45 and 46 (window "edge"), though
they work. They are necessary to get calculations to come out right.

Below is 2*(frame + edge) + fontw*columns + hscrollwidth (which is correct).

v:\> echo %@eval[2 * (%@winmetrics[32] + %@winmetrics[45]) + %_columns * %_fontw
+ %@winmetrics[2]]
668

v:\> echo %@winsize[*3352*]
331,668
--
- Vince
 
May 20, 2008
3,515
4
Elkridge, MD, USA
vefatica wrote:
| FontHeight * rows + 2 * (SM_CYSIZEFRAME + SM_CYEDGE) + SM_CYCAPTION
| [+ SM_CYHSCROLL]
|
| and the width is
|
| FontWidth * columns + 2 * (SM_CXSIZEFRAME + SM_CXEDGE) [+
| SM_CXVSCROLL]
|
| Those SM_* values can be gotten with @WINMETRICS. The parameter
| values for @WINMETRICS (ultimately for GetSystemMetrics()) are:
|
| CXSIZEFRAME 32
| CXEDGE 45
| CXVSCROLL 2
|
| CYSIZEFRAME 33
| CYEDGE 46
| CYCAPTION 4
| CYHSCROLL 3
|
| Figure out if there are scroll bars by comparing screen buffer size
| and window size, both in characters, horizontally and vertically).

Thanks, Vince. This is just what I was looking for.
--
Steve
 
May 20, 2008
3,515
4
Elkridge, MD, USA
rconn wrote:
| rconn wrote:
|| Steve Fábián wrote:
||| What's the algorithm to calculate the width and height of a window
||| as required by the /POS option of the WINDOW command, given the
||| desired size in columns and rows?
|
|| Multiply the rows & columns by your font size, and add the title
|| bar.
|
|
|
| ---Quote---
|| I thougt the font size is the character pixel array size, but that
|| there
| ---End Quote---
| is
|
|
| ---Quote---
|| space between them both vertically and horizontally, for which I
|| also need ---End Quote---
|
|
| ---Quote---
|| to account. How about vertical and / or horizontal scroll bar size?
|| Are
| ---End Quote---
| they
|
|
| ---Quote---
|| included in the /POS design?
| ---End Quote---
| The font size includes the pixels above & below.
|
| If you want to resize a TCC window in Take Command, it's vastly
| simpler to drag it; you'll see the current size updated in the
| status bar. If you want to resize a stand-alone TCC window, click
| on the icon on the title bar and use the Windows console manager
| (which is going to be doing it anyway).

The part in which you quoted my post came through horribly mangled,
but luckily your response came through legibly.

As usual, I am interested in stand-alone TCC window resizing. I am
particularly interested in a/ automatic resizing after screen
resolution change, and b/ sizing to specified size(s) regardless of
screen resolution programmatically (e.g., in a batch file).
--
Steve
 

rconn

Administrator
Staff member
May 14, 2008
12,312
147
Window sizing (help error)

> The help has "2" erroneously described as "Width of arrow bitmap on
> horizontal
> scroll bar". MS says:
>
> SM_CXVSCROLL
> 2
> The width of a vertical scroll bar, in pixels.
>
> And "3" might be better described by, simply
>
> SM_CYHSCROLL
> 3
> The height of a horizontal scroll bar, in pixels.

"Erroneously" may be a bit harsh, since the width of the scroll bar and the
width of the arrow bitmap are identical; and the help text was taken
directly from Microsoft's documentation. Apparently MS decided to document
it differently in different places -- where did you see the text you're
referring to?

Rex Conn
JP Software
 
May 20, 2008
11,285
95
Syracuse, NY, USA
Re: Window sizing (help error)

"Erroneously" may be a bit harsh, since the width of the scroll bar and the
width of the arrow bitmap are identical; and the help text was taken
directly from Microsoft's documentation. Apparently MS decided to document
it differently in different places -- where did you see the text you're
referring to?

The error is that the TCC help says (of "2") "horizontal"; it should be
"vertical". "21" is similarly wrong; it should be "arrow-width **horizontal**
[not vertical] scroll bar. To put it another way, TCC has them paired wrong. In
actuality, "2" is XV and "3" is YH, referring to the scroll bar itself; "20" is
YV and "21" is XH, referring to the mimimum button size.

My source is

ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/sysinfo/base/getsystemmetrics.htm

(also the first hit when searching MS for "GetSystemMetrics"
 
Similar threads
Thread starter Title Forum Replies Date
R History window wrong size, can't remember size change Support 12
R @select inside alias gives different (insanely small) window Support 7
K_Meinhard How to? Help window position Support 7
D Directory History Window with wildcard search Support 3
Dmitry L. Kobyakov Documentation Error in the Help: the WINDOW command Support 0
L LIST's pop-up search loses focus in a Windows Terminal window Support 15
ntak About window size notification Support 6
R Batch Debugger Command Expansion Window Support 3
R How do I get a Git Bash shell to appear in TCC window? Support 7
G Press on another Window Support 24
Peter Murschall IDE: After undocking the command expansion Window is offended Support 2
T TCC Window Background Color Anomaly Support 9
A v25 BC break in WINDOW and ACTIVATE Support 12
vefatica BTM, elevated, console window caption? Support 4
W Hide window Support 7
R How to? START program as top window? Support 2
P No linefeed on last line of console window Support 2
scottb How to? ipconfig output in current window Support 4
R How to? Change TCMD tab font size in window menu Support 3
T Fixed IDE locks up if edit window for running batch is closed Support 6
E How to change window title tcmd window - not tcc window Support 1
jaltman tcmd 21.0.19 win10 16179 console window loses content Support 2
B How to get window status of a running app Support 3
James Miller tcc shell window does not disappear Support 18
M Call History popup-window? Support 0
D How cut in TCC tab window Support 5
S Paste in TCC/TCMD window is very slow [v20.0.22] Support 13
C How to? Feed keys to firefox (Yahoo Mail) window Support 4
C How to? Feed keys to firefox (Yahoo Mail) window Support 0
C How to? run a BTM in elevated, inv tcc tab window Support 9
vefatica Ctrl-Enter in command history window? Support 8
D Take Command tab only uses half of window Support 1
CWBillow Power Shell in a TCMD window Support 5
vefatica TCC window caption in elevated session? Support 5
vefatica New File Explorer window Support 1
T 64 bit TCCLE appears to crash when opening tcc.exe from within tcc.exe window Support 7
D WAD TASKBAR window commands confuses our friends at MS Support 4
F EDIT FIELD in a popup window Support 2
samintz Flashing window Support 4
fpefpe How to? folder / explorer window Support 10
C Msg Popup window does not close Support 8
Jay Sage Failure of ACTIVATE to Set a Window Position Support 3
R Minor Cosmetic Issue in Take Command Window Support 2
D TCMD 17 window border and mouse cursor Support 10
rps Command Input Window tab completion broken Support 7
Charles Dye OPTION dialog appears underneath Take Command window Support 4
nickles activate "..." hide hides the foremost window Support 3
vefatica WAD Window title Support 13
mikea How to? @select[] window size, redux. Support 3
L WAD File-popup Window nearly empty Support 6

Similar threads