-
March 16th, 2004, 10:41 PM
#16
I searched these forums for CopyFileEx and I really think there is some help there. Did you look in the CodeGuru articles?
-
March 17th, 2004, 05:05 AM
#17
Originally posted by jkw2068
Not sure what is meant by this. Could you explain please?
Well...what I want to know (and probably see) is where you actually call the function 'CopyFile()'. You have a modal dialog opened with a progress bar...thus, I am assuming that the function will be called somewhere within this modal dialog...and in order to determine exactly why you are having problems with updating your progress bar...
-
March 17th, 2004, 08:06 AM
#18
Originally posted by Andreas Masur
Well...what I want to know (and probably see) is where you actually call the function 'CopyFile()'. You have a modal dialog opened with a progress bar...thus, I am assuming that the function will be called somewhere within this modal dialog...and in order to determine exactly why you are having problems with updating your progress bar...
I believe his problem is that if for example, he has 1mb worth of files to copy and one of the files is 800k he sits for a minute while it copies then gets an 80% jump on his progress bar. He needs to be able to increment the progress bar smoothly, which will require feedback from whatever method he uses to copy the file. CopyFileEx will provide that feedback, or he could write his own copy function pretty easily too. Combine the feedback with a PeekMessage, DispatchMessage call and he'll be there. No need for threads.
-
March 17th, 2004, 08:12 AM
#19
Originally posted by GCDEF
I believe his problem is that if for example, he has 1mb worth of files to copy and one of the files is 800k he sits for a minute while it copies then gets an 80% jump on his progress bar. He needs to be able to increment the progress bar smoothly, which will require feedback from whatever method he uses to copy the file. CopyFileEx will provide that feedback, or he could write his own copy function pretty easily too. Combine the feedback with a PeekMessage, DispatchMessage call and he'll be there. No need for threads.
Yes...that is what I basically assume as well...and that is why I would like to see the actual code and where it is placed at the moment...
-
March 17th, 2004, 04:36 PM
#20
Here ya go.
[CODE]
void CCopyDlg::CopyProgress(void)
{
//
m_progress.SetPos(m_progress.GetPos() + 30);
int copy = CopyFile(m_strFILELOCATION,"A:\\" + m_strFILENAME,FALSE); \\Copying file
if(copy > 0){
m_progress.SetPos(m_progress.GetPos() + 60);
CStdioFile csf;
csf.Open("a:\\autoexec.bat", CFile::modeWrite | CFile::modeCreate | CFile::typeText);
\\Need to handle on error for file creation\write.
m_progress.SetPos(m_progress.GetPos() + 90);
csf.WriteString(m_strFILENAME);
csf.Close();
m_progress.SetPos(m_progress.GetPos() + 100);
MessageBox("Disk is ready for use", "Done", MB_OK | MB_ICONINFORMATION);
OnCancel();
}
else {
m_progress.SetPos(m_progress.GetPos() + 100);
MessageBox("Unable to copy the file " + m_strFILENAME, "ERROR", MB_OK | MB_ICONERROR);
OnCancel();
}
}CODE]
____________
VC++ .NET MFC
-
March 17th, 2004, 04:54 PM
#21
Thank you....okay this is a regular function of your second (modal) dialog. As long as you are within this function the message queue of that dialog will not be processed. In other words, your progress bar will not be updated...
Since you are updating your progress bar based on some other tasks that you are doing and not only on the copying of the file alone, using 'CopyFileEx()' will not help here much. So, I would suggest that you update the progress bar itself after setting the new position...thus
Code:
void CCopyDlg::CopyProgress(void)
{
m_progress.SetPos(m_progress.GetPos() + 30);
m_progress.UpdateWindow();
int copy = CopyFile(m_strFILELOCATION,"A:\\" + m_strFILENAME,FALSE); \\Copying file
if(copy > 0)
{
m_progress.SetPos(m_progress.GetPos() + 60);
m_progress.UpdateWindow();
CStdioFile csf;
csf.Open("a:\\autoexec.bat", CFile::modeWrite | CFile::modeCreate | CFile::typeText);
// Need to handle on error for file creation\write.
m_progress.SetPos(m_progress.GetPos() + 90);
m_progress.UpdateWindow();
csf.WriteString(m_strFILENAME);
csf.Close();
m_progress.SetPos(m_progress.GetPos() + 100);
m_progress.UpdateWindow();
MessageBox("Disk is ready for use", "Done", MB_OK | MB_ICONINFORMATION);
}
else
{
m_progress.SetPos(m_progress.GetPos() + 100);
m_progress.UpdateWindow();
MessageBox("Unable to copy the file " + m_strFILENAME, "ERROR", MB_OK | MB_ICONERROR);
}
}
-
January 27th, 2005, 07:16 PM
#22
Re: Progress bar
Hello guys....I'm a niewbie in coding and i'd like some help....
Is there a demo of copying some files from a location to another displaying also the copying progress in a progress bar?
I m using VC++ Studio 6
Please help me by posting a zip or a link to a FULL tutorial....
Regards
-
January 27th, 2005, 07:31 PM
#23
Re: Progress bar
People that answer questions usually prefer that we look for answers first. Did you look in the articles in the CodeGuru web site and other such web sites? Also, it is usually better to create your own thread rather than adding to someone else's. Using someone else's is often called "hijacking".
-
January 28th, 2005, 04:17 AM
#24
Re: Progress bar
Originally Posted by BorBoMoTSaLo
Hello guys....I'm a niewbie in coding and i'd like some help....
Is there a demo of copying some files from a location to another displaying also the copying progress in a progress bar?
SHFileOperation()
-
January 28th, 2005, 03:51 PM
#25
Yes but....
ok this nethod is called highjacking but i 'd like to learn how can i make my dialog act like this.....
So is there a link for a simple demo project that copies a file (not counting) from a location to another to help me finish my work?
I m not an expert and i m not going to be....I just want to add progress bar in
my personal program.....
Thanks a lot again
Regards
-
January 28th, 2005, 04:04 PM
#26
Re: Yes but....
Originally Posted by BorBoMoTSaLo
ok this nethod is called highjacking but i 'd like to learn how can i make my dialog act like this.....
But if you are inconsiderate to the people you want to help you will get little or no help.
Originally Posted by BorBoMoTSaLo
I m not an expert and i m not going to be....I just want to add progress bar in
my personal program.....
You don't need to be an expert programmer to be considerate.
-
January 28th, 2005, 04:28 PM
#27
inconsiderate?
@Sam Hobbs
Sorry for the annoyance but i trying to find a solution for 2 days.....
At this time i have nowhere to look searh or something.....I'm just asking for a way to create a realtime progress bar....
In the beginning is only copy & paste.....Then knowledge rises and you can share it with people that need it....
I think its very easy for you to create a demo project that does the above work,but for me isn't....
Everybody was a niewbie at the beginning and i think you know how it feels...
I'd be thankfull if you could attach a zip file including the workspase of the above program....
thanks again and i m sorry for the annoyance....
Regards
-
January 28th, 2005, 04:35 PM
#28
Re: Progress bar
You are inconsiderate because you refuse to start a new thread.
You are inconsiderate if you have not looked in the CodeGuru web site and other such sites for relevant articles.
You are inconsiderate if you ignored Andreas's answer.
Even if you did start your own thread, it is unlikely you will get much help if you ask others to do all your work for you. If you don't know how to use SHFileOperation() or anything in an article, then look at it (SHFileOperation or the article) and do the best you can to figure out how to use it. Then ask specific questions. Do that in another thread, not here.
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
|