Author Topic: Help to unbury QB64 window under other windows  (Read 3986 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Help to unbury QB64 window under other windows
« on: September 07, 2019, 11:30:04 am »
I got a qb64 program monitoring the clipboard for input from other windows.  After responding to the clipboard I need to enter by hand a number to an input question.  My problem is with qb64 window buried under what could be many other windows.  It becomes a hassle.  I have tried using via shell a program called "CMDOW".  Very handy program I use with bat's and cmd's.  According to CMDOW using /min and /res.  Should bring the qb64 window to the focus and top window level.  Not always happening.

To the point.  While looking over some other commands inside QB64 (examples).  I happened across "display" command a while back.  I moved on keeping a mental note of it.  I now got the time to revisit that problem program.  After looking at "display" again.  Going over the command and examples, it read "This way" but everything in my head "Went that way".

So can you please provide a simple example for me ?
Does not have to be elaborate.  Simple for a simpleton.
Or maybe it was a mental defect on my part and it's not "display" command I am after.

Thanks

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: Help to unbury QB64 window under other windows
« Reply #1 on: September 07, 2019, 11:47:26 am »
Simply forget about, _DISPLAY will not solve your problem, it does not bring your program window into focus.

All what _DISPLAY does is updating the content shown in your program window according to the actual _DEST (destination write page), but it will not bring the window to the top level.

AFAIK there's no QB64 internal command to bring the window upfront, all we have is _WINDOWHASFOCUS to check whether the program window currently has focus or not.
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Re: Help to unbury QB64 window under other windows
« Reply #2 on: September 07, 2019, 12:03:22 pm »
Rats, "_DISPLAY" wasn't the route to take.  Maybe I will play with "CMDOW" and _WINDOWHASFOCUS to get my QB64 program on top and focus. I will beat it with a stick until it does what I want or die trying.  10 Wacks should do it before I call it dead.

Maybe we need something like.  _WINDOWTOP(titleofwindow) and_WINDOWFORCEFOCUS(titleofwindow).
For what it's worth _WINDOWMIN(tittleofwindow) too.

Thanks saved me loads of time.


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Help to unbury QB64 window under other windows
« Reply #3 on: September 07, 2019, 12:25:26 pm »
Has anyone tried resizing the window? that might pop it up? justa thought

Can we do a Min/Max with QB64?

Marked as best answer by doppler on September 08, 2019, 03:47:36 am

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Help to unbury QB64 window under other windows
« Reply #4 on: September 07, 2019, 12:59:03 pm »
An easy task to accomplish in Windows, using DECLARE LIBRARY for us:

Code: QB64: [Select]
  1.     FUNCTION GetKeyState% (BYVAL nVirtKey AS LONG) 'reads Windows key presses independently
  2.     FUNCTION ShowWindow& (BYVAL hwnd AS LONG, BYVAL nCmdShow AS LONG) 'minimize or maximize
  3.     FUNCTION SetWindowPos& (BYVAL hWnd%&, BYVAL hWndInsertAfter%&, BYVAL X&, BYVAL Y&, BYVAL cx&, BYVAL cy&, BYVAL uFlags~&)
  4.  
  5.  
  6.  
  7.  
  8. PRINT "SHIFT-A has drawn my window back into focus!"
  9.  
  10.     IF GetKeyState(16) < 0 AND GetKeyState(65) < 0 THEN '<==== Shift+A
  11.         y& = ShowWindow&(hwnd&, 1) 'make certain to show the window in case it was minimized or hidden
  12.         y& = SetWindowPos&(hwnd&, HWND_TOPMOST, 200, 200, 0, 0, 17) 'move it to the top of the stack of windows
  13.     END IF
  14.     _LIMIT 30
  15.  

This makes a small program and then hides it from us, while assigning a hotkey which we can hit to bring it back into focus and move it on top of all our other programs.  (In this case, Shift-A -- feel free to assign a different hotkey which you won't be using normally, such as Shift-~ or such.)

Run the demo, hit Shift-A and you can bring it to the foreground of your windows.  Bury it underneath your web browser, or other stuff, and shift-A will pop it back up on top of them for you.  Just a few extra lines in your program, and you shouldn't have any problem getting it where you can pop it back up quickly, no matter how buried it becomes on your system.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Re: Help to unbury QB64 window under other windows
« Reply #5 on: September 07, 2019, 04:54:06 pm »
Hmmm, interesting.  I am glad you are fluent in windose-ezz.

Looking at the code.  It will bring it to the top but.  Resize it to 200x200 at pos 0,0.
Am I looking at it wrong ?

I am looking to just big it up top level.  So wouldn't it be possible to change about

ShowWindow&(important stuff)
GetWindowPos&(important stuff)
SetWindowPos&(important stuff)

I already have a trigger point with the program (not needing a keystroke to activate).
The newy part being GetWindowPos& or maybe including GetWindowSize& needed to
before executing SetWindowPos&

Windows may ignore the set command, since the window is already there.  I really
never learned windows mid level programming.  So please be kind.  I got too many
other mid level and low level O/S's in my head.  Very confusing at times.

I like where this is going, everybody including me might get another trick to put
in the bag.

BTW, where is the value for HWND_TOPMOST set ?  Or is zero the right value ?

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Help to unbury QB64 window under other windows
« Reply #6 on: September 07, 2019, 05:05:35 pm »
Hmmm, interesting.  I am glad you are fluent in windose-ezz.

Looking at the code.  It will bring it to the top but.  Resize it to 200x200 at pos 0,0.
Am I looking at it wrong ?

I am looking to just big it up top level.  So wouldn't it be possible to change about

ShowWindow&(important stuff)
GetWindowPos&(important stuff)
SetWindowPos&(important stuff)

I already have a trigger point with the program (not needing a keystroke to activate).
The newy part being GetWindowPos& or maybe including GetWindowSize& needed to
before executing SetWindowPos&

Windows may ignore the set command, since the window is already there.  I really
never learned windows mid level programming.  So please be kind.  I got too many
other mid level and low level O/S's in my head.  Very confusing at times.

I like where this is going, everybody including me might get another trick to put
in the bag.

BTW, where is the value for HWND_TOPMOST set ?  Or is zero the right value ?

Sorry.  I forgot to post the applicable CONST values for use for you:

CONST HWND_TOP = 0        'window at top of z order no focus
CONST HWND_BOTTOM = 1     'window at bottom of z order no focus
CONST HWND_TOPMOST = -1   'window above all others no focus unless active
CONST HWND_NOTOPMOST = -2 'window below active no focus

And we're not resizing the window; that 200,200 was just where I decided to place it on my desktop (200 pixels down and right from the top left corner.)

    FUNCTION SetWindowPos& (BYVAL hWnd%&, BYVAL hWndInsertAfter%&, BYVAL X&, BYVAL Y&, BYVAL cx&, BYVAL cy&, BYVAL uFlags~&)

hWnd%& -- our _WINDOWHANDLE
hWndInsertAfter%& -- how we want it to display (On top of everything in this case)
X, Y -- where we want to window to move to, on our display
cx, cy -- resize options for the window, if we want to do so.  Just leave them 0 to leave your window settings alone.
uflags -- The window sizing and positioning flags.

https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowpos -- You can get a good run down of those parameters and such from microsoft here.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Re: Help to unbury QB64 window under other windows
« Reply #7 on: September 07, 2019, 05:59:02 pm »
Well since I already had a position in the program.  200,200 became a move for me.
No matter I just subsisted my _screenmove values for the  X and Y.

As a side note: The window did become top window with an arbitrary focus (could
be ON or OFF).  Suited my need, answered my input question.  But the window
remained on top always.  I threw in another HWND_BOTTOM call to get it off top
after the input question was done.

Another trick for the bag.
Funny thing about my trick bag, I never seems to fill it up.

Thanks for the help.


Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: Help to unbury QB64 window under other windows
« Reply #8 on: September 08, 2019, 01:32:32 pm »
Hi Doppler

about position of window on the desktop there are these two QB64 functions... _ScreenX and _ScreenY so at the place of 200,200 you can put them

Code: QB64: [Select]
  1. y& = SetWindowPos&(hwnd&, HWND_TOPMOST, _SCREENX,_SCREENY, 0, 0, 17) 'move it to the top of the stack of windows
just play with window moving it in different positions on the desktop, as you can see the window comes back on the exact position.
Programming isn't difficult, only it's  consuming time and coffee

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Re: Help to unbury QB64 window under other windows
« Reply #9 on: September 08, 2019, 02:39:00 pm »
_screenx and _screeny better than hard-coding my _screenmove values.  Then again if i move it around it will follow.

Very helpful.

edit: i figured out how to get around the windows when brought to the top not having focus all the time.
I used the program I mentioned before "CMDOW".  Using the /act to make it active and when I downsized it
I following again with /dis.  Just to make sure of no window input to it.

CMDOW has to much going for it to ignore.
https://ritchielawrence.github.io/cmdow/
« Last Edit: September 08, 2019, 03:00:51 pm by doppler »