Board Logo
« Universal Screen Fit? »

Welcome Guest. Please Login or Register.
Jan 16th, 2018, 3:32pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1 2 3  Notify Send Topic Print
 sticky  Author  Topic: Universal Screen Fit?  (Read 3496 times)
bkg73123
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 43
xx Re: Universal Screen Fit?
« Reply #15 on: Jun 22nd, 2009, 10:27pm »

I use 1280x1024.
Works great on my comp.
My work comp uses something else. one of those 16:9 ratio screens. If I load the code in JB and run from within JB the window sizes properly on my work comp. I haven't tried making an EXE on my work comp to see the results.

Here is the actual code. I can't paste all of it cause it exceeds the limit.

Code:
    NOMAINWIN
    WindowWidth = DisplayWidth
    WindowHeight = DisplayHeight
'-----------------------------------------------------------------------------------------------------------------
[ENTRY]

    graphicbox #entry.graphicbox1, 0, 0, DisplayWidth, DisplayHeight
    Textbox #entry.tbx1, -400, -50, 200, 24
    Button #entry.default, "", "", UL, -100, 0

    Open "TRACKING" for Dialog as #entry
    #entry, "Trapclose [Trapentry]"
    #entry.graphicbox1,"down;fill white"
    #entry.graphicbox1,"font MS_Sans_Serif 24 bold;color blue;backcolor white"
    loadbmp "mainback", "bmp\MAINBACK.BMP"
    #entry.graphicbox1,"drawbmp mainback 0 0"
    #entry.graphicbox1,"flush"
    unloadbmp "mainback" 


« Last Edit: Jun 22nd, 2009, 10:29pm by bkg73123 » User IP Logged

AltBas
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 461
xx Re: Universal Screen Fit?
« Reply #16 on: Jun 22nd, 2009, 11:07pm »

I believe it has something to do with the monitor Dots Per Inch (DPI) settings, as discussed in this thread Get Screen DPI by Stefan.

I was playing around with Pyazist's Chaos fractal, and the graphicbox was extending off the screen, so I started to subtract larger and larger numbers until the right side was visible, which was around 300. Running Stefan's code on my 1280 x 1024 LCD returned the 1.25 ratio for 120 DPI font scaling, when I substituted 1.25 as a divisor the graphicbox fit properly within the screen, as 1280/1.25=1024; 1280*0.20=256; 1024+256=1280.
-AltBas
« Last Edit: Jun 22nd, 2009, 11:12pm by AltBas » User IP Logged

Stefan Pendl
Administrator
ImageImageImageImageImage


member is offline

Avatar

Let's talk JB ...


Homepage PM

Gender: Male
Posts: 3712
xx Re: Universal Screen Fit?
« Reply #17 on: Jun 23rd, 2009, 02:05am »

If the resolution factor is 4:3, then you are likely using 96DPI for the screen.
This is useful for resolutions up to, but not including, 1600x1200.

The new 16:9 monitors are likely to use 1920x1200 at 120DPI, this has a big effect on the display of regular windows.

Dialog type windows are using a different sizing algorithm, which does automatically compensate the DPI settings.

For other type windows you need to compensate on your own.

This is a feature that is build into Windows and can't be changed.
User IP Logged

Stefan - Homepage

Remember to read the forum rules board wink

Just BASIC 1.01, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Stefan Pendl
Administrator
ImageImageImageImageImage


member is offline

Avatar

Let's talk JB ...


Homepage PM

Gender: Male
Posts: 3712
xx Re: Universal Screen Fit?
« Reply #18 on: Jun 23rd, 2009, 02:35am »

Since dialog type windows will automatically adapt their size to the DPI settings of the screen you need the following Code:
    ' get the scaling factor based on the screens DPI settings
    ScreenScale = GetScaleFactor()

    ' full screen dialog window
    WindowWidth = int(DisplayWidth/ScreenScale)
    WindowHeight = int(DisplayHeight/ScreenScale)

'...

end

function GetScaleFactor()
    GetScaleFactorWindowWidth = WindowWidth
    GetScaleFactorWindowHeight = WindowHeight
    WindowWidth = 1
    WindowHeight = 1

    open "test" for graphics as #GetScaleFactor
    #GetScaleFactor "down"
    #GetScaleFactor "font arial 10"
    #GetScaleFactor "place 0 0"
    #GetScaleFactor "\\I"
    #GetScaleFactor "posxy PosX PosY"
    close #GetScaleFactor

    select case PosY
        case 26
        GetScaleFactor = .75
        case 32
        GetScaleFactor = 1
        case 38
        GetScaleFactor = 1.25
        case 46
        GetScaleFactor = 1.5
        case 64
        GetScaleFactor = 2
    end select

    WindowWidth = GetScaleFactorWindowWidth
    WindowHeight = GetScaleFactorWindowHeight
end function
 

The easier way is to use the following Code:
    nomainwin
    open "test" for dialog_fs as #m
    #m "trapclose [quit]"
    wait

[quit]
    close #m
    end
 
User IP Logged

Stefan - Homepage

Remember to read the forum rules board wink

Just BASIC 1.01, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Universal Screen Fit?
« Reply #19 on: Jun 23rd, 2009, 03:21am »

You might also consider setting the office pc to the default 96Dpi display setting.
User IP Logged

Stefan Pendl
Administrator
ImageImageImageImageImage


member is offline

Avatar

Let's talk JB ...


Homepage PM

Gender: Male
Posts: 3712
xx Re: Universal Screen Fit?
« Reply #20 on: Jun 23rd, 2009, 03:46am »

on Jun 23rd, 2009, 03:21am, Rod wrote:
You might also consider setting the office pc to the default 96Dpi display setting.

For high resolutions this is not an option, since the overall text will get too tiny to be able to read it for eight hours a day.

I am working in front of a 23", 1920x1200, 120DPI screen each day, so I know what I am talking about.

Setting the DPI to 96 (= normal or 100%) does hurt my eyes.

The resolution is recommended by the monitor vendor and it allows a big graphics area for the CAD system I am working with.
In addition I have a virtual desktop application installed, since I usually run more than one application at a time, due to programming custom utilities for the CAD system, to get rid of the windows cluttering up the taskbar, but which are still needed.
User IP Logged

Stefan - Homepage

Remember to read the forum rules board wink

Just BASIC 1.01, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Rod
Administrator
ImageImageImageImageImage


member is offline

Avatar

Graphics = Goosebumps!


PM

Gender: Male
Posts: 3151
xx Re: Universal Screen Fit?
« Reply #21 on: Jun 23rd, 2009, 05:43am »

I accept those points Stefan. However I'm still confused. I tried setting my PC to 120Dpi and I find that my original sample code opens window type window, graphic and in Liberty, popup as full screen windows. The window is always edge to edge with the display. Is the confusion the fact that we are talking about controls in the window being out of place or is it the window itself that does not fit on the display?

We have asked a couple of times but could we see the exact code that demonstrates the problem?

I run a 1440x900 wide screen display at 96Dpi by default.
User IP Logged

bkg73123
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 43
xx Re: Universal Screen Fit?
« Reply #22 on: Jun 23rd, 2009, 07:38am »

Thanks Guys!
It was the DPI setting.
I too use the 120 DPI setting.
I am running 1680x1050 120DPI.
I changed it to 96 DPI and that solved the problem.
The original EXE I made from home now scales
properly to my screen.
However, I too don't like the smaller font which
is why I set it to 120 DPI. I will try the code Stefan suggested.

B
User IP Logged

bkg73123
Member in Training
ImageImage


member is offline

Avatar




PM


Posts: 43
xx Re: Universal Screen Fit?
« Reply #23 on: Jun 23rd, 2009, 07:46am »

dialog_fs works with the 120DPI setting!
Thank you so much!

B
User IP Logged

Stefan Pendl
Administrator
ImageImageImageImageImage


member is offline

Avatar

Let's talk JB ...


Homepage PM

Gender: Male
Posts: 3712
xx Re: Universal Screen Fit?
« Reply #24 on: Jun 24th, 2009, 01:29am »

on Jun 23rd, 2009, 05:43am, Rod wrote:
We have asked a couple of times but could we see the exact code that demonstrates the problem?

I run a 1440x900 wide screen display at 96Dpi by default.

I too use this resolution at home for my notebook screen, but if the width resolution is equal to or greater than 1600, 120DPI is a must.

See About Dialog Boxes at MSDN
Quote:
Dialog Box Measurements

Every dialog box template contains measurements that specify the position, width, and height of the dialog box and the controls it contains. These measurements are device independent, so an application can use a single template to create the same dialog box for all types of display devices. This ensures that a dialog box will have the same proportions and appearance on all screens despite differing resolutions and aspect ratios between screens.

The measurements in a dialog box template are specified in dialog template units. To convert measurements from dialog template units to screen units (pixels), use the MapDialogRect function, which takes into account the font used by the dialog box and correctly converts a rectangle from dialog template units into pixels. For dialog boxes that use the system font, you can use the GetDialogBaseUnits function to perform the conversion calculations yourself, although using MapDialogRect is simpler.


Summarizing:
Dialog type windows are sized by dialog units, which are independent from the device, and will be converted into device units before display.

Window type windows are already sized by screen units, so there will be no conversion.

Dialogs use dialog units to make sure they look the same on any screen, without the need to correct their contents.
User IP Logged

Stefan - Homepage

Remember to read the forum rules board wink

Just BASIC 1.01, Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: Universal Screen Fit?
« Reply #25 on: Sep 8th, 2016, 03:51am »

on Jun 23rd, 2009, 02:35am, Stefan Pendl wrote:
Since dialog type windows will automatically adapt their size to the DPI settings of the screen you need the following Code:
    ' get the scaling factor based on the screens DPI settings
    ScreenScale = GetScaleFactor()

    ' full screen dialog window
    WindowWidth = int(DisplayWidth/ScreenScale)
    WindowHeight = int(DisplayHeight/ScreenScale)

'...

end

function GetScaleFactor()
    GetScaleFactorWindowWidth = WindowWidth
    GetScaleFactorWindowHeight = WindowHeight
    WindowWidth = 1
    WindowHeight = 1

    open "test" for graphics as #GetScaleFactor
    #GetScaleFactor "down"
    #GetScaleFactor "font arial 10"
    #GetScaleFactor "place 0 0"
    #GetScaleFactor "\\I"
    #GetScaleFactor "posxy PosX PosY"
    close #GetScaleFactor

    select case PosY
        case 26
        GetScaleFactor = .75
        case 32
        GetScaleFactor = 1
        case 38
        GetScaleFactor = 1.25
        case 46
        GetScaleFactor = 1.5
        case 64
        GetScaleFactor = 2
    end select

    WindowWidth = GetScaleFactorWindowWidth
    WindowHeight = GetScaleFactorWindowHeight
end function
 

The easier way is to use the following Code:
    nomainwin
    open "test" for dialog_fs as #m
    #m "trapclose [quit]"
    wait

[quit]
    close #m
    end
 

Slowly getting a grasp of some of the features of JB I have been better able to start to tackle more threads, and thought this one seemed to be just the ticket,
especially "the easier way" bit :-)

However

This works ok:
Code:
open "BREEDING RECORDS.... (Windows7, 1920 x 1080).... v.1.01" for window as #main 


...but, when the following is substituted, the screen opens with about 1/6 of the bmp, which is to be displayed, missing on the right and at the bottom:
Code:
open "BREEDING RECORDS.... (Windows7, 1920 x 1080).... v.1.01" for dialog_fs as #main 


https://www.filesanywhere.com/fs/v.aspx?v=8b716486585e73a9a9aa
« Last Edit: Sep 8th, 2016, 04:04am by stumpy » User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3635
xx Re: Universal Screen Fit?
« Reply #26 on: Sep 8th, 2016, 1:02pm »

so.
What is your DPI setting / what factor linked "Get Screen DPI by Stefan" program returns?
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
stumpy
Full Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 148
xx Re: Universal Screen Fit?
« Reply #27 on: Sep 8th, 2016, 3:37pm »

right I did not understand, but when I have run either of the two sets of code on its own under JB as follows,

either, the code entitled ' get the scaling factor based on the screens DPI settings,
or the code under the heading "the easier way"

I just then get a 'buttonface' coloured empty screen which shows no text or numbers.

Would you kindly spell out what I need to do to get my dpi setting?

and please say if, or how, I can use that information in "Breeding Records" so that it can display the screen correctly on any PC ?
« Last Edit: Sep 8th, 2016, 3:42pm by stumpy » User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3635
xx Re: Universal Screen Fit?
« Reply #28 on: Sep 8th, 2016, 4:39pm »

Run code
http://justbasic.conforums.com/index.cgi?board=code&action=display&num=1244976691
reply #1

For me in says Code:
PosY .................. 32
Screen Scale Factor ... 1

Finished ... 
that means "96 DPI" (default 100% settings)
1.25 means 125%, or 120 DPI etc

I suspect (to test I should change DPI setting, which will mess desktop icon layout), that then you open dialog, all control sizes get scaled by that factor (1.25 etc)
so your picture just gets shifted lower right.
(btw size of picturebox get scaled, but size of picture/drawings still stays same - in pixels, not scaled. So picture doesn't fill whole picturebox.)
« Last Edit: Sep 8th, 2016, 5:13pm by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3635
xx Re: Universal Screen Fit?
« Reply #29 on: Sep 8th, 2016, 4:54pm »

Quote:
and please say if, or how, I can use that information in "Breeding Records" so that it can display the screen correctly on any PC ?

I'm not sure it would help at all.
My guess to make 1920 x 1080 interface fit to 1024x768 screen,
you have to calculate scale factor - something like
scale = min(1024/1920, 768/1080 )
and use it in creating your controls (adding "*scale" everythere)
Oh, and somehow use if for font size too
(I would use font sized in pixels, setting only height,
http://justbasic.wikispaces.com/BB___font
, and scale it)

EDIT
something like this
Code:
nomainwin

    'WindowWidth = 1920
    'WindowHeight = 1080
    WindowWidth = 1024
    WindowHeight = 768
    scale = 1024/1920

    graphicbox #main.startscreen, 0, 0, 1920*scale, 1080*scale

    button #main, "Open Pairs Record", [pairsrecordsswitch], UL, 1480*scale, 114*scale, 240*scale, 40*scale
    button #main, "- Guide -", [guidepairs], UL, 1740*scale, 114*scale, 80*scale, 40*scale

    button #main, "Open Nest Cards + Young", [cardsandyoungswitch], UL, 1480*scale, 456*scale, 240*scale, 40*scale
    button #main, "- Guide -", [guidecards], UL, 1740*scale, 456*scale, 80*scale, 40*scale

open "BREEDING RECORDS.... (Windows7, 1920 x 1080).... v.1.01" for window as #main
'    print #main, "font Arial Narrow 10 italic"
'    print #main, "font Arial Narrow 0 16 italic"
print #main, "font Arial Narrow 0 ";int(16*scale);" italic" 
« Last Edit: Sep 8th, 2016, 5:08pm by tsh73 » User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
Pages: 1 2 3  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls