You are on page 1of 53

Ex. No.

: 1 NAME:
DATE: REG NO:

1. DATABASE APPLICATIONS USING DATA CONTROL.


AIM:
To create an application that connects with the database using data control in VB

ALGORITHM:
1. Start the program and open the Microsoft VB in standard exe
2. Drag and drop data control in the form
3. Create a database in MS Access
4. Write the coding to declare database and recordset
5. compile and run the program
PROGRAM:
Dim db As Database
Dim rs As Recordset

Private Sub Command1_Click()


rs.MoveFirst
While Not rs.EOF
If Text1.Text = rs.Fields(1) Then
Text2.Text = rs.Fields(2)
Text3.Text = rs.Fields(3)
Label3.Caption = rs.Fields(4)
GoTo x:
Else
MsgBox ("word is not found")
GoTo x:
End If
rs.MoveNext
Wend
End Sub

Private Sub Form_Load()


Set db = OpenDatabase(App.Path + "\dictionary.mdb")
Set rs = db.OpenRecordset("datadic", dbOpenTable)
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
OUTPUT:

RESULT:
Thus an application that connects with the database has been executed successful
Ex. No.: 1 NAME:
DATE: REG NO:

1. SDK PROGRAM FOR GDI OBJECTS


AIM:
To write the SDK program to display GDI Objects
ALGORITHM:
Step1: Select New from the file menu. In the New dialog box pick the Projects tab. Select
Win32 Application. In the Location field select the subdirectory in the Project name field type
the name of the project, which in this case is WindowPgm1. The platform section should indicate
Win32. Choose OK
Step2: A dialog box labeled Win32 application step 1 of 1 will appear. Indicate that you want
to create an Empty project , and press the Finish button
Step3: Choose OK button.
Step 4: Select New from the File menu again.
Step 5: In the New dialog box, pick the Files tab. Select c++ Source File. The Add to Project box
should be checked, and the WindowPgm2 should be indicated. Type the windpgm2.c in the File
Name field. Choose OK.
Step6: Type the coding.
Step7: Compile the program using F7 or pick the Build menu.
Step8: Run the program using ctrl+F5 or click the Execute Program icon.

PROGRAM:
#include <windows.h>
const char g_szClassName[] = "myWindowClass";
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
lParam)
{HDC hdc;
PAINTSTRUCT ps;
POINT parray[10]={10,70,50,70,50,10,90,10,90,50,30,50,30,90,70,90,70,30,10,30};
switch(msg)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
SelectObject(hdc,GetStockObject(GRAY_BRUSH));
SetPolyFillMode(hdc,ALTERNATE);
Polygon(hdc,parray,10);//first parameter handle to device context,second CONST POINT
//*lpPoints pointer to polygon's vertices, third count of polygon's vertices
EndPaint(hwnd,&ps);
return 0;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wc))
{MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"Filled Area",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{TranslateMessage(&Msg);
DispatchMessage(&Msg);
} return Msg.wParam; }

OUTPUT

RESULT:
Thus the program for SDI has been tested and executed successfully .
Ex. No.: 2 NAME:
DATE: REG NO:
Implementation of Building Calculator using PWCT

Aim
To build simple calculator using PWCT Programming without coding techniques.

Implementation Steps:

1. Select the step (The First Step)


2. We will start now new interaction process to generate new steps to our steps tree.
1 - Click Interact to open the components browser
2 - Select the domain (Windows)
3 - Select the component (Define New Window)

Component Browser Select the component (Define New Window)

3. After selecting the component click Ok or press ENTER


Interaction page - Set the properties and enter the required data as in the image above

Form Designer
Goal Desginer - Steps Tree

4. Select the step (Window Controls)


5. We will start now new interaction process to generate new steps to our steps tree.
1 - Click Interact to open the components browser
2 - Select the domain (Controls)
3 - Select the component (Button)

Component Browser Select the component (Button)

6. After selecting the component click Ok or press ENTER


Interaction page - Set the properties and enter the required data as in the image above
Final Steps Tree:

The First Step


Define New Window ( win1 ) , Title : "Simple Calculator by Sameh Kamel"
Window Events
Window Properties
win1.Center ( )
Window Controls
Define New Button ( btn1 ) , Caption : "Close"
Button Events
Event: ON CLICK : Action Sameh()
Button Properties
Define New Button ( btn2 ) , Caption : "+"
Button Events
Event: ON CLICK : Action Sum()
Button Properties
Define TextBox ( text1 )
TextBox EVENTS
TextBox Properties
Define TextBox ( text2 )
TextBox EVENTS
TextBox Properties
Define TextBox ( text3 )
TextBox EVENTS
TextBox Properties
Define New Button ( btn3 ) , Caption : "-"
Button Events
Event: ON CLICK : Action Minus()
Button Properties
Define New Button ( btn4 ) , Caption : ""
Button Events
Event: ON CLICK : Action Multi()
Button Properties
Define New Button ( btn5 ) , Caption : ""
Button Events
Event: ON CLICK : Action Div()
Button Properties
Define Label ( lbl2 ) , Caption : "="
Label Events
Label Properties
End Of Window
Activate window
proc
Define Procedure Sameh
Start Here
win1.Release ( )
End of Procedure
Define Procedure Multi
Start Here
num1 = win1.text1.Value
num2 = win1.text2.Value
win1.text3.Value := num1*num2
End of Procedure
Define Procedure Sum
Start Here
num1 = win1.text1.Value
num2 = win1.text2.Value
win1.text3.Value := num1+num2
End of Procedure
Define Procedure Div
Start Here
num1 = win1.text1.Value
num2 = win1.text2.Value
win1.text3.Value := num1/num2
End of Procedure
Define Procedure Minus
Start Here
num1 = win1.text1.Value
num2 = win1.text2.Value
win1.text3.Value := num1-num2
End of Procedure

Output:

Result:

The application using PWCT is executed successfully.


Ex. No.: 3 NAME:
DATE: REG NO:

Implementation of advanced dynamic Slider & Image control applications


AIM:
To implement of advanced dynamic slider & image control applications using vc++

ALGORITHM:

1- Start Microsoft Visual C++.


2- a Using the MFC AppWizard (exe), create a dialog project called ExoSlider.
b In Step 2 of 4 of the MFC AppWizard page, title your dialog as: Slider. ClickFinish.
c Once you are back in the studio of Visual C++, delete the TODO line of text on the
dialog.
If you are using Visual C++ 6, you might get a dialog that is too big for this exercise,
you might just have to shrink it.
d Insert two static texts, one edit, and one slider controls, like the above graphic shows.
Identify the Edit box as: IDC_SLIDER_VALUE.
Identify the Slider control as IDC_SLIDER.

3- a Right-click in the current dialog and choose ClassWizard...


b In the ClassWizard, from the Member Variables property sheet, double-
click IDC_SLIDER to Add Member name m_Slider which is of CategoryControl and
of the Variable Type CSliderCtrl. Click OK.
Add Member Variable for IDC_SLIDER_VALUE called m_SliderValue of
Category Value and a CString Variable Type. Click OK.
c Still in the MFC ClassWizard dialog box, click Message Maps. In the Object IDs list
box, click CExoSliderDlg. In the list of Member Functions, clickOnInitDialog. Click
the Edit Code button.
We will set the range values for the slide control, namely the minimum and the
maximum values.
d

e Our application still needs to provide communication between the edit and the slider
controls. Access the ClassWizard and
associate WM_HSCROLLto CExoSliderDlg (Did I tell you that you could have made
your slider control vertical by changing its position in the Properties dialog so in that
case you could be choosing WM_VSCROLL in ClassWizard?).
Implement the OnHScroll() function as follows:

On the main menu, click Build -> Set Action Configuration...


Double-click ExoSlider - Win32 Release.
Implement the OnInitDialog() function as follows:

if(nSBCode == SB_THUMBPOSITION) {
m_SliderValue.Format("%ld", nPos);
UpdateData(false);
}

else {
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

Implement the OnHScroll() function as follows:


CDialog::OnHScroll(nSBCode, nPos, pScrollBar);

// TODO: Add extra initialization here


m_Slider.SetRangeMin(1, false);
m_Slider.SetRangeMax(100, false);
m_SliderValue = "1";
UpdateData(FALSE);

OUTPUT
RESULT:

Thus the dynamic slider and image control application is implemented.


Ex. No.: 4 NAME:
DATE: REG NO:

4. PROGRAMMING FOR READING AND WRITING INTO DOCUMENTS.

AIM :
To design a document view structure to print a text with popup menu.
ALGORITHM:

1. Start the program.


2. Declare a variable of type class Cstring.
3. Create a Rich control with an object.
4. Create OnCreate(), OnSize(), OnNewDocument() by selecting
view->classwizard.
5. Create an edit field in edit menu and right click it and select class wizard and select both
OnCommand and Update Command for add function.
6. After creating both Edit and Update Edit function then click edit code button to edit the
code.
7. Create two menus named Transferstoredataindoc and Transfergerdatafromdoc and select
view->classwizard to edit the code.
8. Then Create an Oncontextmenu() function and edit the code to load the particular menu
you want.
9. Then Create two menu named Colour with green and red to Display a text in particular
color.
10. End the program.

PROGRAM:
Class view :
/*docviewDoc.h*/

#if !
defined(AFX_DOCVIEWDOC_H__E195BA16_9682_4B30_80B6_551437792826__INCLUD
ED_)
#define
AFX_DOCVIEWDOC_H__E195BA16_9682_4B30_80B6_551437792826__INCLUDED_

#if _MSC_VER > 1000


#pragma once
#endif // _MSC_VER > 1000
class CDocviewDoc : public CDocument
{
protected: // create from serialization only
CDocviewDoc();
DECLARE_DYNCREATE(CDocviewDoc)

// Attributes
public:
CString m_str;

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDocviewDoc)
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
//}}AFX_VIRTUAL

// Implementation
public:
virtual ~CDocviewDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions


protected:
//{{AFX_MSG(CDocviewDoc)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !
defined(AFX_DOCVIEWDOC_H__E195BA16_9682_4B30_80B6_551437792826__INCLUD
ED_)

/* docviewView.h */

#if !
defined(AFX_DOCVIEWVIEW_H__ED57B075_5437_4545_9A70_C58D68EC4804__INCLU
DED_)
#define
AFX_DOCVIEWVIEW_H__ED57B075_5437_4545_9A70_C58D68EC4804__INCLUDED_

#if _MSC_VER > 1000


#pragma once
#endif // _MSC_VER > 1000

class CDocviewView : public CView


{
protected: // create from serialization only
CDocviewView();
DECLARE_DYNCREATE(CDocviewView)
// Attributes
public:
CDocviewDoc* GetDocument();
CRichEditCtrl m_rich;

// Operations
public:

// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDocviewView)
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL

// Implementation
public:
virtual ~CDocviewView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions


protected:
//{{AFX_MSG(CDocviewView)
afx_msg void OnColorGreen();
afx_msg void OnColorRed();
afx_msg void OnTransferGet();
afx_msg void OnTransferStore();
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG // debug version in docviewView.cpp


inline CDocviewDoc* CDocviewView::GetDocument()
{ return (CDocviewDoc*)m_pDocument; }
#endif

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !
defined(AFX_DOCVIEWVIEW_H__ED57B075_5437_4545_9A70_C58D68EC4804__INCLU
DED_)

File view

#include "stdafx.h"
#include "docview.h"

#include "docviewDoc.h"
#include "docviewView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CDocviewView

IMPLEMENT_DYNCREATE(CDocviewView, CView)

BEGIN_MESSAGE_MAP(CDocviewView, CView)
//{{AFX_MSG_MAP(CDocviewView)
ON_COMMAND(ID_COLOR_GREEN, OnColorGreen)
ON_COMMAND(ID_COLOR_RED, OnColorRed)
ON_COMMAND(ID_TRANSFER_GET, OnTransferGet)
ON_COMMAND(ID_TRANSFER_STORE, OnTransferStore)
ON_WM_CONTEXTMENU()
ON_WM_CREATE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

// CDocviewView construction/destruction

CDocviewView::CDocviewView()
{
// TODO: add construction code here

}
CDocviewView::~CDocviewView()
{
}
BOOL CDocviewView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CView::PreCreateWindow(cs);
}
// CDocviewView drawing

void CDocviewView::OnDraw(CDC* pDC)


{
CDocviewDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
// CDocviewView printing

BOOL CDocviewView::OnPreparePrinting(CPrintInfo* pInfo)


{
// default preparation
return DoPreparePrinting(pInfo);
}

void CDocviewView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)


{
// TODO: add extra initialization before printing
}

void CDocviewView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)


{
// TODO: add cleanup after printing
}

// CDocviewView diagnostics

#ifdef _DEBUG
void CDocviewView::AssertValid() const
{
CView::AssertValid();
}

void CDocviewView::Dump(CDumpContext& dc) const


{
CView::Dump(dc);
}

CDocviewDoc* CDocviewView::GetDocument() // non-debug version is inline


{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CDocviewDoc)));
return (CDocviewDoc*)m_pDocument;
}
#endif //_DEBUG

// CDocviewView message handlers


void CDocviewView::OnColorGreen()
{
// TODO: Add your command handler code here
CDC *p=GetDC();
p->SetTextColor (RGB(0,255,0));
p->TextOut (100,100,"II MCA B");
ReleaseDC(p);
}

void CDocviewView::OnColorRed()
{
// TODO: Add your command handler code here

CDC *p=GetDC();
p->SetTextColor (RGB(255,0,0));
p->TextOut (100,100,"II MCA B");
ReleaseDC(p);
}

void CDocviewView::OnTransferGet()
{
// TODO: Add your command handler code here
CDocviewDoc *e=GetDocument();
m_rich.SetWindowText(e->m_str);
m_rich.SetModify(FALSE);

}
void CDocviewView::OnTransferStore()
{
// TODO: Add your command handler code here

CDocviewDoc *e=GetDocument();
m_rich.GetWindowText(e->m_str);
m_rich.SetModify(FALSE);

void CDocviewView::OnContextMenu(CWnd* pWnd, CPoint point)


{
// TODO: Add your message handler code here
CMenu m;
m.LoadMenu(IDR_MAINFRAME);
m.GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN,point.x ,point.y ,this);
}

int CDocviewView::OnCreate(LPCREATESTRUCT lpCreateStruct)


{
if (CView::OnCreate(lpCreateStruct)==-1)
return -1;

// TODO: Add your specialized creation code here


CRect rect(0,0,0,0);
m_rich.Create(ES_MULTILINE|WS_VISIBLE|WS_VSCROLL,rect,this,1);
return 0;
}

void CDocviewView::OnSize(UINT nType, int cx, int cy)


{
CView::OnSize(nType, cx, cy);

// TODO: Add your message handler code here


m_rich.SetWindowPos (&wndTop,0,0,400,400,SWP_SHOWWINDOW);
}
OUTPUT:
On clicking the menu item red:

After clicking Store:


Clicking Get:

RESULT:
Thus the program using Document View Architecture in VC++ was executed successfully.
Ex. No.: 5 NAME:
DATE: REG NO:

5. DYNAMIC LINKING LIBRARIES


AIM:
To design a DLL in connection with just one application.
ALGORITHM:
1. Start the program
2. Select a regular dll
3. It can be linked both statically and dynamically.
4. Static dll functions can be exported into Exe file.
5. Exe file can imported all the functions of the dll files.
6. Stop the process.
7. End.
PROGRAM:
//EXPORT DLL
//Dyn.h
#include "math.h"

//dyn.cpp
extern "C"__declspec(dllexport)double sqrroot(double d)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
if(d>0.0)
{
return sqrt(d);
}
AfxMessageBox("NO");
return 0.0;
}
//IMPORT DLL

//dyn1.h
#include "math.h"
extern "C"__declspec(dllimport)double sqrroot(double d)
//dialog
void CDyn1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(true);

m_output=sqrroot(m_input);
UpdateData(false);
}

OUTPUT:

RESULT:
Thus the program to create a dynamic link library using MFC is tested and
executed successfully.
Ex. No.: 6 NAME:
DATE: REG NO:

6. DATA ACCESS THROUGH ODBC CDATABASE, CRECORDSET

AIM :
To design a student information system using database
ALGORITHM:
1. Start the program.
2. Design an interface form with menu options
3. Write appropriate coding for menu options add , modify , delete , update .
4. Execute the application to display the details of all students.
5. Calculate the average and total of each student
6. Stop the process
7. End.
PROGRAM:
// studentView.cpp : implementation of the CStudentView class
//
#include "stdafx.h"
#include "student.h"

#include "studentSet.h"
#include "studentDoc.h"
#include "studentView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CStudentView

IMPLEMENT_DYNCREATE(CStudentView, CRecordView)

BEGIN_MESSAGE_MAP(CStudentView, CRecordView)
//{{AFX_MSG_MAP(CStudentView)
ON_BN_CLICKED(IDC_BUTTON1, OnTotal)
ON_BN_CLICKED(IDC_BUTTON2, OnAverage)
ON_BN_CLICKED(IDC_BUTTON3, OnAdd)
ON_BN_CLICKED(IDC_BUTTON4, OnDelete)
ON_BN_CLICKED(IDC_BUTTON5, OnEdit)
ON_BN_CLICKED(IDC_BUTTON6, OnExit)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()
// CStudentView construction/destruction

CStudentView::CStudentView()
: CRecordView(CStudentView::IDD)
{
//{{AFX_DATA_INIT(CStudentView)
m_pSet = NULL;
//}}AFX_DATA_INIT
// TODO: add construction code here

CStudentView::~CStudentView()
{
}

void CStudentView::DoDataExchange(CDataExchange* pDX)


{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStudentView)
DDX_FieldText(pDX, IDC_EDIT1, m_pSet->m_StudName, m_pSet);
DDX_FieldText(pDX, IDC_EDIT2, m_pSet->m_RegNo, m_pSet);
DDX_FieldText(pDX, IDC_EDIT3, m_pSet->m_m1, m_pSet);
DDX_FieldText(pDX, IDC_EDIT4, m_pSet->m_m2, m_pSet);
DDX_FieldText(pDX, IDC_EDIT5, m_pSet->m_m3, m_pSet);
DDX_FieldText(pDX, IDC_EDIT6, m_pSet->m_tot, m_pSet);
DDX_FieldText(pDX, IDC_EDIT7, m_pSet->m_avg, m_pSet);
//}}AFX_DATA_MAP
}

BOOL CStudentView::PreCreateWindow(CREATESTRUCT& cs)


{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

return CRecordView::PreCreateWindow(cs);
}

void CStudentView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_studentSet;
CRecordView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
// CStudentView printing
BOOL CStudentView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}

void CStudentView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)


{
// TODO: add extra initialization before printing
}

void CStudentView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)


{
// TODO: add cleanup after printing
}
// CStudentView diagnostics

#ifdef _DEBUG
void CStudentView::AssertValid() const
{
CRecordView::AssertValid();
}

void CStudentView::Dump(CDumpContext& dc) const


{
CRecordView::Dump(dc);
}

CStudentDoc* CStudentView::GetDocument() // non-debug version is inline


{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CStudentDoc)));
return (CStudentDoc*)m_pDocument;
}
#endif //_DEBUG
// CStudentView database support
CRecordset* CStudentView::OnGetRecordset()
{
return m_pSet;
}
// CStudentView message handlers
void CStudentView::OnTotal()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_pSet->m_tot=(m_pSet->m_m1+m_pSet->m_m2+m_pSet->m_m3);
UpdateData(false);
}
void CStudentView::OnAverage()
{
// TODO: Add your control notification handler code here
UpdateData(true);
m_pSet->m_avg=(m_pSet->m_tot)/3;
UpdateData(false);

void CStudentView::OnAdd()
{
// TODO: Add your control notification handler code here
m_pSet->AddNew();
UpdateData(true);
m_pSet->Update();

void CStudentView::OnDelete()
{
// TODO: Add your control notification handler code here
m_pSet->Delete();
UpdateData(true);

void CStudentView::OnEdit()
{
// TODO: Add your control notification handler code here
m_pSet->Edit();

void CStudentView::OnExit()
{
// TODO: Add your control notification handler code here
exit(0);
}
OUTPUT:

RESULT:
Thus the given program to interface with database using VC++ 6.0 was executed and
verified successfully.
Ex. No.: 7(A) NAME:
DATE: REG NO:

7. A) STATUSBAR APPLICATION

AIM:
To write a program, to create a status bar and to display the coordinates of the mouse
pointer and display the time.
ALGORITHUM:
Create a dialog based application using VC++.
1. Create a number variable for status bar.
2. Also create a member function for
i) mouse move
ii) time
3. Divide the status bar into 2 parts, one for displaying mouse movement
and other for displaying the time at bottom corner.
4. Use the in built functions to display the required things
5. Compile and run the program.

RESOURCE VIEW:
ID_INDICATOR_START
ID_INDICATOR_TIME

PROGRAM:

// ex 11Dlg.cpp : implementation file


//

#include "stdafx.h"
#include "ex 11.h"
#include "ex 11Dlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static UINT BASED_CODE
indicator[]={IDS_INDICATOR_START,IDS_INDICATOR_TIME};
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog


{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides


//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEx11Dlg dialog
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEx11Dlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEx11Dlg, CDialog)
//{{AFX_MSG_MAP(CEx11Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_SIZE()
ON_WM_MOUSEMOVE()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CEx11Dlg message handlers

BOOL CEx11Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);


if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX,
strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here


SetTimer(100,100,NULL);
m_bar.Create(this);
m_bar.SetIndicators(indicator,2);
CRect rect;
GetClientRect(&rect);
m_bar.SetPaneInfo(0,IDS_INDICATOR_START,SBPS_NORMAL,rect.Width()-
100);
m_bar.SetPaneInfo(1,IDS_INDICATOR_TIME,SBPS_STRETCH,0);

RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,I
DS_INDICATOR_TIME);
return TRUE; // return TRUE unless you set the focus to a control
}
void CEx11Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CEx11Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle


int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
void CEx11Dlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);

// TODO: Add your message handler code here

void CEx11Dlg::OnMouseMove(UINT nFlags, CPoint point)


{
// TODO: Add your message handler code here and/or call default
CString s;
s.Format("X:%d Y:%d",point.x,point.y);
m_bar.SetPaneText(0,s);
CDialog::OnMouseMove(nFlags, point);
}

void CEx11Dlg::OnTimer(UINT nIDEvent)


{
// TODO: Add your message handler code here and/or call default
if(nIDEvent==100)
{
CTime t1;
t1=CTime::GetCurrentTime();
m_bar.SetPaneText(1,t1.Format("%H:%M:%S"));
}
CDialog::OnTimer(nIDEvent);
}

OUTPUT:

RESULT:
Thus the program has been created and executed successfully
Ex. No.: 7(B) NAME:
DATE: REG NO:

7. B.CREATING SPLITTER WINDOWS


AIM:
To run the program for dynamically splitting window using document view architecture
ALGORITHM:
1. Start the program
2. MFC application wizard exe step 4 -> features->advanced-> windows style.
3. Write the code in the OnDraw part
4. Static dll functions can be exported into Exe file.
5.Compile and run the program
6. Stop the process.
PROGRAM:
#include "stdafx.h"
#include "split.h"
#include "splitDoc.h"
#include "splitView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// CSplitView

IMPLEMENT_DYNCREATE(CSplitView, CView)

BEGIN_MESSAGE_MAP(CSplitView, CView)
//{{AFX_MSG_MAP(CSplitView)
ON_COMMAND(ID_COLORS_GREEN, OnColorsGreen)
ON_COMMAND(ID_COLORS_RED, OnColorsRed)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
// CSplitView construction/destruction
CSplitView::CSplitView()
{
// TODO: add construction code here
}
CSplitView::~CSplitView()
{
}

BOOL CSplitView::PreCreateWindow(CREATESTRUCT& cs)


{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
// CSplitView drawing

void CSplitView::OnDraw(CDC* pDC)


{
CSplitDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBrush m;
m.CreateSolidBrush(RGB(100,5,100));
pDC->SelectObject(&m);
pDC->Ellipse(200,200,50,300);
pDC->TextOut(250,250,"Splitter Window",15);
// TODO: add draw code for native data here
}

// CSplitView printing
BOOL CSplitView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CSplitView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CSplitView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
// CSplitView diagnostics

#ifdef _DEBUG
void CSplitView::AssertValid() const
{
CView::AssertValid();
}

void CSplitView::Dump(CDumpContext& dc) const


{
CView::Dump(dc);
}
CSplitDoc* CSplitView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CSplitDoc)));
return (CSplitDoc*)m_pDocument;
}
#endif //_DEBUG
// CSplitView message handlers
void CSplitView::OnColorsGreen()
{
// TODO: Add your command handler code here
CClientDC p(this);
CRect r;
GetClientRect(&r);
COLORREF b;
b=RGB(100,20,50);
CBrush br(b);
p.FillRect(&r,&br);
}
void CSplitView::OnColorsRed()
{
// TODO: Add your command handler code here
CClientDC p(this);
CRect r;
GetClientRect(&r);
COLORREF b;
b=RGB(255,0,0);
CBrush br(b);
p.FillRect(&r,&br);
}
OUTPUT:

RESULT:
Thus the given program to implement the split window Using VC++ 6.0 was executed
and verified successfully.
Ex. No.: 8 NAME:
DATE: REG NO:

8.PROGRAM TO DISPLAY BITMAP IMAGES

AIM:
To create a bitmap and display the image into an untitled document.

ALGORITHM:
1. Create a single document .
Select insert ->resource->bitmap Create a new bitmap
2. Select the file view ,in that open the bitview.cpp and in ondraw function type the
code.
3. Run the code
4. The bitmap image will be displayed on the output window.

SOURCE CODE:
void CBm3aView::OnDraw(CDC* pDC)
{
CBm3aDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP2);
BITMAP bm;
bmp.GetObject(sizeof(BITMAP),&bm);
CDC dcmem;
dcmem.CreateCompatibleDC(pDC);
CBitmap *pbmpOld=dcmem.SelectObject(&bmp);
pDC->BitBlt(10,10,bm.bmWidth,bm.bmHeight,&dcmem,0,0,SRCCOPY);
dcmem.SelectObject(pbmpOld);
}
OUTPUT:

RESULT:
Thus the program to load the bit map dynamically with and with out wizard using
vc++ is successfully executed .
Ex. No.: 9 NAME:
DATE: REG NO:

9.CREATING AN ACTIVEX CONTROL


AIM:
To create Activex Control in VC++ (Currency conversion)

ALGORITHM:
STEP 1: Open Microsoft Visual C++ and select,
File->New->Project->ATLCOM AppWizard.

STEP 2: Type the project name as curcon and select Dynamic Linking Library(DLL)
and press Finish.

STEP 3: Right click on the curcon class and select


new ATL Object->Simple Object->currency(short name).

STEP 4: Right click on Icurrency under curcon class and Add method.

STEP 5: Type the method name(indtofor & fortoind)and parameters in the new window
that is opened.

STEP 6: Go to file view and write the coding for the added methods.
Curcon files->Source files->double click on currency.cpp

STEP 7: Build the project.(need not execute)

//VB.NET CLIENT
STEP 8: Open a new project as,
File->New->Project->Microsoft VisualBasic->Windows Application->Ok.

STEP 9: Add reference as,


Project->Add references->COM->Browse(select curcon.tlb).

STEP 10: Design the form with labels,textbox,combo box and buttons.

STEP 11: Write the code in button1_Click and button2_Click.

STEP 12: Execute and stop the program.


SOURCE CODE:

Project Name ->curcon


Short Name ->currency

VC++ Server
// currency.cpp : Implementation of Ccurrency
#include "stdafx.h"
#include "Curcon.h"
#include "currency.h"

//Indian to Foreign Currency


STDMETHODIMP Ccurrency::indtofor(int a, int b, int *c)
{
switch(b)
{
case 1: //EURO
*c=a/62;
break;
case 2://US DOLLAR
*c=a/45;
break;
case 3: //DINAR
*c=a/158;
break;
case 4://POUND
*c=a/68;
break;
case 5: //YEN
*c=a/2;
break;
}
return S_OK;
}

//Foreign to Indian Currency


STDMETHODIMP Ccurrency::fortoind(int a, int b, int *c)
{
switch(b)
{
case 1://EURO
*c=a*62;
break;
case 2://US DOLLAR
*c=a*45;
break;
case 3: //DINAR
*c=a*158;
break;
case 4://POUND
*c=a*68;
break;
case 5: //YEN
*c=a*2;
break;
}
return S_OK; }

VB.NET Client
Form Design
Dim obj As CURCONLib.currency

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
obj = New CURCONLib.currency
TextBox2.Text = obj.indtofor(Val(TextBox1.Text), ComboBox1.SelectedIndex + 1)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
obj = New CURCONLib.currency
TextBox3.Text = obj.fortoind(Val(TextBox1.Text), ComboBox2.SelectedIndex + 1)
End Sub
End Class
OUTPUT:

RESULT:
Thus the program to perform currency conversion using vc++ is successfully
executed .
VIVA QUESTIONS
Ex No. 1
1. What is the size of class
Size of the class will be the some of the size of all member variables. For example if in a
class we have one integer and one char. Then in 32 bit OS size will be 8 bytes ( Padding comes
here in picture ).
2. What is the difference between Synchronous
Asynchronous sockets are usually defined by the server side application and not by what the
client's doing. I'm apparently wrong per your developer, but I thought an asynchronous socket
allows multiple connections by forking or threading. A synchronous socket processes one request
at a time.
3. What is CArchive class dowes
CArchive is the class which is not derived from CObject. This is the class by which we do
serialization.
4. What is a message map, and what is the advantage of a message map over virtual functions?
Message map is the mechanism by which MFC handles the application messages. Advantage
of message map over virtual function is in case of virtual function VTABLE will grow and you
will have vptr for each and every instance of your class having virtual function.
5. What function is used to retrieve the currently selected index in a list box?
GetCurSel is the method.
6. Explain something about MFC?
MFC :- Microsoft Foundation Class. A collection of classes by which you can create GUI
based applications. You can create Active X control , COM component etc.
CObject is the base class of MFC.
7. Why not virtual functions to handle messages?
If you have virtual functions instead of message map then for each class ( having virtual
function ) there will be a vptr. vptr will take 4 bytes. Also your VTABLE will grow because you
have more virtual functions in your class.
To avoid this situtation MFC has given feature of message map.
8. How to handle command line arguments from simple MFC application ?
CCommandLineInfo class.
9. How to setup a timer?
goto class wizard and add ontimer function in that function u can declare which function
u want to do ..
in onint function settimer (0,1000,NULL)
this is used to trigger every one second
you can stop timer using killtimer function
10. How to access document object from view ?
GetDcoument() function will return pView pointer
11. What is the use of CCmdTarget ?
CmdTarget provides the message mapping functionality in MFC. It routes messages to their
respective functions.
12. How to create a Modeless Dialog?
using Create Method , we can create a Modeless dialog box.
CDialog dlg(IDD_DIALOG1);
dlg.Create();
Modal Dialog Box:
CDialog dlg(IDD_DIALOG1);
dlg.DoModal();

13. What function is used to disable a control at runtime?


EnableWindow(false)
14. What is the command routing in MFC framework?
CView->CDocument->CFrameWnd->CWinApp
15. What is the difference between ASSERT and VERIFY?
ASSERT used in Debug Version where in VERIFY used in Debug / Release version.
16. What interface must be supported by an ActiveX control?
IDispatch interface
17. What four types of properties are supported by an ActiveX control?
Ambient properties are provided to the control by the container. The control uses these
properties in order to "fit in" properly. Commonly used ambient properties include the container's
background color, default font, and foreground color.
18. What is CSingleDoc Template?
It is used to create SDI Applications.
19. How to update all the views whenever document got updated ?
UpdateAllViews - a method of CDocument
20. What is the use of OninitDialog ?
OnInitDialog needs to be overridden for initialization of controls ( if any ) of dialog box.
CDialog m_dlg;
m_dlg.DoModal(); // Here OnInitDialog will get called.
21. How to convert a CString variable to char* or LPTSTR?
GetBuffer method of CString function.
22. What is document-view architecture ? Give one real time example for SDI ?
notepad is one real time example of SDI Application.
Document View Architecture :- In this document has two part one is for saving the data and one if
for displaying the data ( mean to say the view ). This contains four classes of MFC.
1) CFrameWnd
2) CView
3) CDocument
4) CWinApp
23. What is a critical section and how is it implemented?
CCriticalSection is for with in the process.
Refer MSDN site for example how to use it.
24. How can we create thread in MFC framework?
AfxBeginThread
25. Does the application have more than one object? If Yes, Briefly explain ?
No,one application can't have more than one object. Because when we create the
Application class object.It calls WinMain() function & which calls AfxWinInit() to register the
window class, InitInstace() to start,show & update the window. Than calls the Run() function
which call
CWinThread::MessagePump() for message loop.
Once it receive the WM_QUIT message it will call AfxWinTerm
() to cleanup & exit the application.
26. What is LPCTSTR? What does LP denote it?
LPCTSTR = Long Pointer to a Const TCHAR String
LPCTSTR = const char* or const wchar_t* depending on _UNICODE
LP - LONG POINTER
27. Explain Doc/View architecture ?
Document/View Architecture (MFC)

28. How to transfer between one exe to another exe while running in VC++ ?
system("MySecondApplication.exe");
WinExec("MySecondApplication.exe",true);
::ShellExecute(NULL,NULL,L"MySecondApplication.exe",NULL,NULL,NULL);
29. What are the differences between MFC Exception macros and C++ exception keywords?
The major difference between the macros and the keywords is that code using the macros
"automatically" deletes a caught exception when the exception goes out of scope. Code using the
keywords does not, so you must explicitly delete a caught exception.
30. What is LoadLibrary function returns?
On success, LoadLibrary() returns a handle to the module
31. What are the types of button controls?
Two types of button controls are there: 1) Command(Push) Button & 2) Radio Button
32. What is serialization ?which function is responsible for serializing data ?
Serialization is the process of converting an object into sequence of bits so that it can be
stored and retrieved from a storage medium e.g. file. serialize() is responsible for serialization of
data.
33. If we derive a new class from CObject what are the basic features the derived class will get ?
If you derive from CObject, you will get following features available
1) Synchronization(Saving and Retrieving Data)
2) Run-time class information
3) Object diagnostic output
4) Compatibility with collection classes
34. Tell about different kinds of synchronization objects ?
CMutex - allows only one thread from any process to access an object
CCriticalSection - allows only one thread from within the current process to access an object
CEvent - notifies an application when an event has occured
CSemaphore - allows between one and a max. number of simultaneous access to an object
35. What view class enables you to use an edit control as a view?
CEditView class
36. What MFC base classes provide support for ActiveX controls?
COleControl
37. What types of threads are supported by MFC framework?
MFC supports two types of threads:
1 Worker Thread - Commonly used to handle background task
2 User Interface Thread - Used to handle user inputs and respond to events and messages
generated by the user
38. What is the difference between OnInitialUpdate and OnUpdate?
OnInitialUpdate() is called once when the view is first created while OnUpdate() is called
everytime the document updates its views
39. What is the difference between Cmutex and Csemaphone?
CMutex allows only one thread from any process to access an object while CSemaphore
allows between one and a specified maximum number of simultaneous accesses to an object.
40. What is the difference between Model and Modeless Dialog?
The difference between a modal and modeless dialog box is that, modal dialogs once invoked
will not allow the users to access the parent window, where as modeless dialogs will allow the
user to work with the parent window. A user cannot enter inputs in any other dialog or invoke a
menu option except without explicitly closing the modal dialog, within the application. But the
user can leave the modeless dialog open and do anything after the modless dialog is invoked.
41. What is the base class for MFC Framework ?
CObject is the root base class for MFC framework.

42. What is the difference between GetMessage and PeekMessage ?


GetMessage() function returns only when it receives any message from the application queue,
it waits infinitely until received any message whereas PeekMessage() function does not wait.
43. Name the Synchronization objects?
CCricticalSection,CMUtex,CEvent,CSemaphore
44. What function is called by a document class to notify views that the document has been changed?
UpdatAllViews() function
45. What is the difference between regular dlls and extended dlls?
MFC Extension Dll:-The dll extent the implementation of the MFC class libraries(derive a
class from existing class).The export functions of this dll (.def file-interface)has mfc object
parameters.The client application which use this MFC Extension dll should be a MFC application
Regular DLL:-
The dll might have win-32 functions and MFC objects. but (.def file-interface) function should
NOT have any MFC parameters(like mfc objects).it shoud have "c " type export functions.It can
be used by both win-32 app and mfc applications
46. What is the use of AFX_MANAGE_STATE ?
Generally application uses resources from local resource pool
AFX_MANAGE_STATE(AfxGetStaticModuleState);
This allows to switch to dll resources.
47. What is sub classing
Subclassing is basically a method that allows you to intercept Windows Messages that is
being sent to a particular Window (ie Form, Control, etc).
48. What are tuples in vc++?
The tuple is used to refer the different types of object instances. The object instances can be of just
declarations, pertaining to template functions or just functions. Accordingly the classes are differentiated
as tuple class, tuple size class and tuple elements class in VC++.
49. How can you have controlled access to the resources, i.e in a thread-safe manner?
You have to have the resources to be controlled with Cmutex object. Then within every object trying to
access this resource declare the variable that is of the type CsingleLock/CMultiLock. Calling the lock
funtion from this access variable. If you cannot get access in some time, then timeout and continue
execution or if you got access perform the functions and do the unlock over the lock variable. Now we
have a thread-safe access to the specified resource guarded by the mutex.
50. When do we use AFX_MANAGE_STATE(AfxGetStaticModuleState( )); ?
The AFX_MANAGE_STATE is used for switching the handle to resource template of the application.
This is required when the application is going to have a change in application resources due to reference
to externally linked DLL from which execution is to continue. The AfxGetStaticModuleState() gets the
handle for resource map I.e that application state from the specific application instance from which it is
called from. After this the AFX_MANAGE_STATE switches the state accordingly and the application
continues execution.
51. What is the return value of InitApplication();?
The InitApplication is used to execute an application and it returns the output of the application. This
denotes whether a specific application has executed successfully or not.
52. What is the use of regex_search() function?
The regex_search() function is used to search the regular expressions and patterns in the specific string. It
also offers various capture groups and parameters for narrowing down the search for the regular
expression including alloc, Elem and rxtraits.
53. Can we have something like virtual static declaration?
No, Under no possible condition can we have a static entity which is declared as virtual. Virtual entities
are for the overriding of the functions individually at different levels of object hierarchy but when it
comes to static object parameters, they are not related to object hierarchy, they are unique for the entire
class declaration, so virtual and static qualifiers can never be combined together.
54. Explain the typical use of CwinThread.
The CwinThread finds its use in the development of GUI or any other threaded application for that matter.
This gives out a separate parallel thread of execution for the program.
55. Why do we need to kill an object prematurely? How is it done?
Sometime the usage of object ends and it does the much wanted cleanups. This is when we need to kill
the object prematurely. This can be done by scoping out the usage from the rest of the function. This way
the destructor is called automatically.
56. What is the difference between a struct and a union, a struct and a class?
The struct allocates memory when declared and it is sum of all the different variables inside the structure
declaration. The Union allocates memory only as much as required by the largest data type of the
members in the union.
When it comes to difference between class and struct, the class has a default inheritance access to be
private while for a struct the inheritance access level is defaulting to public. All the members of the struct
are public unlike class where we declare the access parameters.
57. What is the use of namespace?
The namespace is used for classification of the different functions and other entities and having a generic
template to the accessed parameters. The namespace eliminates the collision between the various naming
collisions that may occur between the various libraries.Use of functions with namespace qualifiers also
makes the code much more readable and sensible.
58. What is the use of typedef?
Typedef is used for declaring a user defined or predefined data type to be accessed by some other name of
our choice. This helps in making the code more modular and even when there is changes going on with
the implementation details (when migrating from one platform to another) the code can still be
maintained the same in all other files, the only place where implementation details affect are in the
typedef parameters.
59. What is function pointer?
Function pointer refers to the pointer to the function and this can be used to call the function as it is done
normally. The other important thing is to help associate the function with objects. In such a case, we have
a reference to the function to be called within the object entity. This helps in having multiple lines of
actions according to the type of object and data or multiple lines of object depending on the type of data
contained in the object. This way the control logic is made simpler in implementation.
60. What are frames?
Frames refer to the window parameters that depict the position of the window and the physical
dimensions and sizes. The application that are based on the Document/view model mostly use the frames
to manipulate the windows and other appearance.
61. What is the use of having a stack based buffer overrun detection?
The stack based buffer over run detection helps in avoiding the program from executing malicious code.
The epilogue code implements the various checks aimed at having the stack based checks. This avoids the
data corruption. The VC++ 2005 and above have the feature.
62. What is the difference between the Visual studio express and professional development
environments?
The professional editions come with the built in support for the windows SDK libraries. The Express
editions do not have the capability to build MFC as the windows.h and other windows SDK library
related headers will not be available.
63. How is the type_traits useful?
The type_traits gives us information regarding the various defined constants, macros and other arguments
at the compile time. We can also identify if a integer type has true value and other such inferences can be
made with the use of some other extensions.
64. What is a DLL? How is it different from a static library file?
Static libraries are the ones that have the functions and other entities defined inside the library but gets
linked during compile time of the application. The DLLs are on the other hand dynamically linked. Only
the reference to the specific library file and specific function location inside the file is used during
compilation and when the application executes it just calls the function referred.
65. What is command routing?
Command routing refers to the routing of the command across the various objects which have subscribed
for the specific command. In case no object in the hierarchy is handling the command at that instance,
then the application object takes it up and ignores it.
66. What is the difference between the CDialog and CFormView?
The CFormView is usually used in the Document/view modeled applications. The Cdialog is initialized
by the OnInitDialog() and the CFormView() is put on the OnInitialUpdate().
67. What is the difference between the document class and a view class?
The document class is the one that is going to alter the data involved in the program. All the computation
and processing aspects of the application come under the Document class. The view class is the one that
interfaces the user with the various data made available through the document classes. The view class is
the one that creates the Gui using the various window elements.
68. What is the library that contains the socket functions of the windows? What headers are the ones
included?
The winsock.h and winsock2.h are the two headers which represent the two different versions of the
windows socket library. The ws2_32.dll or ws2_64.dll are the dll libraries that contain the socket function
definitions. They have to be linked with the executable for the windows socket programs to work
properly.
69. Can a win32 application use the Cstring datatype with the default setting?
The CString is a datatype defined in the afxwin.h that can be included only in the MFC library based
applciations. So if you need to include the CString datatype you have to change the project settings to
include shared MFC libraries.
70. What is the difference between COM components and DLL components?
With DLL, there exists dynamic links to the library from all applications and when the DLL changes all
the other applications dependent on it have to recompiled to work properly. But in the case of the COM
objects they have their own management for representing each object and class definitions and thus they
have a better way of communicating to the dependent applications. Recompilation is not needed unless
the structure of the specific structure or class is expected to change.
71. What is CArchive class does?
This class helps to do the serialization and de-serialisation. storing of objects from and to disk storage.
The CArchive class allows user to save a complex objects to the permanent storage (usually disk storage)
binary format.
72. What problem does the namespace feature solve?
Multiple providers of libraries might use common global identifiers causing a name collision when an
application tries to link with two or more such libraries. The namespace feature surrounds
73. Explain about InitApplication()?
To display an output for a certain application programmers have to use InitApplication() method.
InitApplication is a Boolean method. This function outputs a true if an application gets succeeded. If it
did not succeed it displays a false command.... Read More
74. Can we declare a static function as virtual?
The virtual function mechanism is used on the specific object that determines which virtual function
to call. Since the static functions are not any way related to objects,
75. Explain about VC++?
To create windows and .NET based applications. This also helps in developing applications for
web, windows based applications, solutions for thin and smart client based mobile devices.
76. Describe about unordered_map
Unordered_map defines container template classes such as unordered map and unordered multimap
template. Under declarations unordered map Class and unordered multimap class are defined. These
classes store hash table.
77. What are all the situations where the /GS compiler is not applied.
These are the following situations where /GS compiler is not applied. 1) When functions do not
contain a buffer 2) When optimizations is not enabled 3) It is obvious when functions are defined to have
a variable argument list .
78. what is the use of AFX_MANAGE_STATE ?
MFC uses the resource handle of the main application to load the resource template. If you have
an exported function in a DLL, such as one that launches a dialog box in the DLL, this template is
actually stored in the DLL module.
79. HOW to Make ActiveX controls Safe for scripting/ Safe for Initialization
When - IE security Level set to Medium/High Solution: 1) Implement IObjectSafety interface in
the control . 2: Add the following entries in the registry for components implemented categories
{7DD95801-9882-11CF-9FA9-00AA006C42C4} {7DD95802-9882.
80. Explain about regex_search function?
Regex_search function searches for a regular expression. A true function is returned only when
the search in its operand sequence succeeds. It also defines the various capture groups in the regular
expression.
81. How to make the Activex auto download on the browser via cab file ?
Step1: Cretae a Cab file using cabarc cabarc N XYZ.cab *. dll Step2: Define in the HTML as <
OBJECT ID="myMenus" CLASSID="CLSID:0000000-0000-0000-0000-123456789abc"
codebase="http://varaghur.com/dload/YZ.cab #Version=-1,-1,-1,-1" HEIGHT...
82. Explain about the function regex?
This defines a template to parse certain regular expressions. It also defines several classes and
functions to search text that is matching a regular expression object. There are many declarations, type
definitions, template functions, and operator.
83. Name some important features of VC++?
Some of the important features of VC++ are as follows 1) Smart pointers 2) New containers 3)
Expression parsing 4) Polymorphic function wrappers 5) Type traits and sophisticated random number
generators.
84. Discuss about the stack based buffer over run detection in VC++?
Stack based buffer over run protects the program from executing malicious code. Function
epilogue code checks the returned cookie for similarity if there is a mismatch it stops executing the code.
It also moves around the stack which makes the data.
85. State some new features which are incorporated into Microsoft visual C++ 2008?
Some of the new features which are introduced to VC++ are a large set of new MFC classes
which will certainly help in building modern user interfaces. TR1 is the major addition to the pack of
VC++. This also has new user interface, adjustable panes,.
86. Explain the program flow for a MFC based application ?
<br><br>Global Application Object Creation -<br>enters into WinMain()<br>retrives the Global
Application Object.<br>Call method of Global Application Object.<br>.
87. What Is CMutex ?
An object of class CMutex represents a ?mutex? ? a synchronization object that allows one thread
mutually exclusive access to a resource. Mutexes are useful when only one thread at a time can be.
88. What You Should Include in a Header File
A header file should begin and end with #include guards to guarantee that its not #included more
than once during the same compilation session.
89. How to Killi an Object Prematurely.
Sometimes, you need to force an object to destroy itself because its destructor performs an operation
needed immediately. For example, when you want to release a mutex or close a file: void func(Modem&
modem) { Mutex mtx(modem); // lock modem.,
Discuss Visual C++ Professional developments
90. Explain about frames?
Frame describes about the borders, dimensions and location of the window. Two types of MFC
applications are present which use a frame. Application using frames use a concept known as
Document/View architecture.
91. Explain about CFrameWnd?
MFC has an extensive set of classes present in its library out of which CFrameWnd is one of those. This
is a very important class and it is used frequently. User defined classes can be created by CFrameWnd. To
create a windows frame CFrameWnd.
92. Explain about CWinThread class?
It is imperative to create a thread which can be done using CWinThread. A public member
variable is used with CWinThread is m_pMainWnd. The main advantage which you can get when
using this thread, it.
93. Explain about functional?
Functional defines a huge number of templates which help construct function objects which defines
operator. Function pointer can be described by a function object. It stores information which can be
accessed during the functional call.
94. How to handle Varinat passed to COM components?
A pointer to another VARIANTARG is passed in pvarVal. This referenced VARIANTARG will
never have the VT_BYREF bit set in vt, so only one level of indirection can ever be present. This value
can be used to support languages that allow functions to.
95. What is the difference between struct and class?
There are few differences: All members of struct are public. Default inheritance for struct is
public, where as for class the default inheritance is private.
96. What is the disadvantage of a template function?
A template function cannot be distributed in the obj form. This is because, fuction with which
parameters the template function is going to be called is decided at the run time only. Therefore an obj
form of a template function cannot be made by.
97. Explain about type_traits?
Type_traits give information about type arguments and provide compile time constants. Syntax of
type_traits is #include This function is very useful as it helps during the compile time. Specific extensions
are provided which give useful information.
98. Explain about typedef?
A type predicate takes one or more arguments and it is a template. If a type predicate is true it
is publicly derived directly or indirectly from true type def. In case it is false it is publicly derived
from false type def.
99. Explain about utility?
Utility function has several general templates and can be used in Standard template
library. Some of them are tuple element Class which is used to wrap the type of pair element. Get
function is used to get an element from the pair object.
100. what is the use #include "stdafx.h"
'stdafx' is just the default name for the 'precompiled header directive'. The headers that
included in stdafx.h are compiled once, and the information is saved to disk

You might also like