LB Booster
« Centering a window »

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



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: Centering a window  (Read 182 times)
Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx Centering a window
« Thread started on: Apr 5th, 2017, 5:30pm »

I'm having trouble centering a wide window. Other, narrower, windows center nicely using this:

Code:
    
    UpperLeftX=Int((DisplayWidth-WindowWidth)/2)
    UpperLeftY=Int((DisplayHeight-WindowHeight)/2)
 


I also tried various combinations of UpperLeftX and UpperLeftX with no luck - the window opens too far to the right - partly off-screen
Is there some limit to the width of a window that can be centered?
I guess I would settle for all of the window being visible without having to manually drag it.

r.m.
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Centering a window
« Reply #1 on: Apr 5th, 2017, 8:09pm »

What is "wide" window?
Up to DisplayWidth it centers OK
If you ask for more, it limits itself to DisplayWidth
in JB it positions partly off- screen (left-ways)
in LBB it positions from 0
Now, from 0 and DisplayWidth - again centered

Or so it works to me.
Code:
WindowWidth = 1.5*DisplayWidth  'gange this number, 0.9 1.0 1.1 ...

    UpperLeftX=Int((DisplayWidth-WindowWidth)/2)
print UpperLeftX

    UpperLeftY=Int((DisplayHeight-WindowHeight)/2)

'nomainwin
    open "test" for window as #main
    #main "trapclose [quit]"

wait

[quit]
    close #main
    end 

User IP Logged

Alincon
Full Member
ImageImageImage


member is offline

Avatar




PM


Posts: 147
xx Re: Centering a window
« Reply #2 on: Apr 5th, 2017, 8:58pm »

If I change the window type from "dialog_modal" to "window" my program 'works'.
If I change the window type in your code from "window" to dialog_modal, it does not center, but does keep all the window in view.

r.m.
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Centering a window
« Reply #3 on: Apr 5th, 2017, 9:17pm »

on Apr 5th, 2017, 8:58pm, Alincon wrote:
If I change the window type in your code from "window" to dialog_modal, it does not center, but does keep all the window in view.

To center a dialog window you must use a style bit:

Code:
    WindowWidth = 300
    WindowHeight = 300
    stylebits #w, _DS_CENTER, 0, 0, 0
    open "test" for dialog_modal as #w
    wait 

Richard.
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: Centering a window
« Reply #4 on: Apr 5th, 2017, 9:22pm »

dialog modal is different beast
it is positioned based on parent window.
So uppertLeftX doesn't supposed to work (if only you position parent window first I think)

But there are stylebits.
Search on LB forum returned this:
Topic: Stylebit not working!

so
Code:
WindowWidth = 0.9*DisplayWidth  'gange this number, 0.9 1.0 1.1 ...

    UpperLeftX=Int((DisplayWidth-WindowWidth)/2)
print UpperLeftX

    UpperLeftY=Int((DisplayHeight-WindowHeight)/2)

'nomainwin
stylebits #main, _DS_CENTER, _WS_SYSMENU, 0, 0
    open "test" for dialog_modal as #main
    #main "trapclose [quit]"

wait

[quit]
    close #main
    end
 


EDIT
while I search Richard just *knows* ;)
« Last Edit: Apr 5th, 2017, 9:23pm by tsh73 » 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