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

    WinInet progress bar

    Will anyone help me out with a progress bar for a wininet ftp client?

    here is my code that I have so far but is not working.
    Code:
    int row = m_listcontrol.GetSelectionMark();
    
    CString s2 = m_listcontrol.GetItemText(row, 0); 
    UpdateData(true);
    CString pepsi = m_pep + "\\" + s2;
    UpdateData(false);
    
    HANDLE hFile = CreateFile(pepsi, GENERIC_READ, FILE_SHARE_READ, NULL,
            OPEN_EXISTING, 0, NULL);
    remote = FtpOpenFile(hIConnect,pepsi,GENERIC_WRITE,
     FTP_TRANSFER_TYPE_BINARY,0);
    BOOL bWriteSuccess = TRUE;
      DWORD progress = 0;
      DWORD maximum = GetFileSize(hFile, NULL);
      DWORD read = MAX_PATH;
      DWORD written = 0;
      
    char cSendBuffer[MAX_PATH];
    m_pro.SetRange(0,maximum/100000);
    while(progress < maximum && bWriteSuccess != FALSE)
     {
    
    	 ReadFile(hFile,cSendBuffer,256, &read, NULL);
     bWriteSuccess = InternetWriteFile(remote,cSendBuffer,read,&written);
     progress += written;
     m_pro.SetPos(progress/100000);
    here is a outline of the program....
    1. USER SELECTS FILE FROM LISTCONTROL
    2. PRESSES UPLOAD BUTTON and the progress is suppose to work


    can anyone help..maybe fix the code or give better tips

  2. #2
    Join Date
    Feb 2005
    Location
    Madrid (Spain)
    Posts
    511

    Re: WinInet progress bar

    Hi Vaas.

    Are you using a new thread for reading the file?

    Normaly, a thread is used to read the file and send message to the parent window to update the progress control.

    And, what is happend if file size is less than 100000??

    Best regards.
    Last edited by juanpast; July 2nd, 2013 at 01:36 AM.

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: WinInet progress bar

    Quote Originally Posted by vaas View Post
    here is my code that I have so far but is not working.

    can anyone help..maybe fix the code or give better tips
    To let us help maybe you give us some more details on what "is not working" looks like, in comparison to your expectations from the code execution.
    Best regards,
    Igor

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