automatically start function after dialig is displayed

I'm writing a proram to automatically copy a bunch of diectories.  Whan a 'copy' button is pressed a new dialog should appear with a prograss bar on it.

The diectories Io want to copy should automatically stat to be copied, and the progress control filled accordingly.

If I put all my copy code on oninitdialig, the program copies the directories, and then (after copying all the directories) displays a full progress control.

How can I get the progress control to fill while I'm copying?

Thanks for any comments,
LVL 1
MothAsked:
Who is Participating?
 
TimBConnect With a Mentor Commented:
can I just have you points then.
0
 
MothAuthor Commented:
Adjusted points to 70
0
 
naveenkohliCommented:
Make use of SHFileOperation API call. Look into the documentation for setting the different parameters in SHFILEOPSTRUCT structure to copy files and indicating the progress bar.
0
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

 
Shay050799Commented:
why don't you use the progress bar provided by devstudio ?
0
 
Tommy HuiEngineerCommented:
The problem is that the progress control relies on messages to update. Since you're taking all the CPU time by using a loop, you will need to pump the messages.

Add this code to your loop:

while (copying)
{
      // Copy stuff here

      // This is the message loop
      MSG msg;

      while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
      {
            if (!AfxGetApp()->PumpMessage())
            {
                  ::PostQuitMessage(0);

                  //!TH maybe throw exception
                  //
                  return FALSE;
            }
      }

      LONG idle = 0;
      while (AfxGetApp()->OnIdle(idle++))
            ;
}
0
 
MothAuthor Commented:
I put this on the oninit in the end, and it worked.


ShowWindow(SW_SHOW);
InvalidateRect(NULL);
UpdateWindow();

m_close_button.EnableWindow( FALSE );
do_installation();

Thanks for the comments though,

Moth
0
 
MothAuthor Commented:
I've worked out an answer for myself, how can I delete this question?
0
 
JOE_WIEMANNCommented:
Accept this answer and change the points to 1 -- that way you will only lose a point
0
 
MothAuthor Commented:
I can't reduce the points
0
 
JOE_WIEMANNCommented:
That a boy tim -- try and rip the poor guy off.  What a pal
0
 
mandhjoCommented:
You used to be able to delete a question -- is that no longer an option?  If you delete the question, the points will go back into your account.  That's the way it used to work because I did it on a couple of occasions.

MJ
0
All Courses

From novice to tech pro — start learning today.