Here's a new ButtonEx example demonstrating basic skin modification and the fancy effects you can achieve by dropping them into a PanelEx page
Code: Select all
; Remember to enable XP Skin Support!
; Demonstrates how to use the ButtonEx controls
CompilerIf Defined(StartProGUI, #PB_Function) = #False
IncludeFile "ProGUI_PB.pb"
CompilerEndIf
StartProGUI("", 0, 0, 0, 0, 0, 0, 0)
;- Window Constants
Enumeration
#Window_0
EndEnumeration
;- Menu/Button Command Constants
Enumeration
#Command_Button1
#Command_Button2
#Command_Button3
EndEnumeration
; set up structure for easy access to icon images
Structure images
normal.i
hot.i
pressed.i
disabled.i
EndStructure
Global Dim image.images(3)
; load in some example icons
image(0)\normal = LoadImg("icons\shell32_235.ico", 16, 16, 0)
image(0)\hot = ImgBlend(image(0)\normal, 255, 30, 0, 0, 0, 0)
image(0)\pressed = ImgBlend(image(0)\normal, 255, 0, -30, 0, 0, 0)
image(1)\normal = ImgBlend(LoadImg("icons\shell32_4.ico", 96, 96, 0), 100, 0, 0, 0, 0, #ImgBlend_DestroyOriginal)
image(2)\normal = LoadImg("icons\dccmanager\downloadpanel_border.png", 0, 0, 0)
;- process ProGUI Windows event messages here
; events can also be simply captured using WaitWindowEvent() too in the main event loop, but for ease of porting the examples to other languages the callback method is used.
; #PB_Event_Menu and EventMenu() can be used to get the selected menu item when using the WaitWindowEvent() method.
Procedure ProGUI_EventCallback(hwnd, message, wParam, lParam)
Select message
; handle selection of menu items and buttons
Case #WM_COMMAND
If HWord(wParam) = 0 ; is an ID
MenuID = LWord(wParam)
Debug MenuID
EndIf
; resize panelex and textcontrolex when main window resized
Case #WM_SIZE
MoveWindow_(PanelExID(0, -1), 5, 5, WindowWidth(#Window_0)-10, WindowHeight(#Window_0)-10, #True)
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
; creates a window
Procedure Open_Window_0()
OpenWindow(#Window_0, 50, 50, 700, 500, "Button Example: Resize the main window!", #PB_Window_ScreenCentered | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_Invisible)
; create PanelEx as main window content
CreatePanelEx(0, WindowID(#Window_0), 215, 5, 480, 490, 0)
page = AddPanelExImagePage(2, image(1)\normal, 0, 0, 0, 0, #PNLX_CENTRE|#PNLX_VCENTRE)
SetPanelExPageBorder(0, 0, image(2)\normal, -1, 0, 0)
SetPanelExPageScrolling(0, 0, #PNLX_AUTOSCROLL, #True)
ButtonEx(page, #Command_Button1, 100, 100, 200, 100, "A Great Big Button!", 0, 0, 0, 0, 0)
ButtonEx(page, #Command_Button2, 100, 200, 160, 32, "Button and Icon", image(0)\normal, image(0)\hot, image(0)\pressed, 0, 0)
; copy system default skin of ButtonEx
skin = GetButtonExSkin(#Command_Button1)
newSkin = CopySkin(skin)
; make position of icon for normal state left aligned
SetSkinProperty(newSkin, "buttonex", "normal", "image position", "x: 0; y: centre")
; add a background image for hot state
SetSkinProperty(newSkin, "buttonex", "hot", "background image", "icons\newlogo2_256x256.png")
; make text red for hot state
SetSkinProperty(newSkin, "buttonex", "hot", "text", "colour: red")
ButtonEx(page, #Command_Button3, 400, 200, 200, 64, "Button and Modified Skin", image(0)\normal, image(0)\hot, image(0)\pressed, 0, newSkin)
; attach our events callback for processing Windows ProGUI messages
SetWindowCallback(@ProGUI_EventCallback())
EndProcedure
Open_Window_0() ; create window
HideWindow(0, 0) ; show our newly created window
; enter main event loop
Repeat
Event = WaitWindowEvent()
Until Event = #WM_CLOSE
End
Chris.