ButtonGadget over ImageGadget

Just starting out? Need help? Post your questions and find answers here.
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 289
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

ButtonGadget over ImageGadget

Post 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 :)
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: ButtonGadget over ImageGadget

Post 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
Egypt my love
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 289
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

Re: ButtonGadget over ImageGadget

Post 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...
Image
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4991
Joined: Sun Apr 12, 2009 6:27 am

Re: ButtonGadget over ImageGadget

Post 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
Egypt my love
User avatar
le_magn
Enthusiast
Enthusiast
Posts: 289
Joined: Wed Aug 24, 2005 12:11 pm
Location: Italia

Re: ButtonGadget over ImageGadget

Post by le_magn »

Thank you very much Rashad this code work!!!
Image
Post Reply