Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Is this a bug or expected behavior with _DestopWidth and _DesktopHeight?
#1
Take a look at this small piece of sample code:

Code: (Select All)
$ScreenHide

x = _DesktopWidth: y = _DesktopHeight

'
' The foloowing lines serve no purpose other that to illustrate that the program
' will never reach those lines of code.

For z = 1 To 10
Next z

System

In this code, I am hiding the QB64pe screen until I take some actions based upon the size of the desktop on which the program is being run. As a result, I try to obtain the width and height of the desktop. However, the line "x = _DesktopWidth: y = _DesktopHeight" will simply hang forever.

If you execute the code above, it will look within the IDE as if the program runs and ends because you get access to the IDE again after running the program. However, if you look at task manager you will find that the program is still running:


[Image: Image1.jpg]

As further proof of this, try to run the same program in Debug mode by pressing the F7 key. Note that it will hang on the line "x = _DesktopWidth: y = _DesktopHeight" and you will never be able to step past that line.

I find it odd that the QB64pe screen would have to be displayed just to allow me to get the width and height of my actual display.

Is this expected behavior for some reason? If so, any workaround or possibility of a fix for this?
Reply
#2
It appears to be a glitch, but should be one that isn't very difficult to sort out. I'll sort it out and see about pushing a fix for it in when we offer our next version. Wink
Reply
#3
I'd say it's rather a problem with glut and $SCREENHIDE, back in the very ancient times, when QB64 was SDL based, I used to hide the screen generally, then _SCREENMOVE to my desired position and then _SCREENSHOW, so that the window nicely opened in the right place, rather than in any random position and then jumping accross the Desktop to the defined position. This behavior did always nerv me and looked unproffesional. But, the above method worked out good to workaround that.

Suddenly, QB64 became OpenGL based, and none of my programs doing the above trick did work anymore. They all just freezed without a sign of life and I need to use the TaskManager to kill it.

Later when start working on my GuiTools project, I had the same problem and started investigating a bit.
Basically I found especially in GuiTools, that the program stopped working, as soon as the display was updated first (_DISPLAY). The only way to prevent this was the use of $CONSOLE:ONLY, which is no option for a GUI project Sad

Internally I think it's glut, which needs a valid window handle for almost all operations, which is not available with $SCREENHIDE in effect. How SDL did manage to work correctly here, no clue Huh
Reply
#4
@RhoSigma You might like this demo: https://qb64phoenix.com/forum/showthread.php?tid=140

The issue here is a stray "if screenexists = 0 then loop" type statement that's not necessary for these 2 commands. Remark those lines out of libqb and it'll run without issue. Smile
Reply
#5
Thanks for looking into this. Once a fix is available I'd be happy to test it. This would help a lot with something I'm trying to accomplish.
Reply
#6
https://github.com/QB64-Phoenix-Edition/QB64pe/pull/60 -- fix for this is waiting for review and approval in the repo. Give it a few days so someone can approve the change, and then you should be good to go from now on with this. Wink
Reply
#7
Thanks! Greatly appreciated.
Reply
#8
Glitch patched, pushed, approved, and merged into the repo.

I'd hold off another day or so before downloading (there's a patch going in now to address an issue that can lock up the IDE) so I wouldn't have to redownload a second time, but it's actually good to go at any point now. Wink
Reply
#9
Fantastic! I'll hold off and wait for that other patch. How will I know when that is ready. Will that show up as a new release like 0.7.0?
Reply
#10
(05-17-2022, 02:10 PM)hanness Wrote: Fantastic! I'll hold off and wait for that other patch. How will I know when that is ready. Will that show up as a new release like 0.7.0?

It's in the queue already.  I'll post you an update when it's accepted and pulled into the repo.  After that, I think we're all done until the next batch of work begins again.  There's always something which needs tweaking or correcting in a project as large as QB64.  Wink
Reply




Users browsing this thread: 1 Guest(s)