Possible bug with _SCREENICON
#1
Bug 
Code: (Select All)
_DELAY 2
_SCREENHIDE
_DELAY 5
' Error 5 after delay at line below...
IF _SCREENICON THEN BEEP ' Should beep with value -1 when minimized by _SCREENHIDE.
_SCREENSHOW

So I have done Win32 API min/restore with focus, but now I was looking for an all QB64 method. Since _SCREENHIDE is supposed minimize the program, it seems odd _SCREENICON should throw an error. It should return -1 when the window is minimized. If you REM out the SCREENHIDE and manually minimize, it works just fine, but apparently not when _SCREENHIDE minimizes the window for you.

QB64PE V 3.30 on Win 10 64-bit OS.


Pete
Reply
#2
Screenhide is not the same as ScreenIcon.  
Use _SCREENICON to minimize your program.   Hide sets the not visible flags in windows.
Reply
#3
https://qb64phoenix.com/qb64wiki/index.php/SCREENICON

Vs

https://qb64phoenix.com/qb64wiki/index.php/SCREENHIDE
Reply
#4
Nice. I've used the function to check status, but not the statement to minimize the window.

That stated, I think I will update the wiki to reflect _SCREENICON cannot be used when _SCREENHIDE is active.

Pete
If eggs are brain food, Biden takes his scrambled.
Reply
#5
Use _SCREENX and/or _SCREENY to check for a minimized window, they usually return -32000 then (at least on Windows)

Code: (Select All)
IF _SCREENX <> -32000 AND _SCREENY <> -32000 THEN
    'not minimized
ELSE
    'is minimized
END IF
However, I guess it won't work either with a hidden screen Huh
Reply
#6
@RhoSigma

Hi Rho,

I've noticed that behavior with _SCREENY and _SCREENX, before. What I use to detected min without Win32 API is the _SCREENICON function. While _SCREENICON minimizes the window (Thanks for that, Steve!) the function lets you know if the window is on the desktop or minimized. 0 = On desktop, -1 = minimized; hwever, I was surprised it would error out with _SCREENHIDE. Not work, sure, but I don't think it should throw an error, but probably a lot of other statements might error out with _SCREENHIDE, too; but _SCREENY and SCREEN X do not error out, they just report the same positions as before the screen gets hidden.

Without _SCREENHIDE..
Code: (Select All)
_DELAY 2 ' Open window for 2 seconds.
PRINT _SCREENICON
_SCREENICON ' Minimize window.
PRINT _SCREENICON
_DELAY 2

I wish we could use NOT _SCREENICON to restore it! Oh well. That can also be accomplished for Windows users  only with Win32 API.

I don't think I've come across any universal way, other than Win32 API, to restore a minimized app; and that's one we sure don't want to use _SCREENCLICK for.

Pete
Reply
#7
Blame Glut for that.  Oddly enough, it offers a cross-platform way to minimize a window (screeniconify is their name for the command, IIRC), but they don't offer anyway to restore back from inconification!   Go figure.  Tongue
Reply
#8
(12-08-2022, 11:25 PM)RhoSigma Wrote: Use _SCREENX and/or _SCREENY to check for a minimized window, they usually return -32000 then (at least on Windows)

Code: (Select All)
IF _SCREENX <> -32000 AND _SCREENY <> -32000 THEN
    'not minimized
ELSE
    'is minimized
END IF
However, I guess it won't work either with a hidden screen Huh

At my end on Manjaro MATE, with the following code, the two functions return zero:

Code: (Select All)
$SCREENHIDE
sx = _SCREENX
sy = _SCREENY
_DELAY 5
_SCREENSHOW
print sx, sy
end

Change the dollar sign to underscore, and the only difference is that only the titlebar and window frame are drawn and shown for five seconds before the window is drawn whole with "_SCREENSHOW".


(12-09-2022, 01:16 AM)SMcNeill Wrote: Blame Glut for that.  Oddly enough, it offers a cross-platform way to minimize a window (screeniconify is their name for the command, IIRC), but they don't offer anyway to restore back from inconification!   Go figure.  Tongue
Probably they expected the programmer to reconfigure the window, or just use the same parameters as when the window was initialized and first put on the screen in the session. If that's the case it's ignorant.

I'm not sure but this is a lot like what we had to do before QB64 v1 where "FindWindow" Win API function had to be used to find the title of a window, to obtain the handle before something done to that window.
Reply




Users browsing this thread: 3 Guest(s)