Author Topic: Change to _SCREENSHOW to restore from an icon  (Read 3771 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Change to _SCREENSHOW to restore from an icon
« on: January 12, 2021, 09:33:31 am »
QB64 currently has the _SCREENICON command which we can use to minimize a running program down to an icon on the task bar.  Unfortunately, we don't currently have any means by which to automatically restore that window back from the task bar.  My initial thought is that a very simple little change could be made to _SCREENSHOW, to correct that for us, like so:

Code: C++: [Select]
  1.         void sub__screenshow(){
  2.             if (!window_exists){
  3.                 create_window=1;
  4.                 }else{
  5.                 #ifdef QB64_GLUT
  6.                     #ifdef QB64_WINDOWS
  7.                         if (func_screenicon) {OpenIcon(window_handle);}
  8.                     #endif      
  9.                     glutShowWindow();
  10.                 #endif
  11.             }
  12.             screen_hide=0;
  13.         }

All we're doing here is adding lines 6-8 into the existing code (I don't know the Linux/Mac equivalent, so someone else can provide those later), and then _SCREENSHOW will restore the iconic window back onto the screen.  Code to test this would be as simple as:

Code: QB64: [Select]

For me, this seems like a simple enough behavior to associate with _SCREENSHOW, but others (like Fellippe) are much more finicky in how they expect everything to behave.  This is simple enough to add to _SCREENSHOW's current behavior, but if folks would rather have a different format (such as a new keyword for _SCREENUNICON, or _SCREENICON OFF, or whatever), then they're more than welcome to implement the change in whatever form they want (or not at all, if it's not a wanted change..)

If you guys want this pushed into the repo, decide how you want it, and then feel free to implement whatever syntax suits you the best.  All I'm doing here is showcasing how simple a change it can be to add it to the language for us.  I'll leave it up to someone else to actually make the change however they want and push it for use.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Change to _SCREENSHOW to restore from an icon
« Reply #1 on: January 12, 2021, 11:02:28 am »
This still won't save me from typing "AS udt" Sigh.

On a serious note, would this addition lead to a method to minimize the launch event of an app, so we never have to see that launch window flash on our screens?

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

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Change to _SCREENSHOW to restore from an icon
« Reply #2 on: January 12, 2021, 11:04:32 am »
This still won't save me from typing "AS udt" Sigh.

On a serious note, would this addition lead to a method to minimize the launch event of an app, so we never have to see that launch window flash on our screens?

Pete :D

Nope.  I was actually looking into that a little, when I remembered we also couldn't restore from an icon, and quickly added this into my personal version.  :)

https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Change to _SCREENSHOW to restore from an icon
« Reply #3 on: January 12, 2021, 12:39:09 pm »
QB64 Windows users can restore from a "icon" (minimized to the task bar) using Windows API calls.

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

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Change to _SCREENSHOW to restore from an icon
« Reply #4 on: January 12, 2021, 01:01:21 pm »
QB64 Windows users can restore from a "icon" (minimized to the task bar) using Windows API calls.

Pete

That’s what this does for us, without having to DECLARE LIBRARY and learn any windows commands.  _SCREENICON to minimize, _SCREENSHOW to restore from icon.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Change to _SCREENSHOW to restore from an icon
« Reply #5 on: January 12, 2021, 02:58:32 pm »
Well the only push back I see, although others may have different objections, would be the minimization and showing the screen are two different processes. Sure, it seems silly to "hide" a minimized screen, you can't view it anyway, but will others see it that way, too? Please note that the _SCREENHIDE command also hides the taskbar icon.

Example. During the 10 sec countdown, click the "-" minimize button on the program window. It will go to the task bar, but when the countdown finishes, the icon will also be hidden by the _SCREENHIDE statement. After 5 seconds (SLEEP 5) the icon will re-appear.

Code: QB64: [Select]
  1. LOCATE 2, 28: PRINT "Minimize during countdown..."
  2. FOR i% = 10 TO 1 STEP -1
  3.     LOCATE 12, 39: PRINT i%;
  4.     _DELAY 1
  5. LOCATE 12, 38: PRINT "See?"

It's interesting that if _SCREENICON is added to the code above, after the _SCREENHIDE command, that the icon will reappear in the taskbar.

Code: QB64: [Select]
  1. LOCATE 2, 28: PRINT "Minimize during count down..."
  2. FOR i% = 10 TO 1 STEP -1
  3.     LOCATE 12, 39: PRINT i%;
  4.     _DELAY 1
  5. _DELAY .5 ' Makes the icon appear like it flashes back to the taskbar after it was hidden.
  6. LOCATE 12, 38: PRINT "See?"

But if you really want to freak out the OS, REM out that _SCREENSHOW line, and after the SLEEP delays have elapsed, try and click that icon (remember, it is still affected by that _SCREENHIDE statement, and see what happens!

Code: QB64: [Select]
  1. LOCATE 2, 28: PRINT "Minimize during count down..."
  2. FOR i% = 10 TO 1 STEP -1
  3.     LOCATE 12, 39: PRINT i%;
  4.     _DELAY 1
  5. LOCATE 12, 38: PRINT "See?"
  6. '''_SCREENSHOW

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

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Change to _SCREENSHOW to restore from an icon
« Reply #6 on: January 12, 2021, 04:10:56 pm »
Quote
Well the only push back I see, although others may have different objections, would be the minimization and showing the screen are two different processes. Sure, it seems silly to "hide" a minimized screen, you can't view it anyway, but will others see it that way, too? Please note that the _SCREENHIDE command also hides the taskbar icon.

That’s why I said I’d leave it to others to sort out what syntax they want.  _SCREENSHOW works for me, as to my logic it shows the minimized screen again.  If others prefer a separate _SCREENUNICONIFY command, then that’s fine too.  _SCREENUNICON?  _SCREENICON _RESTORE?  _SCREENICON OFF?

Honestly, I don’t give a shit.  Fight it out, call it what you want, but at the end of the day, we should have a native way to restore from an icon, if we have one to go to an icon.  For my personal use, at the moment, I’ve simply set it to work with _SCREENSHOW in my own version of QB64.  I’m too old, too tired, and too worn down from taking care of my mother with Alzheimers to fight over something like syntax anymore.  I’ve shown how simple it’d be to add the option to the language, now somebody else can bash out the perfect keyword/syntax, and make it whatever folks want it to be.

Personally, I wish we didn’t have half the _SCREEN commands that we do.  I’d love to see them all consolidated to a simple, singular, _SETSCREEN command.

_SETSCREEN _HIDDEN
_SETSCREEN _ICON
_SETSCREEN _NORMAL
_SETSCREEN _POSITION(x, y)
_SETSCREEN _SIZE(x, y)
_SETSCREEN _RESIZABLE (ON, OFF, STRETCH, SMOOTH)
_SETSCREEN _FULLSCREEN

One command instead of six.  (SCREENHIDE, SCREENSHOW, SCREENICON, SCREENMOVE, $RESIZE, and _FULLSCREEN.).

Then, a simple inverse function for GETSCREEN can do the same for telling you if you’re in fullscreen, hidden, normal, ect...

Two commands to remember to use, rather than having to search through a dozen different listings in the wiki. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: Change to _SCREENSHOW to restore from an icon
« Reply #7 on: January 12, 2021, 04:31:36 pm »
Two statements. That sounds reasonable. But removing the six older statements will affect the backward compatibility of older QB64 programs. I suggest _SCREENICON OFF. But better solutions for this statement name is welcome. :)

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Change to _SCREENSHOW to restore from an icon
« Reply #8 on: January 12, 2021, 04:54:36 pm »
Two statements. That sounds reasonable. But removing the six older statements will affect the backward compatibility of older QB64 programs.

Aye, which is why it’ll probably always just be one of those, “I wish...”, type things for me.  The goal would be to simplify our keyword lists, not add to them, so I don’t think anyone would ever actually implement the extra two _SETSCREEN and _GETSCREEN commands.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Change to _SCREENSHOW to restore from an icon
« Reply #9 on: January 12, 2021, 05:41:22 pm »
Language improvements can be accomplished behind the scenes. That way, backward compatibility is recognized by the compiler. Eventually, the old stuff isn't used anymore. The problem is, that's a lot of extra work to develop.

For whatever it's worth, I'm with Steve on  implementing a way to undo the _SCREENICON statement.

Hey, did anyone try out that last example I posted? On my computer, It struggles to reproduce the hidden window, meaning it flashes quickly, probably 10's or 100's of time, before it crashes.

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

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: Change to _SCREENSHOW to restore from an icon
« Reply #10 on: January 12, 2021, 08:09:18 pm »
Code: [Select]
if (func_screenicon) that doesn't sound right.

Also please get your indentation right.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Change to _SCREENSHOW to restore from an icon
« Reply #11 on: January 12, 2021, 08:38:08 pm »
Code: [Select]
if (func_screenicon) that doesn't sound right.

Also please get your indentation right.

What’s wrong with the if?  func_screenicon is what we use to tell us if the screen has been iconified, or not.  It’s compiling and working for me, without tossing any errors or warnings.

And you’ll need to specify about the indentation more, as well.  It’s all as it was, with the exception of lines 6-8, which was the only things I altered.  Was it formatted different for you, somehow before?

Here’s how it looks in the repo right now:

Code: C++: [Select]
  1.          
  2.         void sub__screenshow(){
  3.             if (!window_exists){
  4.                 create_window=1;
  5.                 }else{
  6.                 #ifdef QB64_GLUT
  7.                     glutShowWindow();
  8.                 #endif
  9.             }
  10.             screen_hide=0;
  11.         }

What did I indent improperly when I inserted those 3 lines?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Change to _SCREENSHOW to restore from an icon
« Reply #12 on: January 12, 2021, 08:43:07 pm »
If the code was a mess, maybe he was just saying get "the" indentation right - like, while you're there, clean up the litter. I know, the previous people on that trail were slobs... Not really saying you caused the bad indentation.
You're not done when it works, you're done when it's right.

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: Change to _SCREENSHOW to restore from an icon
« Reply #13 on: January 12, 2021, 10:44:21 pm »
Function names without a () in C are function pointers, not calls.

(A) correct indentation would be
Code: [Select]
void sub__screenshow(){
    if (!window_exists){
        create_window=1;
    }else{
        #ifdef QB64_GLUT
            glutShowWindow();
        #endif
    }
    screen_hide=0;
}
This would be much easier if you made a merge request.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Change to _SCREENSHOW to restore from an icon
« Reply #14 on: January 12, 2021, 11:02:30 pm »
This would be much easier if you made a merge request.

Now I'm completely lost.  What am I merging?  I haven't pulled, or pushed, anything at all into the repo.  There's nothing to merge.  I was simply showcasing how simple it'd be to add this type of behavior into the language for us.  There's no reason to even try to push anything into the repo, when folks can't even agree on the basic syntax of the command, or even what a good name would be for it.

As I said in the first post: 
Quote
If you guys want this pushed into the repo, decide how you want it, and then feel free to implement whatever syntax suits you the best. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!