الاخوة الاكارم : أحب ان اقدم لكم هذا ال class وهو عبارة عن progress قم بنسخ الكود وستتعرف عليه اكثر .
/* Programmed by: Genuis
Date:12/18/2001
Contenents: Progress class and example.
Example: Reading file.
*/
#include
#include
using namespace std;
class Progress
{
private:
double Deficit; // Deficit from last time.
int nPrint; // Number of charecters have drawn.
public:
int Min; // Minimum value.
int Max; // Maximum value.
int Maxdraw; // Max charecters to be drawn.
char style; // Style of charecter to be drawn.
void Resetall(); // Reset all setting to default.
void ResetDeficit(); // Reset Deficit to use progress again.
void Firstdraw(); // Draw the first line number of Maxdraw charecter.
void DrawProgress(int); // Draw the progress by adding values.
};
int main()
{
char *FileName="C:WindowsExplorer.exe"; // File to be read.
ifstream File;
int fLen=0; // Length of File
int nChunck=4096; // Number of data to be read each time.
int Offset=0; // Offset of file.
char *cTemp; // To get data from File.
int fExit=false;
Progress prog;
// Open File
File.open(FileName,File.binary);
if (!File)
{
cout << "File: " << FileName << " Not Founded" << endl;
return 1;
}
// Get the length of the file.
File.seekg(0,File.end);
fLen=File.tellg();
File.seekg(0,File.beg);
//Progress Setting
prog.Resetall();
prog.Min=0;
prog.Max=fLen;
prog.Maxdraw=79;
prog.style='=';
prog.Firstdraw();
// Read File
while (!File.eof() && !fExit)
{
Offset=File.tellg();
if (fLen<= Offset+nChunck)
{
// Read the rest of the data in File.
nChunck=fLen-Offset;
fExit=true;
}
cTemp=new char[nChunck];
File.read(cTemp,nChunck);
// Do whatever with data in nChunck.
delete [] cTemp;
prog.DrawProgress(nChunck);
}
File.close();
cout << endl;
system("PAUSE");
return 0;
}
void Progress::Resetall()
{
Min=0;
Max=100;
Maxdraw=79;
style='=';
Deficit=0;
nPrint=0;
}
void Progress::ResetDeficit()
{
Deficit=0;
nPrint=0;
}
void Progress::Firstdraw()
{
for (int i=1;i<=Maxdraw;i++)
cout << style;
cout << endl;
}
void Progress:: DrawProgress(int Change)
{
float PerWithDef;
float Percent;
if (Max==0) return;
Percent=(float(Change)/ float(Max))*Maxdraw;
PerWithDef=Percent+Deficit;
for (int i=1;i<=PerWithDef;i++)
{
if (nPrint>=Maxdraw) break; // exit when draw over maxdraw
cout << style;
nPrint++;
}
Deficit=PerWithDef-float(--i);
}** لاحظ انني في الاخير عند Progress:: DrawProgress عملت مسافة بين : و D قم بحذفها حتى يعمل البرنامج بشكل سليم "لقد فعلت ذلك لي تظهر صورة مكان الرمزين"