Author Topic: Can a Screen Be Resized by Code?  (Read 28817 times)

0 Members and 1 Guest are viewing this topic.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Can a Screen Be Resized by Code?
« on: January 06, 2019, 06:12:58 am »
After posting my updated Pelmanism Game in the regular Programs section, I realised that I could have made that an InForm game - would give it a more professional look.  But I would need to have three different screen sizes, and in InForm we are resricted to the Screen created by the UiEditor and we can, of course, only have the one screen.  If we could write some code which changed the Screen X- and Y- widths, that would do I think.  A User can do this with $RESIZE and _RESIZEWIDTH etc, but could the screen width/height be set by code commands?  From the Wiki, I think not.  A pity.

FellippeHeitor

  • Guest
Re: Can a Screen Be Resized by Code?
« Reply #1 on: January 06, 2019, 08:28:25 am »
Control(__UI_FormID).Width = (whatever width suits you)
Control(__UI_FormID).Height = (whatever height suits you)

Alternatively you can set a form's CanResize property to true so the user can freely resize the form. That will trigger the __UI_FormResize event from which you can adapt your interface according to the resulting Control(__UI_FormID).Width and Control(__UI_FormID).Height.
« Last Edit: January 06, 2019, 08:42:34 am by FellippeHeitor »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Can a Screen Be Resized by Code?
« Reply #2 on: January 06, 2019, 10:07:34 am »
Oh great!  That's mapped out my next project.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Can a Screen Be Resized by Code?
« Reply #3 on: January 06, 2019, 12:45:54 pm »
So when is the Inform WIKI going to go live? Don't you have a Clippy equivalent in Brazil? Maybe Senior Quippy?

You're living my dream of customization ability in programs. I've only written a handful of libraries that allow for easy changes like that.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

FellippeHeitor

  • Guest
Re: Can a Screen Be Resized by Code?
« Reply #4 on: January 06, 2019, 01:02:08 pm »
Bam: https://github.com/FellippeHeitor/InForm/wiki

As old as the project itself ;-)

FellippeHeitor

  • Guest
Re: Can a Screen Be Resized by Code?
« Reply #5 on: January 06, 2019, 01:14:52 pm »
You're living my dream of customization ability in programs. I've only written a handful of libraries that allow for easy changes like that.

Pete

It's a project I'm really proud of :-)

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Can a Screen Be Resized by Code?
« Reply #6 on: January 06, 2019, 01:39:07 pm »
As one who has coded some InForm projects, I can attest that the InForm wiki was a great resource.  Fellippe, please do feel proud.

(And I only needed the tiniest amount of Fellippe's additional help to get going - probably not the most correct usage of the superlative of tiny!).

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Can a Screen Be Resized by Code?
« Reply #7 on: January 06, 2019, 03:10:28 pm »
Nice job on the WIKI, too!

We don't need o stinkin' Quippy!

Pete :D
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Can a Screen Be Resized by Code?
« Reply #8 on: January 07, 2019, 06:40:14 am »
Fellippe, I've started on Pelmanism InForm.  I've created a starting Form of a certain size, which will get resized (larger and smaller) during the program execution.  Will there be a problem if the Form size shrinks so that some of the controls are temporarily outside the new Form limits, or shall I have to temporarliy move everything inside the smaller Form?

FellippeHeitor

  • Guest
Re: Can a Screen Be Resized by Code?
« Reply #9 on: January 07, 2019, 07:06:01 am »
If they won't be needed when the form is smaller they can remain hidden, no problem. You may want to set their .Disabled property to True temporarily to prevent them from gaining focus if your user navigates the interface using Tab.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Can a Screen Be Resized by Code?
« Reply #10 on: January 09, 2019, 05:36:32 am »
Fellippe, I'm most of the way to preparing the InForm version of my Pelmanism program.  However, it is prone to crashing, either at compilation or some way through when running (unpredictable).  When you have some spare time, could you take a look?  I'm now using the 64-bit version of QB64 - could that be a problem?  Thanks, Richard

https://www.dropbox.com/s/p3oeqa30ytdq0qp/Pelmanism%20InForm.zip?dl=1
InForm Failure.jpg
* InForm Failure.jpg (Filesize: 75.39 KB, Dimensions: 853x685, Views: 482)

FellippeHeitor

  • Guest
Re: Can a Screen Be Resized by Code?
« Reply #11 on: January 09, 2019, 11:12:26 am »
I'll have a look at your code.

Edit: Just ran it with no issues, compiled with QB64 32bit (btw: flip card times are slooooooooooow). Could you confirm you also get these crashes using the 32bit version of QB64? There are quite a few API calls when InForm is running under Windows, and eventual crashing could be related to that.
« Last Edit: January 09, 2019, 11:22:00 am by FellippeHeitor »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Can a Screen Be Resized by Code?
« Reply #12 on: January 09, 2019, 12:51:53 pm »
Fellippe, thanks for feedback.  Copied my project folder back to QB64 (32-bit) - how long ago that seems! - and initially got Crash Divide by Zero fails every time I clicked on "New Game".  Found out that this was due to _SCREENMOVE statements (I has wanted to reposition the screen for different window sizes).  With the _SCREENMOVE lines commented out, it looks like the 32-bit version runs OK, and I've doubled the speed of the turnovers (I'd made the game deliberately lazy).  The 64-bit version still crashes unreliably at any time.

There are quite a few API calls when InForm is running under Windows

No idea what an API call is: another gaping hole in my knowledge - if Steve stumbles across this post, he'll probably give me another large dose of tuition!  I'll just keep taking those tablets of wisdom.
« Last Edit: January 09, 2019, 12:54:09 pm by Qwerkey »

FellippeHeitor

  • Guest
Re: Can a Screen Be Resized by Code?
« Reply #13 on: January 09, 2019, 12:57:41 pm »
No idea what an API call is: another gaping hole in my knowledge - if Steve stumbles across this post, he'll probably give me another large dose of tuition!  I'll just keep taking those tablets of wisdom.

https://en.wikipedia.org/wiki/Application_programming_interface

When you use a system function Windows makes available via DLLs. The reason why we have http://www.qb64.org/wiki/DECLARE_DYNAMIC_LIBRARY
« Last Edit: January 09, 2019, 12:58:51 pm by FellippeHeitor »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Can a Screen Be Resized by Code?
« Reply #14 on: January 10, 2019, 06:07:15 am »
With the _SCREENMOVE lines commented out, it looks like the 32-bit version runs OK

Oh, by the way, is there an InForm equivalent of _SCREENMOVE which I can use in the running code?  Clearly InForm doesn't like _SCREENMOVE after UI_OnLoad.