Page 1 of 1
ButtonGadget over ImageGadget
Posted: Mon Nov 25, 2024 12:38 am
by le_magn
Hi all, I would like to know if there is a way to place a buttongadget or other type of gadget on top of an imagegadget, so that the button gadget is in the foreground but can receive the events of the imagegadget as well, if I disable the imagegadget the button works but I don't receive the events of the imagegadget anymore, thanks

Re: ButtonGadget over ImageGadget
Posted: Mon Nov 25, 2024 1:06 am
by RASHAD
Hi
Code: Select all
If CreateImage(0, 255, 255)
StartDrawing(ImageOutput(0))
For k=0 To 255
FrontColor(RGB(k,0, k)) ; a rainbow, from black to pink
Line(0, k, 255, 1)
Next
DrawingMode(#PB_2DDrawing_Transparent)
FrontColor(RGB(255,255,255)) ; print the text to white !
DrawText(40, 50, "An image easily created !")
StopDrawing()
EndIf
flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,400,300,"Test",Flags)
ImageGadget(0,10,10,40,40,ImageID(0))
DisableGadget(0,1)
ButtonGadget(1,20,20,80,24,"TEST")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Debug "OK"
EndSelect
EndSelect
Until Quit = 1
End
Re: ButtonGadget over ImageGadget
Posted: Mon Nov 25, 2024 1:27 am
by le_magn
Hi Rashad and thanks for your example, but i need to use also the image gadget event not only the button event, if imagegadget is disabled event is not generated...
Re: ButtonGadget over ImageGadget
Posted: Mon Nov 25, 2024 1:56 am
by RASHAD
Code: Select all
If CreateImage(0, 255, 255)
StartDrawing(ImageOutput(0))
For k=0 To 255
FrontColor(RGB(k,0, k)) ; a rainbow, from black to pink
Line(0, k, 255, 1)
Next
DrawingMode(#PB_2DDrawing_Transparent)
FrontColor(RGB(255,255,255)) ; print the text to white !
DrawText(40, 50, "An image easily created !")
StopDrawing()
EndIf
flags = #PB_Window_SystemMenu| #PB_Window_MaximizeGadget| #PB_Window_MinimizeGadget| #PB_Window_ScreenCentered | #PB_Window_SizeGadget
OpenWindow(0,0,0,400,300,"Test",Flags)
ImageGadget(1,10,10,40,40,ImageID(0))
ButtonGadget(2,20,20,80,24,"TEST")
ButtonGadget(3,20,60,80,24,"TEST 2")
SetWindowLongPtr_(GadgetID(1), #GWL_STYLE, GetWindowLongPtr_(GadgetID(1), #GWL_STYLE) | #WS_CLIPSIBLINGS)
SetWindowPos_(GadgetID(1), #HWND_BOTTOM, -1, -1, -1, -1, #SWP_NOSIZE | #SWP_NOMOVE)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Debug "1"
Case 2
Debug "2"
Case 3
Debug "3"
EndSelect
EndSelect
Until Quit = 1
End
Re: ButtonGadget over ImageGadget
Posted: Mon Nov 25, 2024 2:16 am
by le_magn
Thank you very much Rashad this code work!!!