LB Booster
« Should REFRESH update WindowWidth/Height? »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:29am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Should REFRESH update WindowWidth/Height?  (Read 316 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Should REFRESH update WindowWidth/Height?
« Thread started on: Aug 11th, 2017, 08:54am »

Over at the LB Community Forum, Rod has proposed that the REFRESH command should be modified to have the side-effect of updating the WindowWidth and WindowHeight variables to correspond to the window's Client Area (i.e. excluding the title bar and borders). The argument is that manually resizing the window has this effect anyway, and it would be useful to be able to force the update in code.

It would be easy enough to make this change in LBB (albeit that it would slow down REFRESH slightly) but I'm a little uneasy about Rod's claim that "It won't break anything". Although the LB docs suggest that REFRESH is only useful in a RESIZEHANDLER (in which case WindowWidth and WindowHeight will already have been changed) it's not impossible that some existing programs use it at different times and might be broken by these variables changing 'unexpectedly'.

What are people's feelings on the pros and cons of this proposed change? Of course if Carl is persuaded to change LB 4 that settles it, but if I lead the way with LBB I don't want to introduce an undesirable incompatibility.

Richard.
User IP Logged

RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx Re: Should REFRESH update WindowWidth/Height?
« Reply #1 on: Aug 11th, 2017, 7:27pm »

I don't use the Refresh statement in my program so changing how it works wouldn't matter to me.

But, I have always thought it was strange that it changes the values to the size of the client area instead of giving the new window sizes. If you are going to go your own direction with this perhaps you could introduce two new variables, ClientWidth and ClientHeight? That might be less confusing to users.
« Last Edit: Aug 11th, 2017, 7:29pm by RobM » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Should REFRESH update WindowWidth/Height?
« Reply #2 on: Aug 11th, 2017, 8:47pm »

on Aug 11th, 2017, 7:27pm, RobM wrote:
perhaps you could introduce two new variables, ClientWidth and ClientHeight? That might be less confusing to users.

But what about WindowWidth and WindowHeight? Many existing Liberty BASIC programs rely on their current behavior and any change would have unacceptable compatibility implications. On that basis I think the introduction of ClientWidth and ClientHeight variables could actually add to the confusion.

What Liberty BASIC should have done, from the start, is use WindowWidth and WindowHeight consistently to refer to the client size. Normally the programmer isn't interested in the overall window dimensions: by definition the non-client areas (title bar and borders) aren't the responsibility of the programmer, so why should he care how large they are?

So if you argue that LBB should try to 'set things right' my solution would be not to introduce new variables but, under control of some directive, optionally make WindowWidth and WindowHeight control the client area when a window is opened. That's straightforward because there's an API (AdjustWindowRect) which calculates the window size that results in a given client size.

I don't plan to do that, because I no longer have ambitions of moving LBB in that direction, but it's what I would want to do if I had!

Richard.
User IP Logged

RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx Re: Should REFRESH update WindowWidth/Height?
« Reply #3 on: Aug 11th, 2017, 9:02pm »

Not sure what the answer is. "resize.bas" that ships with LB doesn't work properly so it would seem Carl struggled with how it should work. An LBB directive that can change how it works might be the best way to go.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Should REFRESH update WindowWidth/Height?
« Reply #4 on: Aug 11th, 2017, 9:24pm »

on Aug 11th, 2017, 9:02pm, RobM wrote:
"resize.bas" that ships with LB doesn't work properly.

It works "properly" after the window is manually resized, doesn't it? It's only the initial state that is wrong, and that's precisely Rod's point: if there was some easy way of getting the client dimensions into WindowWidth and WindowHeight without having to manually resize the window it would fix that issue. Here it's done using an API call to prove the point:

Code:
    nomainwin
    WindowWidth = 550
    WindowHeight = 410

    listbox #resizer.lbox1, array$(), [lbox1DClick], 1, 0, 256, 186
    listbox #resizer.lbox2, array$(), [lbox2DClick], 257, 0, 284, 164
    combobox #resizer.cbox3, array$(), [cbox3DoubleClick], 257, 164, 283, 150
    texteditor #resizer.tedit4, 1, 186, 540, 195
    open "Resizing example" for window as #resizer
    #resizer "trapclose [quit]"
    #resizer "resizehandler [resized]"

    ' Rod would like to replace this block of code with #resizer "refresh":
    hw = hwnd(#resizer)
    struct rect, left as long, top as long, right as long, bottom as long
    calldll #user32, "GetClientRect", hw as ulong, rect as struct, r as void
    WindowWidth = rect.right.struct
    WindowHeight = rect.bottom.struct

[resized]
    wWid = WindowWidth
    wHig = WindowHeight
    upperVert = int(256/550*wWid) 'upper middle vertical edge
    midHoriz = int(186/410*wHig) 'middle horizontal edge
    urWid = upperVert - wWid
    #resizer.lbox1 "locate 0 0 "; upperVert; " "; int(186/410*wHig)
    #resizer.lbox2 "locate "; upperVert; " 0 "; wWid-upperVert; " "; int(186/410*wHig)-23
    #resizer.cbox3 "locate "; upperVert; " "; midHoriz-23; " "; wWid - upperVert; " "; 100
    #resizer.tedit4 "!locate 0 "; midHoriz; " "; wWid; " "; wHig-midHoriz;
    #resizer "refresh"
    wait

[quit] 'quit the program
    close #resizer
    end 

Richard.
« Last Edit: Aug 11th, 2017, 9:30pm by Richard Russell » User IP Logged

RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx Re: Should REFRESH update WindowWidth/Height?
« Reply #5 on: Aug 11th, 2017, 9:35pm »

Correct, I was referring to the initial state.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Should REFRESH update WindowWidth/Height?
« Reply #6 on: Aug 12th, 2017, 09:38am »

on Aug 11th, 2017, 9:02pm, RobM wrote:
it would seem Carl struggled with how it should work.

I can only assume that he wasn't/isn't familiar with the AdjustWindowRect API, the use of which would have made it very easy for WindowWidth and WindowHeight to refer always to the client area, solving this and other problems.

As Raymond Chen frequently says in his Microsoft blog, a time machine would be very helpful!

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls