Beruflich Dokumente
Kultur Dokumente
S. No.
Particulars
Page
Number
5-6
Beyond Syllabus
8 23
Mission
To develop BRCM College of Engineering & Technology into a Center of Excellence
By :
Providing State of the art Laboratories, Workshops, Research and instructional facilities
Encouraging students to delve into technical pursuits beyond their academic curriculum.
Facilitating Post graduate teaching and research
Creating an environment for complete personality development of students.
Assisting in the best possible placement
Vision
To Nurture and Harness talent for empowerment towards self actualization in all technical
domains both existing for the future
PROGRAM
Study of Visual Basic 6.0 .NET and Visual C++ 6.0 .NET
1
Study Windows APIs. Find out their relationship with MFC classes. Appreciate
how they are helpful in finding complexities of windows programming.
Create an SDI application in VC++ that adds a popup menu to your application
which uses File drop down menu attached with the menu bar as the pop-up menu.
The pop-up menu should be displayed on the right click of the mouse.
Create an SDI application in VC++ using which the user can draw atmost 20
rectangles in the client area. All the rectangles that are drawn should remain visible
on the screen even if the window is refreshed. Rectangle should be drawn on the
second click of the left mouse button out of the two consecutive clicks. If the user
tries to draw more than 20 rectangles, a message should get displayed in the client
area that No more rectangles can be drawn
Create an application in VC++ that shows how menu items can be grayed, disabled
and appended at run time.
Write a program in VC++ to implement serialization of inbuilt and user defined
objects.
6
7
Write a program in VC++ to create archive class object from C File class that reads
and stores a simple structure (record)
Write a program in VC++ to create archive class object from C File class that reads
and stores a simple structure (record).
Write a program in VB to implement a simple calculator
Create a simple database in MS Access Database /Oracle and a simple database
application in VB that shows database connectivity through DAO and ADO
Write a simple program that displays an appropriate message when the illegal
operation is performed using error handling technique in VB.
Write a program in VB to create a notepad.
Create a DLL in VB.
Write a program in VC++ to implement a simple calculator.
Write a program in VC++ to create a static link library and a dynamic link library.
9
10
11
12
13
14
15
16
17
Beyond syllabus
P. No Program
1
}
hwnd=CreateWindow(szAppName,"vasanth",WS_OVERLAPPEDWINDOW,10,
20,500,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,iCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&msg,0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (0);
}
LRESULT CALLBACK WndProc(HWND hwnd,UINT message,WPARAM
wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
switch(message)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
GetClientRect(hwnd,&rect);
DrawText(hdc,TEXT("Hello"),1,&rect,DT_SINGLELINE|DT_CENTER|DT_VCENTER);
EndPaint(hwnd,&ps);
return(0);
case WM_DESTROY:
PostQuitMessage(0);
return(0);
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
Output:
#include<windows h>
LRESULT CALLBACK WndProc (HWND,UINT,WPARAM,LPARAM);
WNDCLASS a;
10
int flag=0;
int WINAPI WinMain(HINSTANCE i,HINSTANCE j,LPSTR k,int l)
{
HWND h;
MSG m;
a.style=CS_HREDRAW|CS_VREDRAW;
a.hInstance=i;
a.cbClsExtra=0;
a.lpfnWndProc=WndProc;
a.lpszMenuName=NULL;
a.cbWndExtra=0;
a.lpszClassName="my";
a.hCursor=LoadCursor(NULL,IDC_ARROW);
a.hIcon=LoadIcon(NULL,IDI_APPLICATION);
a.hbrBackground=(HBRUSH)GetStockObject(RGB(255,0,0));
if(!RegisterClass(&a))
{
MessageBox(h,TEXT("Error"),"my",MB_ICONERROR);
return 0;
}
h=CreateWindow("my",TEXT("TITLE"),WS_OVERLAPPEDWINDOW,100,100,150,100
,
NULL,NULL,NULL,NULL);
ShowWindow(h,l);
while(GetMessage(&m,NULL,0,0))
{
TranslateMessage(&m);
DispatchMessage(&m);
}
return m.wParam;
}
LRESULT CALLBACK WndProc(HWND w,UINT x,WPARAM y,LPARAM z)
{
HDC d;
switch(x)
{
case WM_LBUTTONDOWN:
flag=1;
return 0;
case WM_MOUSEMOVE:
if(flag==1)
11
{
d=GetDC(w);
SetPixel(d,LOWORD(z),HIWORD(z),RGB(255,0,0));
ReleaseDC(w,d);
}
return 0;
case WM_LBUTTONUP:
flag=0;
return 0;
case WM_DESTROY:
PostQuitMessage(10);
return 0;
}
return DefWindowProc(w,x,y,z);
}
OUTPUT:
3. Select FileNewWin32 Application, then give the project name and then choose empty
project button and finally give finish OK.
4. Again go to File New C++ Source File File Name OK.
5. Type the coding.
6. Build and test the application.
Keyboard Events Program
Program:
#include<windows.h>
#include<stdio.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
WNDCLASS a;
char cs[50];
int X=10,Y=10;
int flag=0;
int WINAPI WinMain(HINSTANCE i,HINSTANCE j,LPSTR K,int l)
{
HWND h;
MSG m;
a.style=CS_HREDRAW|CS_VREDRAW;
a.hInstance=i;
a.cbClsExtra=0;
a.lpszMenuName=NULL;
a.cbWndExtra=0;
a.lpszClassName="my";
a.lpfnWndProc=WndProc;
a.hCursor=LoadCursor(NULL,IDC_ARROW);
a.hIcon=LoadIcon(NULL,IDI_APPLICATION);
a.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
if(!RegisterClass(&a))
{
MessageBox(0,TEXT("ERROR"),"my",MB_ICONERROR);
return 0;
}
h=CreateWindow("my",TEXT("TITLE"),WS_OVERLAPPEDWINDOW,CW_USEDEFA
ULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,i,NULL);
ShowWindow(h,l);
UpdateWindow(h);
while(GetMessage(&m,NULL,0,0))
{
TranslateMessage(&m);
13
DispatchMessage(&m);
}
return m.wParam;
}
LRESULT CALLBACK WndProc(HWND h,UINT x,WPARAM y,LPARAM z)
{
HDC d;
switch(x)
{
case WM_CHAR:
sprintf(cs,"%c",LOWORD(y));
d=GetDC(h);
if(X>300)
{
X=10,Y+=20;
}
TextOut(d,X+=8,Y,cs,1);
ReleaseDC(h,d);
break;
case WM_LBUTTONUP:
flag=1;
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(h,x,y,z);
}
14
OUTPUT:
15
16
9.
Give OK
10.Click on the 0 button give the member function name and give 0K.
11.Add the Coding for each buttons like this.
12.In the CalcDlg header file under the construction comment line add the declaration part.
i.e int index,val,data,data1;
double m,a,b;
char temp [10];
13.Build and test the application
PROGRAM:
//eDlg.h header file
int index,val,data,data1;
double m,a,b;
char temp[10];
//eDlg.cpp
void CEDlg::OnOne()
{
UpdateData(true);
if(m_t1=="0"|| m_t1==" ")
m_t1="1";
else
m_t1+="1";
UpdateData(false);
}
17
void CEDlg::OnZero()
{
UpdateData(true);
if(m_t1=="0"|| m_t1==" ")
m_t1="0";
else
m_t1+="0";
UpdateData(false);
}
void CEDlg::Ontwo()
{
UpdateData(true);
if(m_t1=="0"|| m_t1==" ")
m_t1="2";
else
m_t1+="2";
UpdateData(false);// TODO: Add your control notification handler code here
}
void CEDlg::Onthree()
{
UpdateData(true);
if(m_t1=="0"|| m_t1==" ")
m_t1="3";
else
m_t1+="3";
UpdateData(false);// TODO: Add your control notification handler code here
}
void CEDlg::Onfour()
{
UpdateData(true);
if(m_t1=="0"|| m_t1==" ")
m_t1="4";
else
m_t1+="4";
UpdateData(false);// TODO: Add your control notification handler code here
}
void CEDlg::Onfive()
{
18
UpdateData(true);
if(m_t1=="0"|| m_t1==" ")
m_t1="5";
else
m_t1+="5";
UpdateData(false);// TODO: Add your control notification handler code here
}
void CEDlg::Onsix()
{
UpdateData(true);
if(m_t1=="0"|| m_t1==" ")
m_t1="6";
else
m_t1+="6";
UpdateData(false);// TODO: Add your control notification handler code here
}
void CEDlg::Onseven()
{
UpdateData(true);
if(m_t1=="0"|| m_t1==" ")
m_t1="7";
else
m_t1+="7";
UpdateData(false);// TODO: Add your control notification handler code here
}
void CEDlg::Oneight()
{
UpdateData(true);
if(m_t1=="0"|| m_t1==" ")
m_t1="8";
else
m_t1+="8";
UpdateData(false);// TODO: Add your control notification handler code here
}
void CEDlg::Onnine()
{
UpdateData(true);
19
a=atof(m_t1);
b=-a;
sprintf(temp,"%f",b);
m_t1=temp;
UpdateData(false);
break;
}
case 2:
{
UpdateData(true);
a=atof(m_t1);
b=a*m;
sprintf(temp,"%f",b);
m_t1=temp;
UpdateData(false);
break;
}
case 3:
{
UpdateData(true);
a=atof(m_t1);
b=m/a;
sprintf(temp,"%f",b);
m_t1=temp;
UpdateData(false);
break;
}
}
UpdateData(false);
}
void CEDlg::Onclear()
{
UpdateData(true);
m_t1="0";
UpdateData(false); // TODO: Add your control notification handler code here
}
void CEDlg::Onplus()
21
{
UpdateData(true);
m=atof(m_t1);
m_t1=" ";
index=0;
UpdateData(false);
}
OUTPUT:
Steps:
1: Run VC++ AppWizard to create an SDI application and select the document view architecture
and deselect the printing and print preview by accepting all the default settings and click
finish to design the project.
22
Use the following command IDs for your new menu items.
Menu
Caption
Command ID
Diagrams
&Rectangle
ID_DIAGRAMS_RECT
Diagrams
E&llipse
ID_DIAGRAMS_ELLIPSE
23
Message
Member Function
ID_DIAGRAMS_RECT
COMMAND
OnDiagramsRect
ID_DIAGRAMS_RECT
UPDATE_COMMAND_UI
OnUpdateDiagramsRect
ID_DIAGRAMS_ELLIPSE
COMMAND
OnDiagramsEllipse
ID_DIAGRAMS_ELLIPSE
UPDATE_COMMAND_UI
OnUpdateDiagramsEllipse
{
pCmdUI->Enable(TRUE);
}
9: Build and test the Toolbar application.
OUTPUT:
25
4. Go to File View and in the source file double click on dynamic .cpp (where dynamic is the
project name).
5. Add the coding &Build the application .You can see the .lib file &.dll file in your projects
Debug folder.
6. Now close the workspace and choose a new MFC Appwizard (exe) &give the project name
(dynamic1).
7. Choose the dialog based application &paste one command button on the dialog box double
click the button and write the coding.
8. Copy the .lib file and .dll file in the debug folder of the dynamic project and paste in
dynamic1 projects debug folder.
9. Go to the coding window of the dynamic1 project select the Project menu and select add to
project &now you can see the debug folder. Now change the file of type as all files and just
double click it.
10.Build &test the application
PROGRAM
//The below coding should be typed in Win32 Dynamic Link Library in mydl.cpp at the top.
extern "C"__declspec(dllexport)double sum(double,double);
extern "C"__declspec(dllexport)double mul(double,double);
double sum(double a, double b)
{
return(a+b);
}
double mul(double a, double b)
{
return(a*b);
}
The below coding should be typed in MFC Appwizard[exe]
//dynamicdllDlg.cpp
26
void CBhuvanaDlg::OnDisplay()
{
CString x;
x.Format("SUM=%2f\n product=%2f",sum(3,4),mul(5,6));
MessageBox(x);
27
Program 7 :
Steps:1: Run AppWizard to generate the project. Accept all the default settings but two: select
Single Document and deselect Printing and Print Preview and select document view architecture.
Finish the application
Keep the default control ID for the Cancel button, but use IDC_START for the Start button.
For the progress indicator, accept the default ID IDC_PROGRESS1.
3: Use ClassWizard to create the CComputeDlg class.
4: After the class is generated, add a WM_TIMER message handler function. Also add
BN_CLICKED message handlers for IDC_START and IDCANCEL. Accept the default
names OnStart and OnCancel.
5: Add three data members to the CComputeDlg class. Edit the file ComputeDlg.h. Add the
following private data members:
int m_nTimer; int m_nCount; enum { nMaxCount = 10000 };
6: Add initialization code to the CComputeDlg constructor in the ComputeDlg.cpp file.
28
m_nCount = 0;
7: Code the OnStart function in ComputeDlg.cpp.
void CComputeDlg::OnStart()
{
MSG message;
m_nTimer = SetTimer(1, 100, NULL);
ASSERT(m_nTimer != 0);
GetDlgItem(IDC_START)->EnableWindow(FALSE);
volatile int nTemp;
for (m_nCount = 0; m_nCount < nMaxCount; m_nCount++)
{
for (nTemp = 0; nTemp < 10000; nTemp++) { }
if (::PeekMessage(&message, NULL, 0, 0, PM_REMOVE))
{
::TranslateMessage(&message);
::DispatchMessage(&message);
}
} CDialog::OnOK();
}
8: Code the OnTimer function in ComputeDlg.cpp.
void CComputeDlg::OnTimer(UINT nIDEvent)
{
CProgressCtrl* pBar = (CProgressCtrl*) GetDlgItem(IDC_PROGRESS1);
pBar->SetPos(m_nCount * 100 / nMaxCount);
}
9: Update the OnCancel function in ComputeDlg.cpp.
void CControlDlg::OnCancel()
{
TRACE("entering CComputeDlg::OnCancel\n");
if (m_nCount == 0) {
CDialog::OnCancel();
}
else {
m_nCount = nMaxCount; }
}
10: Edit the CComputeDlgView class in ComputeDlgView.cpp.
29
function
to
handle
30
try{
m_pSet->Delete();
}
catch(CDBException* e){
AfxMessageBox(e->m_strError);
e->Delete();
m_pSet->MoveFirst();
UpdateData(false);
return;
}
m_pSet->GetStatus(status);
if(status.m_lCurrentRecord==0)
{
m_pSet->MoveNext();
}
UpdateData(false);
}
void COdbcView::OnRecordUpdate()
{
// TODO: Add your command handler code here
m_pSet->Edit();
UpdateData(true);
if(m_pSet->CanUpdate()){
m_pSet->Update();
}
}
32
33
MDI
// mdiDoc.h
public:
float m_fSalary;
CString m_strName;
// mdiDoc.cpp
CMdiDoc::CMdiDoc():m_strName("")
{
// TODO: add one-time construction code here
m_fSalary=0.0;
}
// mdiView.h
public:
void UpdateControlsFromDoc();
// mdiView.cpp
void CMdiView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
ResizeParentToFit();
UpdateControlsFromDoc();
}
void CMdiView::OnEnter()
{
// TODO: Add your control notification handler code here
CMdiDoc* pDoc = GetDocument();
UpdateData(TRUE);
pDoc->m_fSalary = m_fSalary;
pDoc->m_strName = m_strName;
}
void CMdiView::UpdateControlsFromDoc()
{
CMdiDoc* pDoc = GetDocument();
m_fSalary = pDoc->m_fSalary;
m_strName = pDoc->m_strName;
UpdateData(FALSE);
}
34
Program 10 :
Steps:
1. Start Programs Microsoft VisualStudio6.0 Microsoft Visual c++ 6.0.
2.Then choose the new Text tool and paste the student.cpp coding and paste in the empty
window and save it under the name of student.cpp (save it within the double codes) &do the
same for student.h. close the application.
3. Choose MFC AppWizard (exe) gives the project name and click ok.
4. Choose single based application in step1 of MFC AppWizard &in the step 6 change the base
class as CFormView &design the form view as shown in the figure
35
6. Add a new function name as UpdateControlsFromDoc() name by using class view (Refer
MDI Program) and write the coding.
7. Double click the COMMAND button and write the coding.
8. Go to Project Add to project File Add the student.cpp and student.h from the
location where we saved.
9. Create a new menu under edit menu give the name as Clear All.
10.GO to class wizard and add the coding for clear all menus.
36
public:
CString m_strName;
int m_nGrade;
CStudent()
{
m_nGrade = 0;
}
CStudent(const char* szName, int nGrade) : m_strName(szName)
{
m_nGrade = nGrade;
}
CStudent(const CStudent& s) : m_strName(s.m_strName)
{
// copy constructor
m_nGrade = s.m_nGrade;
}
const CStudent& operator =(const CStudent& s)
{
m_strName = s.m_strName;
m_nGrade = s.m_nGrade;
return *this;
}
BOOL operator ==(const CStudent& s) const
{
if ((m_strName == s.m_strName) && (m_nGrade == s.m_nGrade))
{
return TRUE;
}
else
{
return FALSE;
}
}
BOOL operator !=(const CStudent& s) const
{
// Lets make use of the operator we just defined!
return !(*this == s);
}
virtual void Serialize(CArchive& ar);
};
38
#endif // _INSIDE_VISUAL_CPP_STUDENT
//student.cpp
#include "stdafx.h"
#include "student.h"
IMPLEMENT_SERIAL(CStudent, CObject, 0)
void CStudent::Serialize(CArchive& ar)
{
TRACE("Entering CStudent::Serialize\n");
if (ar.IsStoring()) {
ar << m_strName << m_nGrade;
}
else {
ar >> m_strName >> m_nGrade;
}
}
// serializeDoc.h
public:
CStudent m_student;
// serializeDoc.cpp
//Constructor
CSerializeDoc::CSerializeDoc() : m_student("default value", 0)
{
// TODO: add one-time construction code here
}
// CSerializeDoc serialization
void CSerializeDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
39
}
m_student.Serialize(ar);
}
// serializeView.h
public:
void UpdateControlsFromDoc();
// serializeView.cpp
void CSerializeView::OnEnter()
{
CSerializeDoc* pDoc = GetDocument();
UpdateData(TRUE);
pDoc->m_student.m_nGrade = m_nGrade;
pDoc->m_student.m_strName = m_strName;
}
void CSerializeView::UpdateControlsFromDoc()
{
CSerializeDoc* pDoc = GetDocument();
m_nGrade = pDoc->m_student.m_nGrade;
m_strName = pDoc->m_student.m_strName;
UpdateData(FALSE); // calls DDX
}
void CSerializeView::OnEditClearall()
{
// TODO: Add your command handler code here
GetDocument()->m_student = CStudent(); // "blank" student object
UpdateControlsFromDoc();
}
40
41