Please enable JavaScript to view this site.

ASQL Reference

Navigation: » No topics above this level «

Auto-Countdown Buttons

Scroll Prev Top Next More

Revised May 2023; added Example

To enable this feature, append "<##>" to the text of a button (ctype MBF_BUTTON), where ## is the desired length of the countdown in seconds. The button display will be updated each second with the remaining length of the countdown until it reaches zero. At that time, the "<##>" suffix will be removed entirely, and one of the following two events will occur:

If the button was initially disabled (MBST_DISABLE), then it will become enabled. This might make sense in a situation where you want to prevent the user from prematurely or accidentally triggering an action with serious consequences.
If the button was initially enabled, then the click event will be triggered.

Example

++include ashinc:ashell.def

++include ashinc:xcall.def    ! (needed if using named parameters)

    ! std text button; auto-clicks itself after 15 seconds

    xcall AUI, AUI_CONTROL, CTLOP_ADD, ctlid="btn1", ctext="&OK <15>", &

        ctype=MBF_BUTTON+MBF_KBD, cmd="VK_xF100", srow=3, scol=5, erow=4, ecol=17

        

    ! button with discrete ico image; enables itself after 3 seconds

    xcall AUI, AUI_CONTROL, CTLOP_ADD, ctlid="btnTV", ctext="   Watch &TV <3>~tv.ico", &

        cstate=MBST_DISABLE, ctype=MBF_BUTTON+MBF_KBD, cmd="VK_xF101", &

        srow=3, scol=20, erow=4, ecol=32

 

    ! button with discrete bmp image; enables itself after 6 seconds

    xcall AUI, AUI_CONTROL, CTLOP_ADD, ctlid="btnCoffee", ctext="Drink &Coffee <6>~coffee.bmp", &

        cstate=MBST_DISABLE, ctype=MBF_BUTTON+MBF_KBD, cmd="VK_xF102", &

        srow=3, scol=35, erow=4, ecol=47

 

    ! button with icon from ashico1.dll; enables itself after 9 seconds

    xcall AUI, AUI_CONTROL, CTLOP_ADD, ctlid="btnExit", ctext="&Exit <9>~exit::ashico1", &

        cstate=MBST_DISABLE, ctype=MBF_BUTTON+MBF_KBD, cmd="VK_xF103", &

        srow=3, scol=50, erow=4, ecol=62

        

    ! command link button; enables itself after 12 seconds

    xcall AUI, AUI_CONTROL, CTLOP_ADD, "btnPrint", &

        "&Print <12>|Prompt for printer; options for email, PDF~printer3::ashico1", &

        MBST_DISABLE, MBF_BUTTON+MBF_KBD, "VK_xF104", NUL_FUNC$, NUL_CSTATUS, &

        6,5,8,35

 

auto-countdown

 

Notes

The "<##>" which triggers the countdown feature must be at the end of the ctext parameter (for text-only buttons), or immediately prior to "~" separating the text from the image spec (for buttons with both text and an image), or immediately prior to the "|" separating the two text lines (for Command Link buttons)
Do not include the MBF_ICON or MBF_BITMAP flags
The use of named parameters in the first four AUI calls relies on this DEFXCALL definition in xcall.def :

defxcall AUI+AUI_CONTROL, opcode, ctlid {, ctext="", cstate=MBST_ENABLE, ctype, cmd="", func="", cstatus=NUL_CSTATUS, srow, scol, erow, ecol, fgc=NUL_FGC, bgc=NUL_BGC, fontattr=0, fontscale=0, fontface="", tooltip="", parentid=0, winclass="", winstyle=0, winstylex=0, ctype2=0}

History

2017 January, A-Shell 6.3.1542:  added to A-Shell