Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What bone-head thing did I miss this time?
#11
@bplus You're welcome, anytime!

@Spriggsy

I tried your method, and yep, it works the same as mine, only yours takes advantage of using QB64 keywords to do what the API calls do. So I think what we have here is a situation where Windows never accounted for another window transferring control to another window. In other words the developers expect users to click a window to activate it. What bugs me is that the developers coded the system to activate a window that is moving from the task bar back to the desktop. That means there must be some command to activate it after it gets restored.I would think that would be available for use as API users, but so far, I can't figure out if I'm missing something or if such a command was simply not made public.

Thanks for having a look. Yep, great minds think alike alright, which means Bill's in real trouble! Big Grin

Pete
Reply
#12
(10-29-2022, 01:56 AM)bplus Wrote: This is pretty cool. I remember somewhere, sometime we discussed how to keep a Window on top but danged if I could find the code.

This works, is it the same thing?

Keeping a window on top isn't that hard in Windows.

Code: (Select All)
'public domain

Const SWP_NOSIZE = &H0001 'ignores cx and cy size parameters
Const SWP_NOMOVE = &H0002 'ignores x and y position parameters
Const SWP_NOZORDER = &H0004 'keeps z order and ignores hWndInsertAfter parameter
Const SWP_NOREDRAW = &H0008 'does not redraw window changes
Const SWP_NOACTIVATE = &H0010 'does not activate window
Const SWP_FRAMECHANGED = &H0020
Const SWP_SHOWWINDOW = &H0040
Const SWP_HIDEWINDOW = &H0080
Const SWP_NOCOPYBITS = &H0100
Const SWP_NOOWNERZORDER = &H0200
Const SWP_NOSENDCHANGING = &H0400
Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Const SWP_DEFERERASE = &H2000
Const SWP_ASYNCWINDOWPOS = &H4000
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

Declare Dynamic Library "user32"
    '    Function FindWindowA%& (ByVal lpClassName%&, Byval lpWindowName%&)
    Function SetWindowPos& (ByVal hWnd%&, Byval hWndInsertAfter%&, Byval X&, Byval Y&, Byval cx&, Byval cy&, Byval uFlags~&)
    Function GetForegroundWindow%&
End Declare

Declare Dynamic Library "kernel32"
    Function GetLastError~& ()
End Declare

Dim hWnd As _Offset





_Title "This Window will always be on Top" 'any title

_Delay 4 'delay allows user to click focus on other windows
hWnd = _WindowHandle 'FindWindowA(0, _OFFSET(t))
If 0 = SetWindowPos(hWnd, HWND_TOPMOST, 200, 200, 0, 0, SWP_NOSIZE Or SWP_NOACTIVATE) Then
    Print "SetWindowPos failed. 0x" + LCase$(Hex$(GetLastError))
End If



Do
    x%& = GetForegroundWindow%& 'find currently focused process handle
    Locate 3, 1
    Print "Program handle:"; hWnd; "Focus handle:"; x%&

    _Limit 30
Loop Until _KeyDown(27)

Edit:  I keep posting twice for the same thing??
Reply
#13
Thumbs Up 
OK that looks good too, all those constants will hint at further API abilities plus a 3rd code to lose!

Thanks to all 3 API pros!
b = b + ...
Reply




Users browsing this thread: 5 Guest(s)