Board Logo
« adjustWindow routine »

Welcome Guest. Please Login or Register.
Sep 25th, 2017, 7:08pm


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  Notify Send Topic Print
 thread  Author  Topic: adjustWindow routine  (Read 473 times)
ezprogramming
Guest
xx adjustWindow routine
« Thread started on: Nov 3rd, 2015, 07:59am »

Anatoly's clever adjustWindow routine is very useful when you want to open a window which has precise (client area) dimensions. However it doesn't always work perfectly, because the values of slackX and slackY it calculates are always even numbers, so the resulting window size may be 'off by one'.

If it is important that the window dimensions are precise, to the pixel, the routine can be modified as listed below:

Code:
    desiredW = WindowWidth: desiredH= WindowHeight
    WindowWidth = 200: WindowHeight = 200
    open "" for graphics_nsb_nf as #gr ' change type as required
    #gr, "home ; down ; posxy x y"
    width = 2*x : height = 2*y
    close #gr
    slackX = 200-width: slackY = 200-height
    WindowWidth = 201: WindowHeight = 201
    open "" for graphics_nsb_nf as #gr ' change type as required
    #gr, "home ; down ; posxy x y"
    width = 2*x : height = 2*y
    close #gr
    if slackX <> 200-width  then slackX = slackX - 1
    if slackY <> 200-height then slackY = slackY - 1
    WindowWidth = desiredW + slackX
    WindowHeight =  desiredH + slackY 

The window type must of course be the same as that of the window you will eventually open, so change the graphics_nsb_nf in both places as necessary.

Richard.
« Last Edit: Nov 3rd, 2015, 08:03am by ezprogramming » User IP Logged

Donnie
Full Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 139
xx Re: adjustWindow routine
« Reply #1 on: Dec 13th, 2015, 08:16am »

This may be an interesting addition to open different windows w/adjustments.

Code:
Handle$="#gr2"
    nop=OpenWindow(Handle$)
    end
    Function OpenWindow(Handle$)
    desiredW = WindowWidth: desiredH= WindowHeight
    M=.75-.125
    nomainwin
    WindowWidth = 720*M: WindowHeight = 348*M
    open "" for graphics as #Handle$ ' change type as required
    #Handle$, "home ; down ; posxy x y"
    width = 2*x : height = 2*y
    close #Handle$
    slackX = 720*M-width: slackY = 348-height
    WindowWidth = 720*M: WindowHeight = 348*M
    open "" for graphics as #Handle$ ' change type as required
    #Handle$, "home ; down ; posxy x y"
    width = 2*x : height = 2*y
    wait
    close #Handle$
    if slackX <> 720*M-width  then slackX = slackX - 1
    if slackY <> 348*M-height then slackY = slackY - 1
    WindowWidth = desiredW + slackX
    WindowHeight =  desiredH + slackY
    end function
 
User IP Logged

Pages: 1  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