CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Posts
    140

    How to update progress bar from CopyFileEx function

    Hi,
    i am using CopyFileEx function to copy a large file. I need to display progress bar to give update to the user.

    I have written the following callback function:

    Code:
    DWORD CALLBACK   CopyProgressRoutine(LARGE_INTEGER TotalFileSize,
    								   LARGE_INTEGER TotalBytesTransferred,
    								   LARGE_INTEGER StreamSize,
    								   LARGE_INTEGER StreamBytesTransferred,
    							       DWORD dwStreamNumber,
    								   DWORD dwCallbackReason,
    								   HANDLE hSourceFile,
    								   HANDLE hDestinationFile,
    								   LPVOID lpData)
    
    {
    	long lTotalSize = (TotalBytesTransferred.QuadPart / TotalFileSize.QuadPart * 100);
    
    
    	//m_FileCopyProgress.SetPos(lTotalSize);
    
    	return PROGRESS_CONTINUE;
    
    }

    How can i update the progress bar in a dialog from the above callback function.

    Please advice.

    Thanks in advance,
    John.

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: How to update progress bar from CopyFileEx function

    When you call CopyFileEx from the dialog class, pass dialog handle as lpData parameter. Now CopyProgressRoutine gets this handle through its lpData. Post user-defined message to this handle, with lTotalSize in WPARAM. In the dialog, handle this message and set progressbar value.

  3. #3
    Join Date
    Mar 2005
    Posts
    140

    Re: How to update progress bar from CopyFileEx function

    Perfect.. Thank you. Reps added

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured