Announcement

Collapse
No announcement yet.

Progress bar ques

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

  • Scott Turchin
    replied
    OK You guys win, THis is phenomenal, I thought the graphics package was a 3rd party etc etc...

    Make a g_Finished global variable and set it TRUE when the program exits, drop this thread in and check it out.....


    It is EXACTLY like my Dos based cylon eye was!!!

    Code:
    Global g_Finished As Long
    
    'In WInmain
    Control Add Graphic, g_hDlg, %IDC_GC1, "", 5,120,245,10, %WS_CHILD Or %WS_VISIBLE Or %SS_OWNERDRAW Or %SS_SUNKEN
    
    'In DialogProc
            Case %IDM_EXIT
                g_Finished = %TRUE 'End Cylon eye AND tcp thread
                Dialog End CbHndl,%TRUE      
    
    
        Case %WM_INITDIALOG
             ' Initialization handler
             Graphic Attach CbHndl,%IDC_GC1,ReDraw
             Graphic Color %Red,%Yellow
             Graphic Clear
             Graphic ReDraw
             Call CylonEyeThread()  
    
    
    
    
    'And the thread itself, tends not to pause when someone connects to the server, although my DOS based cylon eye would stop...
    '==========================================================================================
    'THREAD FOR CYLON EYE
    Function CylonEyeThread() As Long
    Local hThread   As Long
    Local lResult As Long
    Local MyThread  As Long
    MyThread = 1
    Thread Create CylonEyeThreadProc(ByVal MyThread) To hThread
    Thread Close hThread To lResult
    'WaitForSingleObject hThread,%INFINITE
    Function = hThread 'grab thread handle to close prematurely and properly if need be.
    End Function
    '------------------------------------------------------------------
    Function CylonEyeThreadProc(ByVal hDrive As Long) As Long
    Local lLoop As Long
    Local lCount As Long
    'Cylon eye
    
    lCount = 1
    Do
    For lLoop = 235 To 1 Step - 1
        Dialog DoEvents                   'allow early breakout
        If IsTrue g_Finished Then Exit For      'Thread is ending, get out of For/Next
        Graphic Attach g_hDlg,%IDC_GC1,ReDraw
        Graphic Clear
        Graphic Box (lCount,1)-(lCount+10,29),0,%Blue,%Blue,0
        lCount = lCount + 1
        Graphic ReDraw
        Sleep 5
    Next lLoop
    For lLoop = 1 To 235
        Dialog DoEvents                   'allow early breakout
        If IsTrue g_Finished Then Exit For      'Thread is ending, get out of For/Next
        Graphic Attach g_hDlg,%IDC_GC1,ReDraw
        Graphic Clear
        Graphic Box (lCount,1)-(lCount+10,29),0,%Blue,%Blue,0
        lCount = lCount - 1
        Graphic ReDraw
        Sleep 5
    Next lLoop
    Loop While IsFalse g_Finished
    
    End Function

    Leave a comment:


  • Scott Turchin
    replied
    WHOA!!!!!!!!!!!!

    HOLD THE FORT!!!

    That is HOT HOT HOT!!!

    Now I understand what it's doing - that is HOT HOT HOT...

    I have it sorta running, at least one direction, reversed it and am syncing it with a timer to run every 5 seconds or so....

    THis has IMMENSE potential!!!!!!!!!


    Very cool!!!!!!!!!!

    Leave a comment:


  • Scott Turchin
    replied
    Originally posted by Cliff Nichols View Post
    I can see where this is going (especially after my 80's flashback in NH on vacay)

    Could be a Cylon, or even KITT, (I even saw someone that not only had a replica of the A-Team van (too bad the driver had the doors locked or I wouldve gotten out), and after the girl I saw this weekend....hmmmm I may not come back to the new era for a while, I am having tooooo much fun *LOL*)

    On the serious side though, I do not see why a progressbar can not be used....its the same general concept, and you can increase/decrease speed of the increment/decremets


    Yup - that's exactly what it is, it was a part of my BBSDown! and InterSceptre programs from the Dos days...
    Last edited by Scott Turchin; 30 Sep 2008, 10:22 AM.

    Leave a comment:


  • Dave Biggs
    replied
    A progress bar could be used..

    PBS_MARQUEE Version 6.0 or later. The progress indicator does not grow in size but instead moves repeatedly along the length of the bar, indicating activity without specifying what proportion of the progress is complete. Note Comctl32.dll version 6 is not redistributable but it is included in Microsoft Windows XP or later. To use Comctl32.dll version 6, specify it in a manifest.

    (You'd also need %PBS_MARQUEE = &H08 as it is missing from CommCtrl.inc)

    But PB's Graphic commands have to be the way to go..

    Leave a comment:


  • Cliff Nichols
    replied
    I can see where this is going (especially after my 80's flashback in NH on vacay)

    Could be a Cylon, or even KITT, (I even saw someone that not only had a replica of the A-Team van (too bad the driver had the doors locked or I wouldve gotten out), and after the girl I saw this weekend....hmmmm I may not come back to the new era for a while, I am having tooooo much fun *LOL*)

    On the serious side though, I do not see why a progressbar can not be used....its the same general concept, and you can increase/decrease speed of the increment/decremets

    Leave a comment:


  • Richard Angell
    replied
    Scott,

    Simply remove the period. It's a PBWin 9 introduction. However there is still the font issue to use the older commands, so hre's a compatible PBWin 8 version:

    Code:
    #COMPILER PBWIN 8
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "Win32API.inc"
    
    %IDD_DIALOG1  =  101
    %IDC_BTN_TEST = 1001
    %IDC_BTN_QUIT = 1002
    %IDC_GC1      = 1003
    %IDC_GC2      = 1004
    
    CALLBACK FUNCTION MainDlgProc()
    '    add any local or static variables here
        LOCAL i&,j&,txt$,qstat&
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
                GRAPHIC ATTACH CBHNDL,%IDC_GC1,REDRAW
                GRAPHIC COLOR %RED,%YELLOW
                GRAPHIC CLEAR
                GRAPHIC REDRAW
                GRAPHIC ATTACH CBHNDL,%IDC_GC2,REDRAW
                GRAPHIC COLOR %GREEN,%BLACK
                GRAPHIC CLEAR
                GRAPHIC FONT "Arial",20, 1
                GRAPHIC REDRAW
    
            CASE %WM_COMMAND
              SELECT CASE AS LONG CBCTL
                  CASE %IDC_BTN_TEST
                      IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                          j& = 1
                          FOR i& = 380 TO 1 STEP - 1
                              DIALOG DOEVENTS                   'allow early breakout
                              IF qstat& <> 0 THEN EXIT FOR      'user pressed Quit!
                              GRAPHIC ATTACH CBHNDL,%IDC_GC1,REDRAW
                              GRAPHIC CLEAR
                              GRAPHIC BOX (j&,1)-(j&+20,29),0,%RED,%RED,0
                              j& = j& + 1
                              GRAPHIC REDRAW
                              GRAPHIC ATTACH CBHNDL,%IDC_GC2,REDRAW
                              GRAPHIC CLEAR
                              txt$ = FORMAT$((((i&/380)*100)\10)+1)
                              GRAPHIC SET POS (i&,1)
                              GRAPHIC PRINT txt$
                              GRAPHIC REDRAW
                              SLEEP 50
                          NEXT i&
                      END IF
    
                  CASE %IDC_BTN_QUIT
                      IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                          qstat& = 1
                          DIALOG END CBHNDL
                      END IF
    
              END SELECT
        END SELECT
    END FUNCTION
    
    FUNCTION PBMAIN () AS LONG
        LOCAL hDLG AS DWORD
        LOCAL lRslt  AS LONG
        DIALOG NEW PIXELS, 0, "Graphic Control Progress Bars",,, 640, 480, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDC_BTN_TEST, "Demo!", 500, 10, 100, 100
        CONTROL ADD BUTTON, hDlg, %IDC_BTN_QUIT, "Quit", 500, 300, 100, 100
        CONTROL ADD GRAPHIC, hDlg, %IDC_GC1, "", 50, 350, 400, 30, _
                %WS_CHILD OR %WS_VISIBLE OR %SS_OWNERDRAW OR %SS_SUNKEN
       CONTROL ADD GRAPHIC, hDlg, %IDC_GC2, "",  50, 400, 400, 30, _
                %WS_CHILD OR %WS_VISIBLE OR %SS_OWNERDRAW OR %SS_SUNKEN
    
        DIALOG SHOW MODAL hDlg, CALL MainDlgProc TO lRslt
    
    END FUNCTION
    '
    '----------------------------------------------------------------------------------------------------------------------------------------------------
    'add your own FUNCTIONS and SUBS starting here
    '----------------------------------------------------------------------------------------------------------------------------------------------------

    Leave a comment:


  • Scott Turchin
    replied
    Why can't I just use the progress bar instead?

    If this is free, requires no additional DLL's, nothing else - (This is a single EXE app that can be run from a CD/floppy/usb) then I can try it.

    BUt, got a compile error right off thebat - period not allowed - CB.HNDL
    Last edited by Scott Turchin; 29 Sep 2008, 04:48 PM.

    Leave a comment:


  • Richard Angell
    replied
    Nice, Paul.

    Code should transfer easily to PBWin as well.

    Leave a comment:


  • Paul Dixon
    replied
    Similar to a progress indicator but faster so it's more useful as an indicator that your code is busy. It's also more like a Cylon!
    Code:
    'Busy Indicator
    $INCLUDE "WIN32API.INC"
    
    %stop=0
    %draw=1
    FUNCTION DrawBusyIndicator ( BYVAL xPos AS LONG, BYVAL yPos AS LONG, _
                            BYVAL DoWhat AS LONG, BYVAL wide AS LONG, BYVAL dw2 AS LONG) AS LONG
    STATIC cnt&,col&() ,hWin???,TimerHandle&,wscale!,high&
    
    SELECT CASE DoWhat
        CASE %stop
            timeKillEvent TimerHandle&
            GRAPHIC WINDOW END
    
        CASE %draw
            IF cnt&=0 THEN
                GRAPHIC ATTACH hWin???, 0  ,REDRAW
                GRAPHIC CLEAR col&(0)
            ELSE
                FOR bar&=0 TO 15
                    position&=(cnt&+bar&) AND &h7f
                    IF (position& AND &h40) THEN position&=(position& XOR &h3f) AND &h3f
                    GRAPHIC BOX ((position&*4)*wscale!,0)-(((position&+1)*4)*wscale!,high&),0,col&(bar&),-1
                NEXT
            GRAPHIC REDRAW
            END IF
    
            INCR cnt&
    
        CASE ELSE
            'it's not stop or draw so it must be start. doWhat is now the colour to use
            'colour should be saturated so R,G and B are either 00 or FF (e.g.&hFFFFFF or &hFF00FF..)
            'create a window to draw the busy indicator in
            GRAPHIC WINDOW "", xPos, yPos, wide&, dw2  TO hWin???
            wscale!=wide/256
            high&=dw2
            'set the colours
            BaseColour&=doWhat
            DIM col&(15)
            temp&=BaseColour&
    
            FOR r&=15 TO 0 STEP -1
                temp&=r&*8+127      'to make more Cylon like change to temp&=r&*16
                col&(r&)=(temp&*65536 +temp&*256+temp&) AND BaseColour&
            NEXT
            'start the timer
            '10=milliseconds between triggers, 0=maximum timer resolution
            TimerHandle& = timeSetEvent ( BYVAL 10, BYVAL 0, CODEPTR(DrawBusyIndicator), BYVAL %draw, BYVAL %TIME_PERIODIC)
    
        END SELECT
    
    END FUNCTION
    
    
    FUNCTION PBMAIN () AS LONG
    
    PRINT "Press a key to exit"
    'start the busy indicator
    DrawBusyIndicator(200,400,%RED,100,10) 'at position 200,400 and 100 wide x 10 high
    
    DO
        SLEEP 10 'this is where you do the main job while the Busy Indicator is displayed
    LOOP UNTIL INSTAT
    
    'end the busy indicator
    DrawBusyIndicator (0,0,%stop,0,0)
    
    END FUNCTION
    Last edited by Paul Dixon; 29 Sep 2008, 04:44 PM. Reason: Added suggestion to make it more Cylon like.

    Leave a comment:


  • Richard Angell
    replied
    Included ... the Power BASIC Graphics Toolset was launched with versions PBCC 4/ PBWin 8. In the help file Programming Reference\Dynamic Dialog Tools section is a secion on Graphics. In the samples for DDT you will also find several examples in its Graphics subdirectory branch. Most of the graphics statements and functions beginning with the keyword GRAPHIC.

    Also in those version the XPRINT command set waas introduced.

    Both of these tool groups were improved and expanded in 5.0/9.0.

    Since you have 8.04, you will need to eliminate the FONT NEW and FONT END statements and change the GRAPHIC SET FONT to the older GRAPHIC FONT statement (see the help file).

    Note that the example shown only is for PBWin, since it uses graphic controls. However, the basic idea of aa progress bar can also be effected in a GRAPHIC WINDOW where one simply replaces an area of the persistent bitmap with (1) a blank progress bar control bitmap; and then (2) a specific bitmap of the current bar, digit or blip at the position or size desired. GRAPHIC COPY would be used for 1, where other graphic commands would be used as in the example code I posted to draw or write the desired image or text or even both.

    IN PBWin 9, ProgressBar control statement and functions have been added to Power BASIC. However for uses beyond the nore, the Graphic Toolset can get the job done. too.

    Leave a comment:


  • Scott Turchin
    replied
    I have PBWIn 8.04, is that included or a 3rd party add-on?

    Leave a comment:


  • Walt Thompson
    replied
    Nice Work!

    Hi Richard;

    Thanks for the Graphic Progress Bars Sample. I can see a number of uses for it.

    Leave a comment:


  • Richard Angell
    replied
    PB GRAPHIC toolset ... piece of cake ... IF the area where you have this "progress bar" is not being overlaid by anything else. Modify for your Cylon friends.

    Code:
    #COMPILER PBWIN
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "Win32API.inc"
    
    %IDD_DIALOG1  =  101
    %IDC_BTN_TEST = 1001
    %IDC_BTN_QUIT = 1002
    %IDC_GC1      = 1003
    %IDC_GC2      = 1004
    
    CALLBACK FUNCTION MainDlgProc()
    '    add any local or static variables here
        LOCAL i&,j&,hFont&,txt$,qstat&
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
                GRAPHIC ATTACH CB.HNDL,%IDC_GC1,REDRAW
                GRAPHIC COLOR %RED,%YELLOW
                GRAPHIC CLEAR
                GRAPHIC REDRAW
                GRAPHIC ATTACH CB.HNDL,%IDC_GC2,REDRAW
                GRAPHIC COLOR %GREEN,%BLACK
                GRAPHIC CLEAR
                FONT NEW "Arial",20, 1 TO hFont&
                GRAPHIC SET FONT hFont&
                GRAPHIC REDRAW
                        
            CASE %WM_DESTROY
                FONT END hFont&
    '
            CASE %WM_COMMAND
              SELECT CASE AS LONG CBCTL
                  CASE %IDC_BTN_TEST
                      IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                          j& = 1
                          FOR i& = 380 TO 1 STEP - 1
                              DIALOG DOEVENTS                   'allow early breakout
                              IF qstat& <> 0 THEN EXIT FOR      'user pressed Quit!
                              GRAPHIC ATTACH CB.HNDL,%IDC_GC1,REDRAW
                              GRAPHIC CLEAR
                              GRAPHIC BOX (j&,1)-(j&+20,29),0,%RED,%RED,0
                              j& += 1
                              GRAPHIC REDRAW
                              GRAPHIC ATTACH CB.HNDL,%IDC_GC2,REDRAW
                              GRAPHIC CLEAR
                              txt$ = FORMAT$((((i&/380)*100)\10)+1)
                              GRAPHIC SET POS (i&,1)
                              GRAPHIC PRINT txt$
                              GRAPHIC REDRAW
                              SLEEP 50
                          NEXT i&
                      END IF
    
                  CASE %IDC_BTN_QUIT
                      IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                          qstat& = 1
                          DIALOG END CBHNDL
                      END IF
    
              END SELECT
        END SELECT
    END FUNCTION
    
    FUNCTION PBMAIN () AS LONG
        LOCAL hDLG AS DWORD
        LOCAL lRslt  AS LONG
        DIALOG NEW PIXELS, 0, "Graphic Control Progress Bars",,, 640, 480, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
        CONTROL ADD BUTTON, hDlg, %IDC_BTN_TEST, "Demo!", 500, 10, 100, 100
        CONTROL ADD BUTTON, hDlg, %IDC_BTN_QUIT, "Quit", 500, 300, 100, 100
        CONTROL ADD GRAPHIC, hDlg, %IDC_GC1, "", 50, 350, 400, 30, _
                %WS_CHILD OR %WS_VISIBLE OR %SS_OWNERDRAW OR %SS_SUNKEN
       CONTROL ADD GRAPHIC, hDlg, %IDC_GC2, "",  50, 400, 400, 30, _
                %WS_CHILD OR %WS_VISIBLE OR %SS_OWNERDRAW OR %SS_SUNKEN
    
        DIALOG SHOW MODAL hDlg, CALL MainDlgProc TO lRslt
    
    END FUNCTION
    '
    '----------------------------------------------------------------------------------------------------------------------------------------------------
    'add your own FUNCTIONS and SUBS starting here
    '----------------------------------------------------------------------------------------------------------------------------------------------------

    Leave a comment:


  • Scott Turchin
    started a topic Progress bar ques

    Progress bar ques

    Anyone know how to make a single "Digit", or sector move across the screen?

    I'm not sure how ot go about this, I guess you could say similiar to a cylon's red eye moving?

    My first app had that, be nice to carry it over

    Thanks,
Working...
X