sorry if you don't understand my english - i went to school in california.

thanks for any help,
mike
Code: Select all
Enumeration
#hWnd
EndEnumeration
Enumeration
#ButtonImage_0
#ButtonImage_1
#ButtonImage_2
#Frame3D_0
EndEnumeration
SystemPath.s = Space(255)
Result = GetSystemDirectory_(SystemPath.s, 255)
Global Image0,Image1,Image2,Image3,Image4,Image5
Image0 = ExtractIcon_(0, SystemPath + "\Shell32.dll", 10)
Image1 = ExtractIcon_(0, SystemPath + "\Shell32.dll", 11)
Image2 = ExtractIcon_(0, SystemPath + "\Shell32.dll", 21)
Image3 = ExtractIcon_(0, SystemPath + "\Shell32.dll", 15)
Image4 = ExtractIcon_(0, SystemPath + "\Shell32.dll", 18)
Image5 = ExtractIcon_(0, SystemPath + "\Shell32.dll", 61)
Procedure Open_hWnd()
If OpenWindow(#hWnd, 290, 255, 261, 106, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar , "Icon Example")
If CreateGadgetList(WindowID())
ButtonImageGadget(#ButtonImage_0, 30, 20, 60, 60, Image0)
ButtonImageGadget(#ButtonImage_1, 100, 20, 60, 60, Image1)
ButtonImageGadget(#ButtonImage_2, 170, 20, 60, 60, Image2)
Frame3DGadget(#Frame3D_0, 10, 10, 240, 80, "")
EndIf
EndIf
EndProcedure
Open_hWnd()
Repeat
Event = WaitWindowEvent()
If Event = #PB_EventGadget
GadgetID = EventGadgetID()
If GadgetID = #ButtonImage_0
; we will change it only once..
SetGadgetState(#ButtonImage_0,Image3)
ElseIf GadgetID = #ButtonImage_1
; we will change it on every click from one to the other
enable=1-enable
If enable = 1
SetGadgetState(#ButtonImage_1,Image4)
Else
SetGadgetState(#ButtonImage_1,Image1)
EndIf
ElseIf GadgetID = #ButtonImage_2
; we will loop through some of the icons
; the lazy-guy way :)
Img + 1
If Img = 1
SetGadgetState(#ButtonImage_2,Image0)
ElseIf Img = 2
SetGadgetState(#ButtonImage_2,Image1)
ElseIf Img = 3
SetGadgetState(#ButtonImage_2,Image2)
ElseIf Img = 4
SetGadgetState(#ButtonImage_2,Image3)
ElseIf Img > 4
SetGadgetState(#ButtonImage_2,Image4)
Img = 0
EndIf
EndIf
EndIf
Until Event = #PB_EventCloseWindow
End
;change icons example by gushh...
Code: Select all
SystemPath.s = Space(255)
Result = GetSystemDirectory_(SystemPath.s, 255)
Image0 = ExtractIcon_(0, SystemPath + "\Shell32.dll", 10)
Code: Select all
Image0 = ExtractIcon_(0, "Shell32.dll", 10)
Code: Select all
spin = SpinGadget(#SpinGadget_0, 120, 0, 30, 20, 5, 15)
Code: Select all
SetParent_(spin, toolbar)
Code: Select all
Enumeration
#Window_0
#ToolBarStandard_1
#ToolBarStandard_2
#ToolBarStandard_3
#ToolBarImage_1
#ButtonImage_0
#SpinGadget_0
EndEnumeration
Procedure Open_Window_0()
If OpenWindow(#Window_0, 216, 0, 150, 100, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar , "ToolBar Test")
toolbar = CreateToolBar(0, WindowID(#Window_0))
If toolbar
ToolBarStandardButton(#ToolBarStandard_1, #PB_ToolBarIcon_New)
ToolBarStandardButton(#ToolBarStandard_2, #PB_ToolBarIcon_Open)
ToolBarStandardButton(#ToolBarStandard_3, #PB_ToolBarIcon_Save)
CreateImage(tbImage1,16,16)
LoadImage(tbImage1, "C:\PureBasic\Examples\Sources\Data\Drive.bmp")
ToolBarImageButton(#ToolBarImage_1, UseImage(tbImage1)) ; can i change this image when user clicks?
EndIf
If CreateGadgetList(WindowID())
img = LoadImage(tbImage2, "C:\PureBasic\Examples\Sources\Data\File.bmp")
button = ButtonImageGadget(#ButtonImage_0, 95, 0, 18, 18, img)
SetParent_(button, toolbar)
; --> SpinGadget returns a handle to the "buddy" (Edit control/StringGadget)
spinBuddy = SpinGadget(#SpinGadget_0, 120, 0, 30, 20, 5, 15)
; --> Find the "spinner" (up/down buttons)
spinner = FindWindowEx_(WindowID(), spinBuddy, "msctls_updown32", #Null)
; --> Set parent for "buddy" and "spinner"
SetParent_(spinBuddy, toolbar)
SetParent_(spinner, toolbar)
SetGadgetState (#SpinGadget_0,5) : SetGadgetText(#SpinGadget_0,"5")
EndIf
EndIf
EndProcedure
swap = 1
Open_Window_0()
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadgetID()
Case #ButtonImage_0
If swap
img = LoadImage(tbImage2, "C:\PureBasic\Examples\Sources\Data\Drive.bmp")
SetGadgetState(#ButtonImage_0, img)
swap = 0
Else
img = LoadImage(tbImage2, "C:\PureBasic\Examples\Sources\Data\CDPlayer.ico")
SetGadgetState(#ButtonImage_0, img)
swap = 1
EndIf
Case #SpinGadget_0
SetGadgetText(#SpinGadget_0,Str(GetGadgetState(#SpinGadget_0))) ; doesn't spin
EndSelect
EndSelect
Until event = #PB_EventCloseWindow
End