Adjusting width, height of a window. Getting window border size

Problem

Problem:
I need to open window of special working (drawing space) size. Say, 400x300 pixels.

so I went on and say
WindowWidth = 400
WindowHeight = 300
open "testGr" for graphics_nsb as #gr
- just to find then well, there space for window title and borders hidden in 400, 300.
Of course I can find that space (by trial and error)...
but it's prone to errors AND! could be different on another machine (or if you switch Classic style /XP style).

So here is a way to do it:
we first open smaller window, say 200x100
get working size
then use that difference from 200x100 to open window of the size we actually need.

It does work for me, I tested with switching Classic style /XP style.

Demo

' this code demonstrates adjusting window height, width to get desired drawing space (like, 400x300)
    UpperLeftX = 20
    UpperLeftY = 20
    WindowWidth = 200   '100 seems to be too much - works different
    WindowHeight = 100
    open "Ajusting..." for graphics_nsb as #gr
'   graphics
'   graphics_nsb
'   graphics_nsb_nf
    #gr, "home ; down ; posxy x y"
    'x, y give us width, height
    width = 2*x : height = 2*y
    close #gr
 
    slackX = 200-width
    slackY = 100-height
 
    desiredWidth = 400
    desiredHeight = 300
    WindowWidth = desiredWidth + slackX
    WindowHeight = desiredHeight + slackY
    open "testGr" for graphics_nsb as #gr
    #gr, "trapclose [quit]"
    #gr, "home ; down ; posxy x y"
    'x, y give us width, height
    width = 2*x : height = 2*y
 
    'testing
    print "Desired window width, height: ", desiredWidth, desiredHeight
    print "Slack by X, by Y: ", slackX, slackY
    print "Requested from windows, width, height: ", WindowWidth, WindowHeight
    print "Got active width, height: ", width, height
 
    #gr, "color red"
    #gr, "place 0 0"
    #gr, "box ";width;" "; height
    #gr, "line 0 0 ";width;" "; height
    wait
 
[quit]
    close #gr
    end

Getting window border size

In the demo, slackX, slackY is space used by borders and title-bar (and menu if you'll have one).
You can count that border width is around slackX/2, and title-bar (with menu, if you'll have one) is around slackY-slackX/2.
This info could be used to precisely position components in a window, or with ResizeHandler example to move / resize components.
It's approximation - we measure on a graphic window but may apply it to ordinary window - but works fairly well.

You can write really short sub and call it then needed.
Just make sure that if your main window has menu, measuring window has it as well.

[getSlackWithMenu]
    WindowWidth=200:WindowHeight=200
    menu #t, "X"
    open "" for graphics_nsb as #t:#t,"home;posxy x y":close#t
    slackX=WindowWidth-2*x:slackY=WindowHeight-2*y
return
 
[getSlack]
    WindowWidth=200:WindowHeight=200
    open "" for graphics_nsb as #t:#t,"home;posxy x y":close#t
    slackX=WindowWidth-2*x:slackY=WindowHeight-2*y
return