@Dav Hi Dav,
I just tried your _DELAY suggestion. Got it working with...
_DELAY .2
SCREEN _NEWIMAGE(600, 480, 32)
A .1 delay failed. Weirdly, too. Two blank consoles opened. Doubling to .2 corrected everything.
I agree, there seems to be some slower response from this later version. I experienced delay issues with using hardware imaging as well. Windows API calls often need delays as well. I mean the greatest thing ever would be some checking function like _FILEEXISTS() does for files so the next statement in the program flow would not be executed until the API function was returned. I've made a few of those.
I am wondering if this delay needed before rendering the SCREEN image could be tweaked. I don't do graphics, but I didn't think delays to render a screen image would ever be necessary.
Thanks for the solution!
Pete
@Pete What you're seeing here has been happening forever and ever in QB64. It's part of our startup behavior. If you watch closely, all QB64 programs start out in SCREEN 0.
_DELAY .2
SCREEN _NEWIMAGE(600, 480, 32)
Even with your little 2-line snippet above, what SCREEN mode was your program in before that _DELAY statement was issued?
Yep! Your favorite! SCREEN 0!
So QB64 makes a screen... Windows gives it a handle...
QB64 frees that screen... Without a delay, you might get that handle...
Windows frees the handle, Makes a new screen... Without a delay, you might get the blank handle...
Windows gives the new screen its handle...
There's several race conditions at work here, which can result in your _WINDOWHANDLE returning garbage for you.
My suggestion is to get into the habit of placing a delay of *at least* 0.2 seconds after each SCREEN or _NEWIMAGE statement, before you go referencing it via _WINDOWHANDLE or other means.