Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

Animated Labels

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Animated Labels

    This demo allows a label to act, somewhat, like a button. When you click on it, it depresses like a button. However, it will stay depressed for the duration of the SLEEP command and then return to its normal state.

    If the SLEEP command is replaced with a function or sub call, the label will remain depressed until the function of sub returns. Beyond that, I haven't a clue how this demo might be employed.

    Code:
    #COMPILE EXE
    #DIM ALL
    
    %Test = 1001
    
    '******************************************************************************
    '   ** Functions and Subs **
    '******************************************************************************
    DECLARE CALLBACK FUNCTION ShowDlgProc()
    
    '******************************************************************************
    '   ** Program Entry Point **
    '******************************************************************************
    FUNCTION PBMAIN () AS LONG
        STATIC hParent      AS DWORD
        STATIC hDlg         AS DWORD
        STATIC ClientX      AS DWORD
        STATIC ClientY      AS DWORD
        STATIC DlgSizeX     AS DWORD
        STATIC DlgSizeY     AS DWORD
        STATIC CtrlX        AS DWORD
        STATIC CtrlY        AS DWORD
        
        LOCAL  lRslt        AS DWORD
        
        DESKTOP GET CLIENT TO ClientX, ClientY
        DIALOG NEW PIXELS, hParent, "Animated Label", 0, 0, 800, 500, %WS_SYSMENU, TO hDlg
        DIALOG SET COLOR hDlg, -1,           %CYAN
    
        DIALOG GET SIZE  hDlg TO DlgSizeX, DlgSizeY
        DIALOG SET LOC   hDlg, (ClientX - DlgSizeX) / 2, (ClientY - DlgSizeY) / 2
           
        CONTROL ADD LABEL, hDlg, %Test, "Standby",   340, 200, 128,  128, %SS_CENTER OR %SS_CENTERIMAGE OR %SS_NOTIFY, ,
        CONTROL SET COLOR hDlg, %Test, %BLUE, %YELLOW
        
        CONTROL GET SIZE hDlg, %Test TO CtrlX, CtrlY
        CONTROL SET LOC hdlg, %Test, (DlgSizeX - CtrlX) / 2, (DlgSizeY - CtrlY) / 2
            
        DIALOG SHOW MODAL hDlg, CALL ShowDlgProc TO lRslt
    END FUNCTION
    
    '******************************************************************************
    '   ** CallBacks **
    '******************************************************************************
    CALLBACK FUNCTION ShowDlgProc()
        
        SELECT CASE CB.MSG
            CASE %WM_COMMAND
                ' Process control notifications
                CONTROL SET FOCUS CB.HNDL, CB.CTL
                SELECT CASE AS LONG CB.CTL
                     CASE %Test
                        CONTROL KILL CB.HNDL, %Test
                        CONTROL ADD LABEL, CB.HNDL, %Test, "Working",   340, 200, 128,  128, %SS_CENTER OR %SS_CENTERIMAGE OR %SS_NOTIFY, %WS_EX_CLIENTEDGE,
                        CONTROL SET COLOR CB.HNDL, %Test, %BLUE, %GREEN
                        CONTROL REDRAW CB.HNDL, %Test
                        DIALOG DOEVENTS 1
                        SLEEP 1000
                        CONTROL KILL CB.HNDL, %Test
                        CONTROL ADD LABEL, CB.HNDL, %Test, "Standby",   340, 200, 128,  128, %SS_CENTER OR %SS_CENTERIMAGE OR %SS_NOTIFY, ,
                        CONTROL SET COLOR CB.HNDL, %Test, %BLUE, %YELLOW
                        CONTROL REDRAW CB.HNDL, %Test
                END SELECT
        END SELECT
    
    END FUNCTION

  • #2
    I am wondering why you use a DIALOG DOEVENTS in the callback. I don't see
    a modeless dialog in your code example. I don't believe this statement will
    do much if anything.

    Another way to show a 'pushed button' using a label, it so leave the label
    there (without killing it) and just change it with control add line (reversing the
    white and black borders to simulate pushed/released state).
    Client Writeup for the CPA

    buffs.proboards2.com

    Links Page

    Comment


    • #3
      Hi Fred;

      The DIALOG DOEVENTS is a left over. The code was extracted from a larger application.

      Changing the CONTROL ADD line with out first killing the control, causes the background colors to mix. Instead of yellow for Standby and green for Working you get a mix of green and yellow.

      Comment

      Working...
      X