*** post was a little bloated (I kept adding to it)

so I edited it down to a very basic example ***
Code: Select all
Global WM_SHELLHOOKMESSAGE
Prototype.b protoDeregisterShellHookWindow(hWnd)
Global DeregisterShellHookWindow.protoDeregisterShellHookWindow
Structure SHELLHOOKINFO
hWnd.l
rc.RECT
EndStructure
Procedure WindowProc(hWnd, Msg, wParam, lParam)
If Msg And Msg = WM_SHELLHOOKMESSAGE
If wParam = #HSHELL_GETMINRECT
sHook.SHELLHOOKINFO
CopyMemory(lParam, sHook, SizeOf(sHook))
hWindow = sHook\hWnd
Else
hWindow = lParam
EndIf
lpwndpl.WINDOWPLACEMENT
lpwndpl\Length = SizeOf(lpwndpl)
GetWindowPlacement_(hWindow, @lpwndpl)
Select lpwndpl\showCmd
Case 0
Debug Str(hWindow) + ": Hidden"
Case 1
Debug Str(hWindow) + ": Restored"
Case 2
Debug Str(hWindow) + ": Minimized"
Case 3
Debug Str(hWindow) + ": Maximized"
Default
Debug Str(hWindow) + ": Other: " + Str(lpwndpl\showCmd)
EndSelect
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
If OpenWindow(0, 0, 0, 200, 100, "Shell Hook Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
user32 = OpenLibrary(#PB_Any, "user32.dll")
If IsLibrary(user32)
DeregisterShellHookWindow = GetFunction(user32, "DeregisterShellHookWindow")
If DeregisterShellHookWindow
If RegisterShellHookWindow_(WindowID(0))
WM_SHELLHOOKMESSAGE = RegisterWindowMessage_("SHELLHOOK")
SetWindowCallback(@WindowProc())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
DeregisterShellHookWindow(WindowID(0))
EndIf
EndIf
CloseLibrary(user32)
EndIf
EndIf