## WindowWidth WindowHeight

Expand Messages
• WindowWidth WindowHeight We use them to assign the width and high of a window we going to created. After the creation of the window, suppose we resize the
Message 1 of 7 , Sep 5, 2012
WindowWidth WindowHeight We use them to assign the width and high of a window we going to created. After the creation of the window, suppose we resize the widow and we wants to know the new WindowWidth WindowHeight, we ask LB about the new value of these two special variables, unfortunately LB give us a wrong value. A value defers than the real one with varies magnitude depending on varies machines we use, so the compensating are useless.
But if we ask API functions we get the correct new values.
The example Resize.bas written by Carl has a clever designed GUI layout that makes this problem unnoticeable.
The following code demonstrate this problem, after you run the program resize the window to full screen then back to first size, and read the values printed on main win.

'code start ----
'NOMAINWIN
WindowWidth = 400 : WindowHeight = 500
UpperLeftX = 1
UpperLeftY = 1
struct Rect, x1 As Long, y1 As Long, x2 As Long, y2 As Long

Open "Resizing Problem" for Window as #main
#main "trapclose [quit]"
#main "font ms_sans_serif 10"
handle = hwnd(#main)

print "WindowWidth= "; WindowWidth, "WindowHeight= ";WindowHeight

[loop]
print #main, "resizehandler [wresized]"
input r\$
print
Wait

[wresized]
print "Width we going to use it from WindowWidth= ";WindowWidth
print "High we going to use it from WindowHeight= ";WindowHeight
print

CallDLL #user32, "GetWindowRect",handle as uLong,_
Rect As struct, result As Long
ulx = Rect.x1.struct: uly = Rect.y1.struct:_
lrx = Rect.x2.struct: lry = Rect.y2.struct
Wwidth = lrx - ulx: Wheight = lry - uly

print "Width we going to use it from API Width= ";Wwidth
print "High we going to use it from API High= ";Wheight
print

'print DisplayWidth
'print DisplayHeight

goto [loop]

[quit]
close #main
END
'code end ----

Regards
SARMED
• Interesting, but you don t normally reuse the WindowWidth and WindowHeight values since the Window is already open. I tried using API to minimize and restore
Message 2 of 7 , Sep 5, 2012
Interesting, but you don't normally reuse the WindowWidth and WindowHeight values since the Window is already open. I tried using API to minimize and restore the window and GetWindowRect but the variables are not changed so it has something to do with actually minimising or restoring the window. Not sure how useful a trick it is.

--- In libertybasic@yahoogroups.com, "Sarmed" <sarmednafi@...> wrote:
>
> WindowWidth WindowHeight We use them to assign the width and high of a window we going to created. After the creation of the window, suppose we resize the widow and we wants to know the new WindowWidth WindowHeight, we ask LB about the new value of these two special variables, unfortunately LB give us a wrong value. A value defers than the real one with varies magnitude depending on varies machines we use, so the compensating are useless.
> But if we ask API functions we get the correct new values.
> The example Resize.bas written by Carl has a clever designed GUI layout that makes this problem unnoticeable.
> The following code demonstrate this problem, after you run the program resize the window to full screen then back to first size, and read the values printed on main win.
>
>
> 'code start ----
> 'NOMAINWIN
> WindowWidth = 400 : WindowHeight = 500
> UpperLeftX = 1
> UpperLeftY = 1
> struct Rect, x1 As Long, y1 As Long, x2 As Long, y2 As Long
>
> Open "Resizing Problem" for Window as #main
> #main "trapclose [quit]"
> #main "font ms_sans_serif 10"
> handle = hwnd(#main)
>
> print "WindowWidth= "; WindowWidth, "WindowHeight= ";WindowHeight
>
> [loop]
> print #main, "resizehandler [wresized]"
> input r\$
> print
> Wait
>
> [wresized]
> print "Width we going to use it from WindowWidth= ";WindowWidth
> print "High we going to use it from WindowHeight= ";WindowHeight
> print
>
> CallDLL #user32, "GetWindowRect",handle as uLong,_
> Rect As struct, result As Long
> ulx = Rect.x1.struct: uly = Rect.y1.struct:_
> lrx = Rect.x2.struct: lry = Rect.y2.struct
> Wwidth = lrx - ulx: Wheight = lry - uly
>
> print "Width we going to use it from API Width= ";Wwidth
> print "High we going to use it from API High= ";Wheight
> print
>
> 'print DisplayWidth
> 'print DisplayHeight
>
> goto [loop]
>
> [quit]
> close #main
> END
> 'code end ----
>
> Regards
> SARMED
>
• ... Inside of the resize handler the values are currently client area sizes, since the controls are placed inside the client area. This can be checked with the
Message 3 of 7 , Sep 5, 2012
Am 05.09.2012 19:09, schrieb Sarmed:
> WindowWidth WindowHeight We use them to assign the width and high of a window we going to created. After the creation of the window, suppose we resize the widow and we wants to know the new WindowWidth WindowHeight, we ask LB about the new value of these two special variables, unfortunately LB give us a wrong value. A value defers than the real one with varies magnitude depending on varies machines we use, so the compensating are useless.
> But if we ask API functions we get the correct new values.
> The example Resize.bas written by Carl has a clever designed GUI layout that makes this problem unnoticeable.
> The following code demonstrate this problem, after you run the program resize the window to full screen then back to first size, and read the values printed on main win.
>

Inside of the resize handler the values are currently client area sizes,
since the controls are placed inside the client area.

This can be checked with the GetClientRect API function.

I have also moved the resize handler definition outside the loop and
replaced the loop with a simple wait.

'---code start (watch for line wraps)

WindowWidth = 400 : WindowHeight = 500
UpperLeftX = 1
UpperLeftY = 1
struct Rect, x1 As Long, y1 As Long, x2 As Long, y2 As Long

Open "Resizing Problem" for Window as #main
#main "trapclose [quit]"
#main "font ms_sans_serif 10"
print #main, "resizehandler [wresized]"

handle = hwnd(#main)

print "WindowWidth= "; WindowWidth, "WindowHeight= ";WindowHeight

[loop]
Wait

[wresized]
print "Width we going to use it from WindowWidth= ";WindowWidth
print "Hight we going to use it from WindowHeight= ";WindowHeight
print

CallDLL #user32, "GetWindowRect",handle as uLong,_
Rect As struct, result As Long
ulx = Rect.x1.struct: uly = Rect.y1.struct:_
lrx = Rect.x2.struct: lry = Rect.y2.struct
Wwidth = lrx - ulx: Wheight = lry - uly

print "Width we going to use it from API Width= ";Wwidth
print "Hight we going to use it from API High= ";Wheight
print

CallDLL #user32, "GetClientRect",handle as uLong,_
Rect As struct, result As Long
ulx = Rect.x1.struct: uly = Rect.y1.struct:_
lrx = Rect.x2.struct: lry = Rect.y2.struct
Cwidth = lrx - ulx: Cheight = lry - uly

print "Client width we going to use it from API Width= ";Cwidth
print "Client hight we going to use it from API High= ";Cheight
print

wait

[quit]
close #main
END

'---code end

--
Stefan Pendl
http://stefanpendl.runbasichosting.com/

LB 4.04 Pro ... http://www.libertybasic.com/assist.html
LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

LB Community Wiki .............. http://basic.wikispaces.com/
LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

Books at http://www.lulu.com/ and http://www.amazon.com/
Alyce Watson ... APIs for Liberty BASIC
Carl Gundel .... Beginning Programming with Liberty BASIC

Windows 7 Home Premium 64-bit SP1
AMD Turion X2 RM-70 2GHz, 4GB RAM
• Hello Rod, Thanks for your replay, nearly I will post a modified Greens code book, and all this comes when I tried to make controls locates in it s new
Message 4 of 7 , Sep 5, 2012
Hello Rod,

Thanks for your replay, nearly I will post a modified Greens code book, and all this comes when I tried to make controls locates in it's new positions. The new code book can deal with pictures (not inside text box). I think it will be useful for you as you wrote articles with pictures.

Regards

________________________________
From: Rod <rodbird@...>
To: libertybasic@yahoogroups.com
Sent: Wednesday, September 5, 2012 10:14 PM
Subject: [libertybasic] Re: WindowWidth WindowHeight

Interesting, but you don't normally reuse the WindowWidth and WindowHeight values since the Window is already open. I tried using API to minimize and restore the window and GetWindowRect but the variables are not changed so it has something to do with actually minimising or restoring the window. Not sure how useful a trick it is.

--- In libertybasic@yahoogroups.com, "Sarmed" <sarmednafi@...> wrote:
>
> WindowWidth WindowHeight We use them to assign the width and high of a window we going to created. After the creation of the window, suppose we resize the widow and we wants to know the new WindowWidth WindowHeight, we ask LB about the new value of these two special variables, unfortunately LB give us a wrong value. A value defers than the real one with varies magnitude depending on varies machines we use, so the compensating are useless.
> But if we ask API functions we get the correct new values.
> The example Resize.bas written by Carl has a clever designed GUI layout that makes this problem unnoticeable.
> The following code demonstrate this problem, after you run the program resize the window to full screen then back to first size, and read the values printed on main win.
>
>
> 'code start ----
> 'NOMAINWIN
> WindowWidth = 400 : WindowHeight = 500
> UpperLeftX = 1
> UpperLeftY = 1
> struct Rect, x1 As Long, y1 As Long, x2 As Long, y2 As Long
>
> Open "Resizing Problem" for Window as #main
> #main "trapclose [quit]"
> #main "font ms_sans_serif 10"
> handle = hwnd(#main)
>
> print "WindowWidth= "; WindowWidth, "WindowHeight= ";WindowHeight
>
> [loop]
> print #main, "resizehandler [wresized]"
> input r\$
> print
> Wait
>
> [wresized]
> print "Width we going to use it from WindowWidth= ";WindowWidth
> print "High we going to use it from WindowHeight= ";WindowHeight
> print
>
> CallDLL #user32, "GetWindowRect",handle as uLong,_
> Rect As struct, result As Long
> ulx = Rect.x1.struct: uly = Rect.y1.struct:_
> lrx = Rect.x2.struct: lry = Rect.y2.struct
> Wwidth = lrx - ulx: Wheight = lry - uly
>
> print "Width we going to use it from API Width= ";Wwidth
> print "High we going to use it from API High= ";Wheight
> print
>
> 'print DisplayWidth
> 'print DisplayHeight
>
> goto [loop]
>
> [quit]
> close #main
> END
> 'code end ----
>
> Regards
> SARMED
>

[Non-text portions of this message have been removed]
• ... Sir, Your upper sentence means, WindowWidth WindowHeight could carry two values, the first is the first assigned value when I asked from outside resize
Message 5 of 7 , Sep 5, 2012
> Inside of the resize handler the values are currently client area sizes,

Sir,
Your upper sentence means, WindowWidth WindowHeight could carry two values, the first is the first assigned value when I asked from outside resize handler. The second is a client area value if I asked from inside resize handler.
Yes I do an experiment with resize.bas. What a pity, why then who wrote resize.bas don't take the value from outside resize handler? He took them from inside resize handler, so if we resize the window a little in width direction, the upper ends of controls jumps up some distance.
It must be a note for that in help file, to eliminates a weeks of misunderstood.

Thank you Stefan.
Sarmed

________________________________
From: Stefan Pendl <pendl2megabit@...>
To: libertybasic@yahoogroups.com
Sent: Thursday, September 6, 2012 1:13 AM
Subject: Re: [libertybasic] WindowWidth WindowHeight

Am 05.09.2012 19:09, schrieb Sarmed:
> WindowWidth WindowHeight We use them to assign the width and high of a window we going to created. After the creation of the window, suppose we resize the widow and we wants to know the new WindowWidth WindowHeight, we ask LB about the new value of these two special variables, unfortunately LB give us a wrong value. A value defers than the real one with varies magnitude depending on varies machines we use, so the compensating are useless.
> But if we ask API functions we get the correct new values.
> The example Resize.bas written by Carl has a clever designed GUI layout that makes this problem unnoticeable.
> The following code demonstrate this problem, after you run the program resize the window to full screen then back to first size, and read the values printed on main win.
>

Inside of the resize handler the values are currently client area sizes,
since the controls are placed inside the client area.

This can be checked with the GetClientRect API function.

I have also moved the resize handler definition outside the loop and
replaced the loop with a simple wait.

'---code start (watch for line wraps)

WindowWidth = 400 : WindowHeight = 500
UpperLeftX = 1
UpperLeftY = 1
struct Rect, x1 As Long, y1 As Long, x2 As Long, y2 As Long

Open "Resizing Problem" for Window as #main
#main "trapclose [quit]"
#main "font ms_sans_serif 10"
print #main, "resizehandler [wresized]"

handle = hwnd(#main)

print "WindowWidth= "; WindowWidth, "WindowHeight= ";WindowHeight

[loop]
Wait

[wresized]
print "Width we going to use it from WindowWidth= ";WindowWidth
print "Hight we going to use it from WindowHeight= ";WindowHeight
print

CallDLL #user32, "GetWindowRect",handle as uLong,_
Rect As struct, result As Long
ulx = Rect.x1.struct: uly = Rect.y1.struct:_
lrx = Rect.x2.struct: lry = Rect.y2.struct
Wwidth = lrx - ulx: Wheight = lry - uly

print "Width we going to use it from API Width= ";Wwidth
print "Hight we going to use it from API High= ";Wheight
print

CallDLL #user32, "GetClientRect",handle as uLong,_
Rect As struct, result As Long
ulx = Rect.x1.struct: uly = Rect.y1.struct:_
lrx = Rect.x2.struct: lry = Rect.y2.struct
Cwidth = lrx - ulx: Cheight = lry - uly

print "Client width we going to use it from API Width= ";Cwidth
print "Client hight we going to use it from API High= ";Cheight
print

wait

[quit]
close #main
END

'---code end

--
Stefan Pendl
http://stefanpendl.runbasichosting.com/

LB 4.04 Pro ... http://www.libertybasic.com/assist.html
LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

LB Community Wiki .............. http://basic.wikispaces.com/
LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

Books at http://www.lulu.com/ and http://www.amazon.com/
Alyce Watson ... APIs for Liberty BASIC
Carl Gundel .... Beginning Programming with Liberty BASIC

Windows 7 Home Premium 64-bit SP1
AMD Turion X2 RM-70 2GHz, 4GB RAM

[Non-text portions of this message have been removed]
• What a door opened! That s means it s better at the beginning after we assigned  WindowWidth WindowHeight for a window, it s better to make a (CallDLL
Message 6 of 7 , Sep 6, 2012
What a door opened!

That's means it's better at the beginning after we assigned  WindowWidth WindowHeight for a window, it's better to make a (CallDLL #user32, "GetClientRect",) then we locates our controls according to values which comes from that call, in that way the locate command will works perfect whatever operating system we use XP or Win7, without the needs to find out what OS we use, or a call to system preferences.
Is this speak correct?
Thank you.

________________________________
From: Sarmed N. <sarmednafi@...>
To: "libertybasic@yahoogroups.com" <libertybasic@yahoogroups.com>
Sent: Thursday, September 6, 2012 9:46 AM
Subject: Re: [libertybasic] WindowWidth WindowHeight

> Inside of the resize handler the values are currently client area sizes,

Sir,
Your upper sentence means, WindowWidth WindowHeight could carry two values, the first is the first assigned value when I asked from outside resize handler. The second is a client area value if I asked from inside resize handler.
Yes I do an experiment with resize.bas. What a pity, why then who wrote resize.bas don't take the value from outside resize handler? He took them from inside resize handler, so if we resize the window a little in width direction, the upper ends of controls jumps up some distance.
It must be a note for that in help file, to eliminates a weeks of misunderstood.

Thank you Stefan.
Sarmed

________________________________
From: Stefan Pendl <pendl2megabit@...>
To: libertybasic@yahoogroups.com
Sent: Thursday, September 6, 2012 1:13 AM
Subject: Re: [libertybasic] WindowWidth WindowHeight

Am 05.09.2012 19:09, schrieb Sarmed:
> WindowWidth WindowHeight We use them to assign the width and high of a window we going to created. After the creation of the window, suppose we resize the widow and we wants to know the new WindowWidth WindowHeight, we ask LB about the new value of these two special variables, unfortunately LB give us a wrong value. A value defers than the real one with varies magnitude depending on varies machines we use, so the compensating are useless.
> But if we ask API functions we get the correct new values.
> The example Resize.bas written by Carl has a clever designed GUI layout that makes this problem unnoticeable.
> The following code demonstrate this problem, after you run the program resize the window to full screen then back to first size, and read the values printed on main win.
>

Inside of the resize handler the values are currently client area sizes,
since the controls are placed inside the client area.

This can be checked with the GetClientRect API function.

I have also moved the resize handler definition outside the loop and
replaced the loop with a simple wait.

'---code start (watch for line wraps)

WindowWidth = 400 : WindowHeight = 500
UpperLeftX = 1
UpperLeftY = 1
struct Rect, x1 As Long, y1 As Long, x2 As Long, y2 As Long

Open "Resizing Problem" for Window as #main
#main "trapclose [quit]"
#main "font ms_sans_serif 10"
print #main, "resizehandler [wresized]"

handle = hwnd(#main)

print "WindowWidth= "; WindowWidth, "WindowHeight= ";WindowHeight

[loop]
Wait

[wresized]
print "Width we going to use it from WindowWidth= ";WindowWidth
print "Hight we going to use it from WindowHeight= ";WindowHeight
print

CallDLL #user32, "GetWindowRect",handle as uLong,_
Rect As struct, result As Long
ulx = Rect.x1.struct: uly = Rect.y1.struct:_
lrx = Rect.x2.struct: lry = Rect.y2.struct
Wwidth = lrx - ulx: Wheight = lry - uly

print "Width we going to use it from API Width= ";Wwidth
print "Hight we going to use it from API High= ";Wheight
print

CallDLL #user32, "GetClientRect",handle as uLong,_
Rect As struct, result As Long
ulx = Rect.x1.struct: uly = Rect.y1.struct:_
lrx = Rect.x2.struct: lry = Rect.y2.struct
Cwidth = lrx - ulx: Cheight = lry - uly

print "Client width we going to use it from API Width= ";Cwidth
print "Client hight we going to use it from API High= ";Cheight
print

wait

[quit]
close #main
END

'---code end

--
Stefan Pendl
http://stefanpendl.runbasichosting.com/

LB 4.04 Pro ... http://www.libertybasic.com/assist.html
LB 4.04 ....... http://www.libertybasic.com/lb404setup.exe

LB Community Wiki .............. http://basic.wikispaces.com/
LB Programmer's Encyclopedia ... http://lbpe.wikispaces.com/
LB Bug Tracker ................. http://libertybasicbugs.wikispaces.com/

Books at http://www.lulu.com/ and http://www.amazon.com/
Alyce Watson ... APIs for Liberty BASIC
Carl Gundel .... Beginning Programming with Liberty BASIC

Windows 7 Home Premium 64-bit SP1
AMD Turion X2 RM-70 2GHz, 4GB RAM

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]
• Sorry for that, The previous conclusions are not correct WindowWidth WindowHeight carry only the entire client area. The controls jump, that seems in
Message 7 of 7 , Sep 6, 2012
Sorry for that,
The previous conclusions are not correct WindowWidth WindowHeight carry only the entire client area.
The controls jump, that seems in resize.bas after a little enlarge the window in width direction is not understandable yet.
The experiment which I did with resize.bas after I read the variables from outside resize handle, there was no resizing happened, I don't notice that because I don't enlarge the window very much.
Actually it's good news, I don't need to throw away my code book work.
Thanks to all who listen and presents help, many thanks to Green who invents code book.

> That's means it's better at the beginning after we assigned Â WindowWidth WindowHeight for a window, it's better to make a (CallDLL #user32, "GetClientRect",) then we locates our controls according to values which comes from that call, in that way the locate command will works perfect whatever operating system we use XP or Win7, without the needs to find out what OS we use, or a call to system preferences.
> Is this speak correct?
> Thank you.Â
>
>
>
>

> Sir,
> Your upper sentence means, WindowWidth WindowHeight could carry two values, the first is the first assigned value when I asked from outside resize handler. The second is a client area value if I asked from inside resize handler.
> Yes I do an experiment with resize.bas. What a pity, why then who wrote resize.bas don't take the value from outside resize handler? He took them from inside resize handler, so if we resize the window a little in width direction, the upper ends of controls jumps up some distance.
> It must be a note for that in help file, to eliminates a weeks of misunderstood.Â
>
> Thank you Stefan.
> Sarmed
>
Your message has been successfully submitted and would be delivered to recipients shortly.