LB Booster
Programming >> Liberty BASIC language >> Size of graphics box?
http://lbb.conforums.com/index.cgi?board=lblang&action=display&num=1436536169

Size of graphics box?
Post by Monkfish on Jul 10th, 2015, 1:49pm

Hi again

I am opening a window with the following command:

open "Window" for dialog as #main

I am setting the size with the WindowWidth & WindowHeight variables.

I am also setting a graphics box to the same size using:

graphicbox #main.gfx, 0, 0, WindowWidth, WindowHeight

Does that mean that the displayed graphics box will actually be slightly smaller than WindowWidth & WindowHeight because they include the window borders as well? Do I need to use something like:

graphicbox #main.gfx, 0, 0, WindowWidth-6, WindowHeight-6

to fit the graphics box inside the window frame?

Re: Size of graphics box?
Post by Richard Russell on Jul 10th, 2015, 3:54pm

on Jul 10th, 2015, 1:49pm, Monkfish wrote:
I am also setting a graphics box to the same size

Not answering your question, but why are you filling an entire dialog window with a graphicbox? The only thing I can immediately think of is that perhaps you are sometimes hiding the graphicbox to reveal the dialog behind. If it's not that, what do you achieve that opening a simple graphics window doesn't:

Code:
open "Window" for graphics as #main 

But to get back to the question, one of the weaknesses of LB (which is not addressed in LBB) is that WindowWidth and WindowHeight control not the size of the client area, which would almost certainly be more useful, but the size of the entire window (including the 'non-client' furniture).

This can be quite a problem, not least because the thickness of the borders and title bar can depend on the version of Windows and the currently-selected theme, so precise positioning and sizing of windows/controls becomes virtually impossible if you want it to work across a range of different platforms.

Things are made even worse if you use the RESIZEHANDLER command because then WindowWidth and WindowHeight are perversely set to the client dimensions of the window!

Quote:
Do I need to use something like:
graphicbox #main.gfx, 0, 0, WindowWidth-6, WindowHeight-6
to fit the graphics box inside the window frame?

If you want it to work 'properly' in all circumstances I would recommend using an API call (GetClientRect) to discover the size of the 'container' window's client area and then use LOCATE to change the size of the graphicbox to suit.

Richard.
Re: Size of graphics box?
Post by Monkfish on Jul 15th, 2015, 1:16pm

Quote:
But to get back to the question, one of the weaknesses of LB (which is not addressed in LBB) is that WindowWidth and WindowHeight control not the size of the client area, which would almost certainly be more useful, but the size of the entire window (including the 'non-client' furniture).


Thanks Richard. That answers my question. I have also now discovered that the height of the entire window is different under XP and later versions of Windows, which is a bit annoying. Doesn't really matter in my case.

BTW, I wasn't actually filling the entire window with a graphics box, I was leaving room at the top for some buttons. I omitted this small fact as it wasn't relevant to my question. smiley

Thanks again smiley
smiley smiley
Re: Size of graphics box?
Post by Richard Russell on Jul 15th, 2015, 3:59pm

on Jul 15th, 2015, 1:16pm, Monkfish wrote:
BTW, I wasn't actually filling the entire window with a graphics box, I was leaving room at the top for some buttons.

You can still use open "" for graphics... since it's legitimate to put buttons and other child controls on a graphics window (unofficially in LB 4.04, although it seems to work, but officially in LBB).

Richard.