Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
setting program to display always on top of other windows without having the focus?
#11
Const SWP_NOMOVE = &H0002 'ignores x and y position parameters
Reply
#12
Do both programs have to be in the same place on the monitor?
If not, you can change these lines.

Code: (Select All)
If 0 = SetWindowPos(hWnd, HWND_TOPMOST, 840, 200, 0, 0, SWP_NOSIZE Or SWP_NOACTIVATE) Then  

und 
Code: (Select All)
  _ScreenClick 880, 240 ' add 40 to x and y to focus on positioned window      

This means that both programs would be next to each other, but only the one that is set to foreground remains in the foreground and the other one
could then fade into the background.
I don't know what you're trying to do, maybe you could also play around with the command (_SCREENICON).
So that the program that is not in the foreground disappears from the monitor?
Reply
#13
Sorry.  I didn't notice the need for _SCREENCLICK.   What you're looking for is:

https://qb64phoenix.com/qb64wiki/index.php/SCREENX
https://qb64phoenix.com/qb64wiki/index.php/SCREENY
Reply
#14
(05-20-2024, 07:24 PM)Steffan-68 Wrote: Do both programs have to be in the same place on the monitor?
Yes, see below for why... 

(05-20-2024, 07:28 PM)SMcNeill Wrote: Sorry.  I didn't notice the need for _SCREENCLICK.   What you're looking for is:
https://qb64phoenix.com/qb64wiki/index.php/SCREENX
https://qb64phoenix.com/qb64wiki/index.php/SCREENY

Thanks for the info. Now I'm going to switch gears and show you what this was all for:
reading multiple mice from QB64PE

Basically, I have 2 programs running, where program A is just for reading separate input from multiple mice plugged into the computer,
but doesn't display anything to the screen. It needs to have the focus and be positioned directly under the other window, 
Program B, which is the main program gets the mouse coordinates from program A, and displays stuff on the screen.
It needs to be on top, but can't have the focus, or else program A won't work.
The two windows need to be sitting on top of each other so the user's mouse movements line up with the display.

(I would like to get everything working in one program, but to do that Spriggsy thought that both would have to have the same window handle registered, but we never really figured that out. So I came up with this kludgey 2-program solution!)
Reply
#15
(05-20-2024, 07:28 PM)SMcNeill Wrote: Sorry.  I didn't notice the need for _SCREENCLICK.   What you're looking for is:

https://qb64phoenix.com/qb64wiki/index.php/SCREENX
https://qb64phoenix.com/qb64wiki/index.php/SCREENY
I think I need the opposite of _SCREENCLICK - I need to make the program on top un-clickable, so that it doesn't steal the focus -and mouse click event- from the program underneath that has the focus, and reads all the mouse input. Is it possible to make a window not-clickable?
Reply
#16
(05-18-2024, 08:17 PM)SMcNeill Wrote:
(05-18-2024, 04:20 PM)grymmjack Wrote: I wonder if it's possible to do this on Mac and Linux? If so, maybe we could add a $WINDOW_ONTOP:ON or something?

How difficult is it to add new things to the QB64PE sourcecode?

Has anyone ever documented that, or the steps required in a tutorial? We might be able to cast a wider net of PRs if we did.

https://qb64forum.alephc.xyz/index.php?t...#msg108485   <-- There's my original guide to adding/altering QB64.  Things may have been shuffled a bit (as we expand, we've restructured the folders a bit), but it's still the same basic process as it was back when I wrote that oh-so-many-moons-ago!   Smile

Thanks @SMcNeill. I'll review this.

This seems too easy Smile (i kid)
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#17
(05-20-2024, 07:39 PM)madscijr Wrote:
(05-20-2024, 07:24 PM)Steffan-68 Wrote: Do both programs have to be in the same place on the monitor?
Yes, see below for why... 

(05-20-2024, 07:28 PM)SMcNeill Wrote: Sorry.  I didn't notice the need for _SCREENCLICK.   What you're looking for is:
https://qb64phoenix.com/qb64wiki/index.php/SCREENX
https://qb64phoenix.com/qb64wiki/index.php/SCREENY

Thanks for the info. Now I'm going to switch gears and show you what this was all for:
reading multiple mice from QB64PE

Basically, I have 2 programs running, where program A is just for reading separate input from multiple mice plugged into the computer,
but doesn't display anything to the screen. It needs to have the focus and be positioned directly under the other window, 
Program B, which is the main program gets the mouse coordinates from program A, and displays stuff on the screen.
It needs to be on top, but can't have the focus, or else program A won't work.
The two windows need to be sitting on top of each other so the user's mouse movements line up with the display.

(I would like to get everything working in one program, but to do that Spriggsy thought that both would have to have the same window handle registered, but we never really figured that out. So I came up with this kludgey 2-program solution!)

@madscijr I have to ask. Why are you using 2 mice at once? LOL! My brain can barely handle 1 mouse at a time. This sounds fascinating and I'm really curious why you'd want to do this. Your ingenious approach is fascinating as well. Goes to show where there is a will there is a way.
grymmjack (gj!)
GitHubYouTube | Soundcloud | 16colo.rs
Reply
#18
(05-21-2024, 04:04 AM)grymmjack Wrote:
(05-20-2024, 07:39 PM)madscijr Wrote:
(05-20-2024, 07:24 PM)Steffan-68 Wrote: Do both programs have to be in the same place on the monitor?
(05-20-2024, 07:28 PM)SMcNeill Wrote: Sorry.  I didn't notice the need for _SCREENCLICK.
Thanks for the info. Now I'm going to switch gears and show you what this was all for:
reading multiple mice from QB64PE
@madscijr I have to ask. Why are you using 2 mice at once? LOL! My brain can barely handle 1 mouse at a time. This sounds fascinating and I'm really curious why you'd want to do this. Your ingenious approach is fascinating as well. Goes to show where there is a will there is a way.
Ha! OK this is going to sound ridiculous, but my initial motivation was simple: 
I want to make 4-player or 8-player Pong games, that people can play on the same computer where everyone gets a mouse!  Tongue
Even a 2-player Pong game - why in the 40 years since PCs have had mouses, has no one ever done this? 
How many Pong games have you seen where the players have to use a keyboard? What is this crap?? LOL
For paddle games to be playable you need a mouse! 
It's long overdue! USB optical mice are cheap and plentiful. 

Beyond that, multiple mice will be useful for games, or collaborative drawing, puzzles, etc. 

Anything that needs a pointer or a spinner. 

And racing games - it's super easy and cheap to turn an optical mouse into a racing wheel - all you need is a broom handle or wood dowel with a wheel at one end, and 6 or so inches of the other end stuck into a section of foam pool noodle. Then you just mount the mouse against that with duck tape or whatever, and voila! Instant racing wheel! It works great for games like Super Sprint in MAME, I've tried it. But to make multiplayer games like Indy 800, we need multiple mice!  Big Grin

Taking the idea even further, did you know the Raw Input API can also do keyboards? 
What about a split-screen multiplayer text adventure or coding game, where each player has their own keyboard and can fully type? 
With the Raw Input API, we can do that!!
Reply
#19
Maybe you can do something with these programs.
The first always keeps the window in the foreground and also gives it focus.
With the second you can make the window invisible.
You just have to think about how you can shoot it again if you can't see it.

Code: (Select All)
Declare Dynamic Library "user32"
    Sub ShowWindow (ByVal hWnd As _Offset, Byval nCmdShow As Long)
End Declare

title$ = "Set Window Active Test"
_Title title$
_Delay .1

Do
    hwnd%& = _WindowHandle
Loop Until hwnd%&


Do
    _Limit 10
    If _WindowHasFocus = 0 Then
        _ScreenIcon
        ShowWindow hwnd%&, 1
    End If
    Cls
    Print hwnd%&
    Sleep 1
    If Len(InKey$) Then End
Loop


Code: (Select All)
Declare Dynamic Library "user32"
    Function SetLayeredWindowAttributes& (ByVal hwnd As Long, Byval crKey As Long, Byval bAlpha As _Unsigned _Byte, Byval dwFlags As Long)
    Function GetWindowLong& Alias "GetWindowLongA" (ByVal hwnd As Long, Byval nIndex As Long)
    Function SetWindowLong& Alias "SetWindowLongA" (ByVal hwnd As Long, Byval nIndex As Long, Byval dwNewLong As Long)
End Declare

' Needed for acquiring the hWnd of the window
Declare Library
    Function FindWindow& (ByVal ClassName As _Offset, WindowName$) ' To get hWnd handle
End Declare

MyHwnd = _WindowHandle 'FindWindow(0, "Translucent window test" + CHR$(0))
Level = 150 '0 TO 255
SetWindowOpacity MyHwnd, Level

Sub SetWindowOpacity (hWnd As Long, Level)
    Dim Msg As Long
    Const G = -20
    Const LWA_ALPHA = &H2
    Const WS_EX_LAYERED = &H80000

    Msg = GetWindowLong(hWnd, G)
    Msg = Msg Or WS_EX_LAYERED
    Crap = SetWindowLong(hWnd, G, Msg)
    Crap = SetLayeredWindowAttributes(hWnd, 0, Level, LWA_ALPHA)

End Sub

Reply
#20
(05-21-2024, 06:54 PM)Steffan-68 Wrote: Maybe you can do something with these programs.
The first always keeps the window in the foreground and also gives it focus.
With the second you can make the window invisible.
You just have to think about how you can shoot it again if you can't see it.
Thank you - I'll give that a look!
Reply




Users browsing this thread: 5 Guest(s)