Flat Buttons In PB

Share your advanced PureBasic knowledge/code with the community.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Flat Buttons In PB

Post by Num3 »

Courtesy of Windows API

Code: Select all

Declare Open_Window_0()

;- Window Constants
;
#Window_0  = 0
#BS_FLAT  = $8000
#GWL_STYLE  =  - 16
#WS_CHILD  = $40000000
;- Gadget Constants
;
#Gadget_0  = 0


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 251, 249, 191, 300, #PB_Window_SystemMenu  | #PB_Window_SizeGadget  | #PB_Window_TitleBar , "Flat Button")
    If CreateGadgetList(WindowID())
      ButtonGadget(#Gadget_0,  25, 100, 140, 40, "Flat Button")
      setwindowlong_(GadgetID(#gadget_0), #GWL_STYLE,  #BS_FLAT)
      HideGadget(#Gadget_0,  0) ; Need to redraw the gadget after changing it's style :(
    EndIf
  EndIf
EndProcedure


open_window_0()
Repeat
  Event  = WaitWindowEvent()
  
  
Until Event  = #PB_EventCloseWindow
CODE EDITED (THANKS GPI!!!)

Code: Select all

Declare Open_Window_0()

;- Window Constants
;
#Window_0  = 0
#BS_FLAT  = $8000
;- Gadget Constants
;
#Gadget_0  = 0


Procedure Open_Window_0()
  If OpenWindow(#Window_0, 251, 249, 191, 300, #PB_Window_SystemMenu  | #PB_Window_SizeGadget  | #PB_Window_TitleBar , "Flat Button")
    If CreateGadgetList(WindowID())
      ButtonGadget(#Gadget_0,  25, 100, 140, 40, "Flat Button",#BS_FLAT)

    EndIf
  EndIf
EndProcedure


open_window_0()
Repeat
  Event  = WaitWindowEvent()
  
  
Until Event  = #PB_EventCloseWindow
Last edited by Num3 on Sun Jun 15, 2003 12:40 am, edited 1 time in total.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: Flat Buttons In PB

Post by GPI »

this is shorter

Code: Select all

      ButtonGadget(#Gadget_0,  25, 100, 140, 40, "Flat Button",#bs_flat)
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

I search the same tip but for ButtonImage ...
To do a toolbar button
Post Reply