Set Flat-Buttonstyle for gadget's (Windows only)

Share your advanced PureBasic knowledge/code with the community.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Set Flat-Buttonstyle for gadget's (Windows only)

Post by Rings »

works also with ButtonImageGadgets(they have no additional flags)

Code: Select all

Procedure SetFlat(gadgetnr)
 #bs_flat=$8000
 SetWindowLong_(GadgetID(gadgetnr),#gwl_style,GetWindowLong_(GadgetID(gadgetnr),#gwl_style) |#bs_flat)
EndProcedure

SPAMINATOR NR.1
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Hi!

Does the flat gadget style aplly to all MS Windows versions? I have only tested on XP Pro.
But does it work on all systems?
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

it works here on NT4-SP6 (IE 5.5) so it should also work under w2k and xp, never tested it under a win89 crook .
SPAMINATOR NR.1
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Ok thanks.
But it would be pretty nice to know if it is also running on win 98.
afterall i think those flat btns are looking great on some apps.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Post by GPI »

NOTE: Flat Buttons don't work on WinXP with XP-Style!

And by the way: Look in the code-archiev...
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

thefool wrote:But it would be pretty nice to know if it is also running on win 98.
yes, it works on '98fe
I tried it on the example gadget.pb
for gadget 5 (add button)

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Gadget example file
;
;    (c) 2002 - Fantaisie Software
;
; ------------------------------------------------------------
;

#WindowWidth  = 390
#WindowHeight = 350

Procedure SetFlat(gadgetnr)
#bs_flat=$8000
SetWindowLong_(GadgetID(gadgetnr),#gwl_style,GetWindowLong_(GadgetID(gadgetnr),#gwl_style) |#bs_flat)
EndProcedure 

If OpenWindow(0, 100, 200, #WindowWidth, #WindowHeight, #PB_Window_MinimizeGadget, "PureBasic - Gadget Demonstration")

 If CreateGadgetList(WindowID())
    
    Top = 10
    GadgetHeight = 24

    Frame3DGadget(#PB_Any, 10, Top, 370, 290, "Player...") : Top+20

    StringGadget(0,  20, Top, 200, GadgetHeight, "")
    ButtonGadget(1, 223, Top,  72, GadgetHeight, "Play")
    ButtonGadget(2, 295, Top,  72, GadgetHeight, "Stop")  : Top+35
    DisableGadget(2,1)
    
    GadgetToolTip(1,"Play the current song")
    
    PanelGadget(3, 20, Top, #WindowWidth-50, #WindowHeight-Top-60)
      AddGadgetItem(3, 0, "MP3 PlayList")
        ListViewGadget(4, 6, 10, 230, 148)

        For k=0 To 30
          AddGadgetItem(4, -1, "Music Song n° "+Str(k))
        Next

        ButtonGadget(5,  250, 10, 80, GadgetHeight, "Add")
        ButtonGadget(6,  250, 38, 80, GadgetHeight, "Remove")
        ButtonGadget(7,  250, 66, 80, GadgetHeight, "Select")
        GadgetToolTip(7, "Select the current song")
        
        TrackBarGadget(17, 10, 168, 310, 25, 0, 100)

      AddGadgetItem(3, 1, "Options")
        Top = 10
        CheckBoxGadget(10, 10, Top, 250, GadgetHeight, "Enable low-pass filter") : Top+30
        CheckBoxGadget(11, 10, Top, 250, GadgetHeight, "Enable visual plug-in")  : Top+30
        ComboBoxGadget(12, 10, Top, 250, 100) : Top+30
          AddGadgetItem(12, -1, "FireWorks")
          AddGadgetItem(12, -1, "OpenGL spectrum")
          AddGadgetItem(12, -1, "Bump bass")
        SetGadgetState(12,0)
        DisableGadget(12,1)
        
        OptionGadget(13, 10, Top, 80, GadgetHeight, "640*480") : Top+20
        OptionGadget(14, 10, Top, 80, GadgetHeight, "800*600") : Top+20
        OptionGadget(15, 10, Top, 80, GadgetHeight, "1024*768")
        SetGadgetState(13, 1)
        
        ButtonGadget(16, 150, Top, 80, GadgetHeight, "Info")
    CloseGadgetList()

    TextGadget  (9, 10, #WindowHeight-30, 250, 24, "PureBasic - Gadget demonstration")
    ButtonGadget(8, #WindowWidth-100, #WindowHeight-36, 80, 24, "Quit")

  EndIf
  
  SetGadgetState(3, 0)
  SetFlat(5)


  Repeat
    EventID = WaitWindowEvent()
    
    If EventID = #PB_EventGadget

      Select EventGadgetID()
        Case 0
          If EventType() = #PB_EventType_ReturnKey
            MessageRequester("Info", "Return key pressed", 0)
            ActivateGadget(0)
          EndIf
          
        Case 1 ; Play
          DisableGadget(2,0)  ; Enable the 'Stop' gadget
          DisableGadget(1,1)  ; Disable the 'Play' Gadget
      
        Case 2 ; Stop
          DisableGadget(1,0)  ; Enable the 'Play' gadget
          DisableGadget(2,1)  ; Disable the 'Stop' Gadget
        
        Case 4
          If EventType() = 2
            SetGadgetText(0, GetGadgetText(4)) ; Get the current item from the ListView..
          EndIf

        Case 5 ; Add
          AddGadgetItem(4, -1, "New Item Added...")

        Case 6 ; Remove
          RemoveGadgetItem(4, GetGadgetState(4)) ; Remove the current element of the ListView

        Case 7 ; Select
          SetGadgetText(0, GetGadgetText(4)) ; Get the current item from the ListView..
  
        Case 8 ; Quit...
          EventID = #PB_EventCloseWindow

        Case 11 ; Enable PlugIn..
          DisableGadget(12, 1-GetGadgetState(11))
          
        Case 16 ;
          If GetGadgetState(13) : Result$ = GetGadgetText(13) : EndIf
          If GetGadgetState(14) : Result$ = GetGadgetText(14) : EndIf
          If GetGadgetState(15) : Result$ = GetGadgetText(15) : EndIf
         
          MessageRequester("Info", "Selected screen mode: "+Result$, 0)
        
        Case 17
          SetGadgetText(0, Str(GetGadgetState(17)))
          
      EndSelect

    EndIf

  Until EventID = #PB_EventCloseWindow

EndIf

End 
:D
Joe
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
User avatar
NoahPhense
Addict
Addict
Posts: 1999
Joined: Thu Oct 16, 2003 8:30 pm
Location: North Florida

Re: Set Flat-Buttonstyle for gadget's (Windows only)

Post by NoahPhense »

Rings wrote:works also with ButtonImageGadgets(they have no additional flags)

Code: Select all

Procedure SetFlat(gadgetnr)
 #bs_flat=$8000
 SetWindowLong_(GadgetID(gadgetnr),#gwl_style,GetWindowLong_(GadgetID(gadgetnr),#gwl_style) |#bs_flat)
EndProcedure

Very nice..

- np
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

GPI wrote:NOTE: Flat Buttons don't work on WinXP with XP-Style!
thats only if you add manifest. If you dont, they will work.
Post Reply