'________________________________________________________________________________________'
' HoverButton test program
' ========================
'
' Simple program testing the HoverButton's module capabilities
' Uses standard button messages/notifications for compatibility.
'________________________________________________________________________________________
Uses "UI"
Uses "UIHoverButton"
Begin ControlID
%IDC_BUTTON1
%IDC_BUTTON2
%IDC_BUTTON3
%IDC_BUTTON4
%IDC_BUTTON5
%IDC_BUTTON6
End ControlID
'------------------------------------------------------------------------------
' Callback function for main dialog
'------------------------------------------------------------------------------
CallBack Function dlgMain() As Long
Select Case CBMSG
Case %WM_COMMAND
If (CBCTLMSG <> %BN_CLICKED) Then Exit Function
Select Case CBCTL
Case %IDC_BUTTON1
MsgBox CBHNDL, "You clicked the first button, this button is marked as default.", "HoverButton", %MB_ICONINFORMATION
Case %IDC_BUTTON2
'---This button is a "spin" button with multiple messages on mousedown...
Static siAmount As Long
Incr siAmount
Control Set Text CBHNDL, %IDC_BUTTON2, "Spin #" + Format$(siAmount)
Control Redraw CBHNDL, %IDC_BUTTON2
Case %IDC_BUTTON3
MsgBox CBHNDL, "You checked the third button", "HoverButton", %MB_ICONINFORMATION
Case %IDC_BUTTON4
'---Set some random colors for the button...
Local ct As DWord, cb As DWord, cf As DWord
Randomize Timer
ct = Rnd(0, %WHITE)
cb = Rnd(0, %WHITE)
cf = Rnd(0, %WHITE)
Control Send CBHNDL, %IDC_BUTTON4, %HBM_SETCOLORS, ct, cb
Control Send CBHNDL, %IDC_BUTTON4, %HBM_SETHOVERCOLORS, -1, cb
Control Send CBHNDL, %IDC_BUTTON4, %HBM_SETFOCUSCOLOR, cf, 0
Control Redraw CBHNDL, %IDC_BUTTON4
Case %IDC_BUTTON5
MsgBox CBHNDL, "You clicked the old style (HBS_ORIGINAL) button", "HoverButton", %MB_ICONINFORMATION
Case %IDC_BUTTON6
MsgBox CBHNDL, "This button is disabled so this message should not be 'fired'", "HoverButton", %MB_ICONINFORMATION
End Select
End Select
End Function
'------------------------------------------------------------------------------
' Program Start Point
'------------------------------------------------------------------------------
Function TBMain() As Long
Local hDlg As DWord
Dialog New 0, "HoverButton Test", -1, -1, 210, 100, %DS_MODALFRAME Or %WS_CAPTION Or %WS_POPUP Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
Dialog Set Color hDlg, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON1, "Click Me!", 10, 10, 80, 20, %HBS_NORMAL Or %HBS_DEFAULT
Control Send hDlg, %IDC_BUTTON1, %HBM_SETCOLORS, %GREEN, %BLACK
Control Send hDlg, %IDC_BUTTON1, %HBM_SETHOVERCOLORS, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON2, "Hold Down Mouse", 10, 40, 80, 20, %HBS_NORMAL Or %HBS_SPIN
Control Send hDlg, %IDC_BUTTON2, %HBM_SETCOLORS, %BLUE, %BLACK
Control Send hDlg, %IDC_BUTTON2, %HBM_SETHOVERCOLORS, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON3, "Check Button", 10, 70, 80, 20, %HBS_NORMAL Or %HBS_CHECKBOX
Control Send hDlg, %IDC_BUTTON3, %HBM_SETCOLORS, %RED, %BLACK
Control Send hDlg, %IDC_BUTTON3, %HBM_SETHOVERCOLORS, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON4, "Change Color", 120, 10, 80, 20, %HBS_NORMAL
Control Send hDlg, %IDC_BUTTON4, %HBM_SETCOLORS, %GRAY, %BLACK
Control Send hDlg, %IDC_BUTTON4, %HBM_SETHOVERCOLORS, %WHITE, %BLACK
Control Add HoverButton, hDlg, %IDC_BUTTON5, "Old Style", 120, 40, 80, 20, %HBS_NORMAL Or %HBS_ORIGINAL
Control Add HoverButton, hDlg, %IDC_BUTTON6, "Disabled", 120, 70, 80, 20, %HBS_NORMAL Or %WS_DISABLED
Control Send hDlg, %IDC_BUTTON6, %HBM_SETCOLORS, %GRAY, %BLACK
Dialog Show Modal hDlg Call dlgMain
End Function
Bookmarks