Welcome!

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

SignUp Now!

Window sizing

May
3,515
5
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?
 
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).
 
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
 
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
 
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 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
 
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
 
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
 
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
 
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
 
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
 
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
 
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"
 
Back
Top
[FOX] Ultimate Translator
Translate