Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. avi file on Status bar

avi file on Status bar

Scheduled Pinned Locked Moved C / C++ / MFC
13 Posts 7 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    ptr_Electron
    wrote on last edited by
    #1

    I am trying to play a AVI file on status bar indicating the progress for the lengthy operation. I am doing this in a button click event. it is working fine if no statements are there below the call and, if there are statements below the avi start.. the avi is not playing on status bar. I tryed with thread, but of no use. void TestPb::OnButton1() { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); pFrame->StartAnimation( IDR_AVITEST ,1); whie(1)//Say length process.... If i comment while(1) .. avi is playing on mainfram status bar {} }

    T R 2 Replies Last reply
    0
    • P ptr_Electron

      I am trying to play a AVI file on status bar indicating the progress for the lengthy operation. I am doing this in a button click event. it is working fine if no statements are there below the call and, if there are statements below the avi start.. the avi is not playing on status bar. I tryed with thread, but of no use. void TestPb::OnButton1() { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); pFrame->StartAnimation( IDR_AVITEST ,1); whie(1)//Say length process.... If i comment while(1) .. avi is playing on mainfram status bar {} }

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      you should move the portion of code playing the AVI in its own thread... and start the thread on the trigger of your choice.

      [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

      P L 2 Replies Last reply
      0
      • P ptr_Electron

        I am trying to play a AVI file on status bar indicating the progress for the lengthy operation. I am doing this in a button click event. it is working fine if no statements are there below the call and, if there are statements below the avi start.. the avi is not playing on status bar. I tryed with thread, but of no use. void TestPb::OnButton1() { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); pFrame->StartAnimation( IDR_AVITEST ,1); whie(1)//Say length process.... If i comment while(1) .. avi is playing on mainfram status bar {} }

        R Offline
        R Offline
        Rajkumar R
        wrote on last edited by
        #3

        while (1); not only stops avi to play, but the complete UI on the GUI thread will stop working.

        P 1 Reply Last reply
        0
        • R Rajkumar R

          while (1); not only stops avi to play, but the complete UI on the GUI thread will stop working.

          P Offline
          P Offline
          ptr_Electron
          wrote on last edited by
          #4

          well, Yes true just i mentioned to as a length process Thanks u I want to paly the avi on the mainfram status bar and start some lenthly process, while still the avi is playing... pls advice

          N 1 Reply Last reply
          0
          • T toxcct

            you should move the portion of code playing the AVI in its own thread... and start the thread on the trigger of your choice.

            [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

            P Offline
            P Offline
            ptr_Electron
            wrote on last edited by
            #5

            I tried placing in threaed but failed

            S 1 Reply Last reply
            0
            • P ptr_Electron

              well, Yes true just i mentioned to as a length process Thanks u I want to paly the avi on the mainfram status bar and start some lenthly process, while still the avi is playing... pls advice

              N Offline
              N Offline
              Nathan Holt at EMOM
              wrote on last edited by
              #6

              ptr_Electron wrote:

              well, Yes true just i mentioned to as a length process Thanks u I want to paly the avi on the mainfram status bar and start some lenthly process, while still the avi is playing... pls advice

              I would run the lengthy operation in a background thread. Nathan

              1 Reply Last reply
              0
              • P ptr_Electron

                I tried placing in threaed but failed

                S Offline
                S Offline
                super_ttd
                wrote on last edited by
                #7

                ptr_Electron wrote:

                I tried placing in threaed but failed

                how did you do that ?


                L 1 Reply Last reply
                0
                • T toxcct

                  you should move the portion of code playing the AVI in its own thread... and start the thread on the trigger of your choice.

                  [VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Hi, Its hard to give you advice without seeing what type of 'processing' you are doing. You should avoid drawing on a window from a separate thread if at all possible. You may be able to simply pump the message que and move the AVI-frame painting into OnPaint. In the while loop you can probably add: while(somecondition) { MSG oMSG; while(::PeekMessage(&oMSG, NULL, 0, 0, PM_NOREMOVE)) { if(::GetMessage(&oMSG, NULL, 0, 0)) { ::TranslateMessage(&oMSG); ::DispatchMessage(&oMSG); } else { break; } } //Your processing code goes here //Hopefully the work is done in chunks and continues to the top of the loop. } pre> This will allow the dialog to process WM_PAINT messages normally.

                  S P 2 Replies Last reply
                  0
                  • L Lost User

                    Hi, Its hard to give you advice without seeing what type of 'processing' you are doing. You should avoid drawing on a window from a separate thread if at all possible. You may be able to simply pump the message que and move the AVI-frame painting into OnPaint. In the while loop you can probably add: while(somecondition) { MSG oMSG; while(::PeekMessage(&oMSG, NULL, 0, 0, PM_NOREMOVE)) { if(::GetMessage(&oMSG, NULL, 0, 0)) { ::TranslateMessage(&oMSG); ::DispatchMessage(&oMSG); } else { break; } } //Your processing code goes here //Hopefully the work is done in chunks and continues to the top of the loop. } pre> This will allow the dialog to process WM_PAINT messages normally.

                    S Offline
                    S Offline
                    super_ttd
                    wrote on last edited by
                    #9

                    you certainly didn't want to say that to our great toxcct, did you ? ;)


                    L 1 Reply Last reply
                    0
                    • S super_ttd

                      ptr_Electron wrote:

                      I tried placing in threaed but failed

                      how did you do that ?


                      L Offline
                      L Offline
                      led mike
                      wrote on last edited by
                      #10

                      super_ttd wrote:

                      how did you do that ?

                      Oh it's easy, you just do something or other :laugh:

                      led mike

                      1 Reply Last reply
                      0
                      • S super_ttd

                        you certainly didn't want to say that to our great toxcct, did you ? ;)


                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #11

                        oops! :doh:

                        1 Reply Last reply
                        0
                        • L Lost User

                          Hi, Its hard to give you advice without seeing what type of 'processing' you are doing. You should avoid drawing on a window from a separate thread if at all possible. You may be able to simply pump the message que and move the AVI-frame painting into OnPaint. In the while loop you can probably add: while(somecondition) { MSG oMSG; while(::PeekMessage(&oMSG, NULL, 0, 0, PM_NOREMOVE)) { if(::GetMessage(&oMSG, NULL, 0, 0)) { ::TranslateMessage(&oMSG); ::DispatchMessage(&oMSG); } else { break; } } //Your processing code goes here //Hopefully the work is done in chunks and continues to the top of the loop. } pre> This will allow the dialog to process WM_PAINT messages normally.

                          P Offline
                          P Offline
                          ptr_Electron
                          wrote on last edited by
                          #12

                          Thanks you very much, for your help, what I am trying to do is extrading 1000's of records from database. since it takes quite some time I want play the avi file on the status bar of main frame, but the call will be made from the dialg. say on button click event we are extracting records form DB and need progress on the status bar, but does not work... void TestPb::OnButton1() { thpbar=AfxBeginThread(thPrgbar,THREAD_PRIORITY_NORMAL,0,0,NULL); //Get 1000's records from DB ..verytime consumming process... } UINT TestPb::thPrgbar( LPVOID pParam ) { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); pFrame->StartAnimation( IDR_AVITEST ,1); return (1); } void CMainFrame::StartAnimation( UINT id, int nPane /*=1*/ ) { StopAnimation(); m_pAnimate = new CStatusbarAnimate; m_pAnimate->Create(id, nPane); } void CMainFrame::StopAnimation() { delete m_pAnimate; m_pAnimate = NULL; } bool CMainFrame::IsAnimationActive() { return (m_pAnimate != NULL); } // needed to ensure original text not visible void CMainFrame::OnUpdateAnimate(CCmdUI* pCmdUI) { pCmdUI->SetText(_T("")); }

                          L 1 Reply Last reply
                          0
                          • P ptr_Electron

                            Thanks you very much, for your help, what I am trying to do is extrading 1000's of records from database. since it takes quite some time I want play the avi file on the status bar of main frame, but the call will be made from the dialg. say on button click event we are extracting records form DB and need progress on the status bar, but does not work... void TestPb::OnButton1() { thpbar=AfxBeginThread(thPrgbar,THREAD_PRIORITY_NORMAL,0,0,NULL); //Get 1000's records from DB ..verytime consumming process... } UINT TestPb::thPrgbar( LPVOID pParam ) { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); pFrame->StartAnimation( IDR_AVITEST ,1); return (1); } void CMainFrame::StartAnimation( UINT id, int nPane /*=1*/ ) { StopAnimation(); m_pAnimate = new CStatusbarAnimate; m_pAnimate->Create(id, nPane); } void CMainFrame::StopAnimation() { delete m_pAnimate; m_pAnimate = NULL; } bool CMainFrame::IsAnimationActive() { return (m_pAnimate != NULL); } // needed to ensure original text not visible void CMainFrame::OnUpdateAnimate(CCmdUI* pCmdUI) { pCmdUI->SetText(_T("")); }

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #13

                            Perhaps you should move to a message based inter-thread communication. You can even pass the percentage of completion. Try something like this: #define WM_START_ANIMATION WM_USER + 0x8 #define WM_INC_PROGRESS WM_USER + 0x10 void TestPb::OnButton1() { thpbar=AfxBeginThread(thPrgbar,THREAD_PRIORITY_NORMAL,0,0,NULL); } UINT TestPb::thPrgbar( LPVOID pParam ) { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); ::PostMessage(pFrame->GetSafeHwnd(),WM_START_ANIMATION,IDR_AVITEST,1); int iCount; int iPosition =0; //Get count(*) from SQL DB and save into iCount; // for each record in DB while(reading DB) { // get 1 record int iPercent = iCount * (iPosition / 100.0); ::PostMessage(pFrame->GetSafeHwnd(),WM_INC_PROGRESS,(WPARAM)iPercent,0); ++iPosition; } //end if return (1); } void CMainFrame::OnStartAnimation( WPARAM id, WPARAM nPane /*=1*/ ) { StopAnimation(); m_pAnimate = new CStatusbarAnimate; m_pAnimate->Create(id, nPane); } void CMainFrame::StopAnimation() { if(IsAnimationActive()) { delete m_pAnimate; m_pAnimate = NULL; } } bool CMainFrame::IsAnimationActive() { return (m_pAnimate != NULL); } // needed to ensure original text not visible void CMainFrame::OnUpdateAnimate(CCmdUI* pCmdUI) { pCmdUI->SetText(_T("")); } Add the following to your CMainFrame /////// // ADD INTO YOUR CMainFrame HEADER FILE: /////// afx_msg LRESULT OnMyProgress(WPARAM wParam, LPARAM lParam); ////////// // ADD INTO YOUR CMainFrame MESSAGE MAP ///////// ON_MESSAGE(WM_INC_PROGRESS,OnMyProgress) ON_MESSAGE(WM_START_ANIMATION,OnStartAnimation) ////////// // ADD INTO YOUR CMainFrame CPP file ///////// LRESULT void CMainFrame::OnMyProgress(WPARAM wParam, LPARAM lParam) { int iPercent = (int)wParam; if(100 == iPercent && IsAnimationActive()) { StopAnimation(); } else { // Update visuals here perhaps to reflect percentage of completion }

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups