I have this code which works and puts a text gadget behind a canvas gadget.
Code: Select all
enableExplicit
declare zIndexBackGadget(Gadget.i)
define NrWin = OpenWindow(#PB_Any, 0, 0, 480, 320, "TestWindow")
if NrWin
define NrS = StringGadget(#PB_Any, 8, 12, 128, 32, "Test Text", #PB_String_BorderLess)
define NrC = CanvasGadget(#PB_Any, 8, 8, 32, 32)
define NrS1 = StringGadget(#PB_Any, 8, 48, 128, 32, "Test Text")
StartDrawing(CanvasOutput(NrC))
Box(0, 0, 32, 32, #Red)
Box(8, 8, 16, 16, RGB(0,0,1))
StopDrawing()
define P .POINT
define R .RECT
Repeat
define Event = WaitWindowEvent(25)
GetCursorPos_(P)
GetWindowRect_(GadgetID(NrS),R)
if PtInRect_(R, P\y << 32 + P\x)
zIndexBackGadget(NrS)
endif
Until Event = #PB_Event_CloseWindow
endif
procedure zIndexBackGadget(Gadget)
SetWindowLongPtr_(GadgetID(Gadget), #GWL_STYLE, GetWindowLongPtr_(GadgetID(Gadget), #GWL_STYLE) | #WS_CLIPSIBLINGS)
SetWindowPos_(GadgetID(Gadget), #HWND_BOTTOM, -1, -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE)
endProcedure ; zIndex_PBCadget
I have changed some things for SetWindowLongPtr_ and SetWindowPos_ but did not succeed.
(o.k., back or fore shouldn't matter; but with many gadgets can be helpful).
Any help apreciated!
Thanks!