Link to home
Start Free TrialLog in
Avatar of Moth
Moth

asked on

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,
Avatar of Moth
Moth

ASKER

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 ?
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++))
            ;
}
Avatar of Moth

ASKER

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
Avatar of Moth

ASKER

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
Avatar of Moth

ASKER

I can't reduce the points
ASKER CERTIFIED SOLUTION
Avatar of TimB
TimB

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start 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.

MJ