-
July 1st, 2013, 08:26 PM
#1
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
-
July 2nd, 2013, 01:32 AM
#2
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.
-
July 2nd, 2013, 01:42 AM
#3
Re: WinInet progress bar
Originally Posted by vaas
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|