Google Search

Saturday, January 29, 2011

PROGRESS CONTROL CREATION 600459– Visual Programming Anna University lab manual download fourth semester

PROGRESS CONTROL CREATION 600459– Visual Programming Anna University lab manual download fourth semester


Aim:
            To write a Visual C++ program for creating a Progress Control Creation using win32 application.

Logical Description:

            The program starts with object creation. After initializing the instance, the user created window is assigned as main window. Using Show window option project user created window. 

Algorithm:

1.Start the Process
2.Create an object for an class which inherits CWinApp
3.The object access InitInstance() function
4.Create a pointer object for the class which inherits CFrameWindow by allocating the memory to the object
5.Show the created window using SW_SHOWNORMAL
6.Stop the process

Source Code:

#include<afxwin.h>
#include<afxcmn.h>
#include "resource.h"
class sortdialog:public CDialog
{
private:
CString fname;
Public:                                                                                                  
sortdialog(int n):CDialog(n)
{
fname="Enter file to be sorted";
}                                                                                                           
void DoDtaExchange(CDataExchange *p)                                         
{                                                                                                                     
DDX_Text(p,IDC_EDIT1,fname);                                                     
}
                                                                                                             
void OnOk()                                                                                         
{                                                                                                                     
CString str[100],temp;                                                                                   
CStdioFile fp;                                                                                                
CProgressCtrl *c;                                                                                           
UpdateData(TRUE);                                                                                     
c=(CProgressCtrl*)GetDlgItem(IDC_PROGRESS1);                                 
c->SetStep(5);                                                                                      
if(fp.Open(fname,CFile::modeReadWrite))                                                  
{                                                                                                                                 
int count=0;                                                                                                                
fp.SeekToBegin();                                                                                                      
while(fp.ReadString (str[count])!=NULL)                                                                
count++;                                                                                                         
for(int j=0;j<count;j++)                                                                                              
{                                                                                                                                 
for(int k=j+1;k<count;k++)                                                                                       
{                                                                                                                                 
if(str[j]>str[k])                                                                                                            
{                                                                                                                                 
temp=str[j];                                                                                                                
str[j]=str[k];                                                                                                                
str[k]=temp;                                                                                                               
}                                                                                                                                 
}                                                                                                                                 
c->StepIt();                                                                                                                
Sleep(100);                                                                                                                 
}                                                                                                                                 
fp.SeekToBegin();                                                                                                      
for(int i=0;i<count;i++)                                                                                              
{                                                                                                                                 
fp.WriteString(str[i]);
                                                                                                                                   
}                                                                                                                                 
fp.Close();                                                                                                      
}                                                                                                                     
else                                                                                                                             
MessageBox(fname,"cannot open file");                                                       
EndDialog(IDOK);                                                                              
}
};
class copydialog:public CDialog
{
private:                                                                                                 
CString source,target;
public:                                                                                                   
copydialog(int n):CDialog(n)                                                               
{                                                                                                                     
source="enter source file name";                                                                    
target="enter target file name";                                                            
}                                                                                                           
void DoDataExchange(CDataExchange *p)
                                                                                                             
{                                                                                                                     
DDX_Text(p,IDC_EDIT1,source);                                                               
DDX_Text(p,IDC_EDIT2,target);
}
                                                                                                             
void OnOk()
                                                                                                             
{                                                                                                                     
CAnimateCtrl *c;                                                                                           
CStdioFile fs,ft;                                                                                             
char str[200];                                                                                                  
UpdateData();                                                                                                
c=(CAnimateCtrl*) GetDlgItem(IDC_ANIMATE1);                                  
c->Open("dillo.avi");                                                                                      
c->Play(0,-1,-1);                                                                                             
if(fs.Open(source,CFile::modeRead)==0)                                                     
{                                                                                                                     
MessageBox("cannot open source file","file error");                                                 
return;                                                                                                   
}
                                                                                                                       
if(fs.Open(target,CFile::modeCreate|CFile::modeWrite)==0)
                                                                                                                       
{                                                                                                                                 
MessageBox("cannot open source file","file error");                                                 
return;                                                                                                   
}
while(fs.ReadString(str,199)!=NULL)
{                                                                                                           
ft.WriteString(str);                                                                               
Sleep(100);
}
fs.Close();
ft.Close();

c->Stop();
c->Close();

EndDialog(1);                                                                                      
}                                                                                                           
};
                                                                                                             
class myframe:public CFrameWnd                                                      
{
public:                                                                                                            
myframe()                                                                                                      
{                                                                                                                                 
Create(0,"progress bar and animation
control",WS_OVERLAPPEDWINDOW,rectDefault,0);                            
}
                                                                                                                       
                                                                                                                       
void sort()                                                                                                      
{                                                                                                                                 
sortdialog *d;                                                                                                             
d= new sortdialog(IDD_DIALOG1);                                                                       
d->DoModal();                                                                                              
}                                                                                                           
void copy()                                                                                                     
{                                                                                                                                 
copydialog *d;                                                                                                           
d=new copydialog(IDD_DIALOG2);                                                                      
d->DoModal();                                                                                              
}
                                                                                                                       
DECLARE_MESSAGE_MAP()                                                        
};
                                                                                                             
BEGIN_MESSAGE_MAP(myframe,CFrameWnd)                                    
ON_COMMAND(101,sort)                                                                
ON_COMMAND(102,copy)                                                                        
END_MESSAGE_MAP()
                                                                                                             
class myapp:public CWinApp
{
public:                                                                                                            
int InitInstance()                                                                                            
{                                                                                                                                 
myframe *p;                                                                                                               
p=new myframe;                                                                                                        
p->ShowWindow(3);                                                                                                 
m_pMainWnd=p;                                                                                                       
return 1;                                                                                                          
}                                                                                                           
};
myapp a;

0 comments:

Post a Comment