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,
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MothAuthor Commented:
Adjusted points to 70
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.
why don't you use the progress bar provided by devstudio ?
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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())

                  //!TH maybe throw exception
                  return FALSE;

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


m_close_button.EnableWindow( FALSE );

Thanks for the comments though,

MothAuthor Commented:
I've worked out an answer for myself, how can I delete this question?
Accept this answer and change the points to 1 -- that way you will only lose a point
MothAuthor Commented:
I can't reduce the points
can I just have you points then.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
That a boy tim -- try and rip the poor guy off.  What a pal
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.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.