First, please use
Code: Select all
SetWindowLongPtr_() ; because SetWindowLong_() does not work on 64 bit
See MSDN for further information.
Second,
they say that windows implement the rule that a window that is transparent to the user's eye is transparent to the mouse as well.
This is the best I could make so far......
Code: Select all
SetWindowLongPtr_(hwCanvas, #GWL_EXSTYLE, GetWindowLongPtr_(hwCanvas, #GWL_EXSTYLE) | #WS_EX_LAYERED)
SetLayeredWindowAttributes_(hwCanvas, #White, 100, #LWA_ALPHA) ; <-- 0 < 100 < 255
My Test-App (borrowed from Help and modified a little bit)
Code: Select all
Macro SetWindowExStyle(HWnd, ExStyle)
SetWindowLongPtr_(HWnd, #GWL_EXSTYLE, GetWindowLongPtr_(HWnd, #GWL_EXSTYLE) | ExStyle)
EndMacro
If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 10, 10, 200, 100)
TextGadget(1, 10, 80, 200, 100, "Text for test"+#LF$+"Second Line of Text "+#LF$+"Third Line of Text ")
SetWindowExStyle(GadgetID(0), #WS_EX_LAYERED)
SetLayeredWindowAttributes_(GadgetID(0), #White, 100, #LWA_ALPHA)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 0
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(0, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(0))
x = GetGadgetAttribute(0, #PB_Canvas_MouseX)
y = GetGadgetAttribute(0, #PB_Canvas_MouseY)
Circle(x, y, 4, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
ElseIf EventType() = #PB_EventType_MouseLeave
If StartDrawing(CanvasOutput(0))
Box(0, 0, OutputWidth(), OutputHeight(), #White)
StopDrawing()
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf