Page 1 of 1

Remove ButtonGadget border

Posted: Fri May 12, 2023 2:32 pm
by Ross Carter
First time using PureBasic, and would like to know if it is possible to display a button using ButtonGadget with no border.

I would be grateful if anyone could help with this problem.

Re: Remove ButtonGadget border

Posted: Fri May 12, 2023 2:47 pm
by jacdelad
Code from uwekel:

Code: Select all

If OpenWindow(0, 0, 0, 300, 200, "Borderless Button", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(0, 10, 10, 80, 40, "Test")
  gtk_button_set_relief_(GadgetID(0), 2)
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
...if you are on Linux. Since you didn't specify your OS...

Re: Remove ButtonGadget border

Posted: Fri May 12, 2023 2:59 pm
by Kiffi
Possible but cumbersome (and possibly cross-platform):

Code: Select all

Enumeration
  #Window
  #Container
  #Button
EndEnumeration

If OpenWindow(#Window, 0, 0, 322, 150, "ButtonGadget without border", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ContainerGadget(#Container, 10, 10, 100, 100)
    ButtonGadget(#Button, -4, -4, 108, 108, "Button 1")
  CloseGadgetList()
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

Re: Remove ButtonGadget border

Posted: Sat May 13, 2023 4:22 am
by Ross Carter
Thanks for the code, jacdelad, and Kiffi, the code works fine for displaying only one button, but having a problem trying to display two buttons within the same window.

I would be grateful if anyone could help with this problem.

Re: Remove ButtonGadget border

Posted: Sat May 13, 2023 5:02 am
by RASHAD
Hi Ross Carter
You can use HyperLinkGadget() instead
Or
If you are Windows User you can use TextGadget() with #SS_Notify
Or Owner Drawn Gadget
There are many alternative in this case

Code: Select all

OpenWindow(0, 0, 0, 270, 160, "HyperLinkButton", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  HyperLinkGadget(0, 10, 10, 80,22," Button #1",$0000FF)
  HyperLinkGadget(1, 10, 45, 80,22," Button #2",$00FF00)
  HyperLinkGadget(2, 10, 80, 80,22," Button #3",$FF0000)
  SetGadgetColor(0,#PB_Gadget_BackColor,$E8E9FE)
  SetGadgetColor(1,#PB_Gadget_BackColor,$E8FEEE)
  SetGadgetColor(2,#PB_Gadget_BackColor,$FEEEE8)
Repeat
  Select WaitWindowEvent()
    Case #PB_Event_CloseWindow
           Quit = 1
           
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 0,1,2
          Debug "Button "+Str(EventGadget())
      EndSelect
  EndSelect
Until Quit = 1

Re: Remove ButtonGadget border

Posted: Sat May 13, 2023 4:32 pm
by Ross Carter
Thanks RASHAD for your code, I never would have thought about using the HyperLinkGadget, it works fine.

Re: Remove ButtonGadget border

Posted: Sat May 13, 2023 6:30 pm
by Caronte3D
Wow! Thi's a nice way of have colored button with mouseover effect :shock:
Another awesome trik from RASHAD :D