+ All Categories

Record

Date post: 22-Nov-2014
Category:
Upload: sathyaperumal
View: 25 times
Download: 5 times
Share this document with a friend
Popular Tags:
37
SIMPLE WINDOW DISPLAY AIM To write a VC++ program to create a simple window and to display some text in it with lines. ALGORITHM STEP 1: Develop two functions-Winmain &Wndproc STEP 2: Define two structures, MSG-MESSAGE STRUCTURE WNDCLASS-WINDOWCLASS STRUCTURE STEP 3: Initialize ten fields of the window class which define the attributes of the window. STEP 4: Register the wndclass by calling the register class function which requires the pointer to wndclass as parameter. STEP 5: Create the window using create window function & return a handle to the window. STEP 6: Display the window using ShowWindow-initial mode of the window display UpdateWindow-to paint the client area STEP 7: Obtain the messages from the messagequeue using GetMessage function STEP 8: Perform message translations by TranslateMessage function.
Transcript
Page 1: Record

SIMPLE WINDOW DISPLAY

AIM

To write a VC++ program to create a simple window and to display some text in it with lines.

ALGORITHM

STEP 1: Develop two functions-Winmain &Wndproc

STEP 2: Define two structures,

MSG-MESSAGE STRUCTURE

WNDCLASS-WINDOWCLASS STRUCTURE

STEP 3: Initialize ten fields of the window class which define the attributes of the window.

STEP 4: Register the wndclass by calling the register class function which requires the pointer to

wndclass as parameter.

STEP 5: Create the window using create window function & return a handle to the window.

STEP 6: Display the window using

ShowWindow-initial mode of the window display

UpdateWindow-to paint the client area

STEP 7: Obtain the messages from the messagequeue using GetMessage function

STEP 8: Perform message translations by TranslateMessage function.

STEP 9: Dispatch the message to the WNDPROC using DispatchMessage function.

STEP 10: Define two structures,

PAINTSTRUCT-Paint structure

RECT-Rectangle structure

STEP 11: Using switch-case handle the messages like

WM_PAINT-To create and paint the client area with the given text

WM_DESTROY-To close the application window

STEP 12: Use DefWindowProc to perform default processing of the messages.

Page 2: Record

PROGRAM:

#include <windows.h>

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR

szCmdLine,int iCmdShow)

{

Static TCHAR szAppName[]=TEXT(“I LOVE INDIA”);

HWND hwnd;

MSG msg;

WNDCLASS wc;

wc.style=CS_HREDRAW|CS_VREDRAW;

wc.IpfnWndProc=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)GetStockObject(WHITE_BRUSH);

wc.IpszMenuName=NULL;

wc.IpszClassName=szAppName;

if(!RegisterClass(&wc))

{

MessageBox(NULL,TEXT(“THIS IS RAM”), szAppName,MB_ICONERROR);

return 0;

}

Hwnd=CreateWindow(szAppName,TEXT(“HAI

BROTHER”),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,

CW_USEDEFAULT, CW_USEDEFAULT,NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,iCmdShow);

UpdateWindow(hwnd);

Page 3: Record

While(GetMessage(&msg,NULL,0,0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

return msg.wParam;

}

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam,

LPARAM IParam)

{

HDC hdc;

PAINTSTRUCT ps;

RECT rect;

switch(message)

{

Case WM_CREATE: return 0;

Case WM_PAINT:

hdc=BeginPaint(hwnd,&ps);

GetClientRect(hwnd,&rect);

DrawText(hdc,TEXT(“I LOVE MY PARENTS”),-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,IParam);

}

Page 4: Record

RESULT

Thus the VC++ program is written to create a simple window and to display some text with lines.

Page 5: Record

BASIC DRAWING

AIM

To write a VC++ program to create basic geometric shapes.

ALGORITHM

STEP 1: Develop two functions-Winmain &Wndproc

STEP 2: Define two structures,

MSG-MESSAGE STRUCTURE

WNDCLASS-WINDOWCLASS STRUCTURE

STEP 3: Initialize ten fields of the windowclass which define the attributes of the window.

STEP 4: Register the wndclass by calling the Registerclass function which requires the pointer to

Wndclass as parameter.

STEP 5: Create the window using Createwindow function & return a handle to the window.

STEP 6: Display the window using

ShowWindow-initial mode of the window display

UpdateWindow-to paint the client area

STEP 7: Obtain the messages from the messagequeue using GetMessage function

STEP 8: Perform message translations by TranslateMessage function.

STEP 9: Dispatch the message to the WNDPROC using DispatchMessage function.

STEP 10: Use the necessary co-ordinates to get the prescribed geometric shapes

STEP 11: Use WM_DESTROY to close the application window.

PROGRAM:

#include <windows.h>

LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR

szCmdLine,int iCmdShow)

{

Static TCHAR szAppName[]=TEXT(“I LOVE INDIA”);

Page 6: Record

HWND hwnd;

MSG msg;

WNDCLASS wc;

wc.style=CS_HREDRAW|CS_VREDRAW;

wc.IpfnWndProc=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)GetStockObject(WHITE_BRUSH);

wc.IpszMenuName=NULL;

wc.IpszClassName=szAppName;

if(!RegisterClass(&wc))

{

MessageBox(NULL,TEXT(“THIS IS RAM”), szAppName,MB_ICONERROR);

return 0;

}

Hwnd=CreateWindow(szAppName,TEXT(“HAI

BROTHER”),WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,

CW_USEDEFAULT, CW_USEDEFAULT,NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,iCmdShow);

UpdateWindow(hwnd);

While(GetMessage(&msg,NULL,0,0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

return msg.wParam;

}

Page 7: Record

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam,

LPARAM IParam)

{

HDC hdc;

PAINTSTRUCT ps;

RECT rect;

switch(message)

{

Case WM_CREATE: return 0;

Case WM_PAINT:

hdc=BeginPaint(hwnd,&ps);

GetClientRect(hwnd,&rect);

DrawText(hdc, TEXT(“I LOVE MY PARENTS”),-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,IParam);

}

RESULT

Thus the VC++ program is written to display the basic geometric shapes.

Page 8: Record

SCROLL BAR

AIM

To write a VC++ program to display a scroll bar in the client area.

ALGORITHM

STEP 1: Develop two functions-Winmain &Wndproc

STEP 2: Define two structures,

MSG-MESSAGE STRUCTURE

WNDCLASS-WINDOWCLASS STRUCTURE

STEP 3: Initialize ten fields of the window class which define the attributes of the window.

STEP 4: Register the wndclass by calling the register class function which requires the pointer to

wndclass as parameter.

STEP 5: Create the window using create window function & return a handle to the window.

STEP 6: Display the window using

ShowWindow-initial mode of the window display

UpdateWindow-to paint the client area

STEP 7: Obtain the messages from the messagequeue using GetMessage function

STEP 8: Perform message translations by TranslateMessage function.

STEP 9: Dispatch the message to the WNDPROC using DispatchMessage function.

STEP 10: Use the Scroll bar functions like SB_LINEUP,

SB_LINEDOWN,SB_PAGEUP,SB_PAGEDOWN etc. to scroll the vertical bars displayed in

the output window.

STEP 11: Use the functions SetScrollRange and SetscrollPos

STEP 12: Build and Execute.

PROGRAM

#include<stdafx.h>

#define STRUCT

#include<windows.h>

#define NUMLINES ((int)sizeof Message / sizeof Message[0])

Page 9: Record

struct

{

int index;

}Message[]={1,2,3,4,5};

HINSTANCE hinst,hprev;

HWND hwnd;

char appname[]="hello.cpp";

int WINAPI WinMain(HINSTANCE hinst,HINSTANCE hprev,LPSTR cmdline,int cmdshow);

long WINAPI windowproc(HWND hwnd,UINT m,WPARAM w,LPARAM l);

int WINAPI WinMain(HINSTANCE hint,HINSTANCE hprev,LPSTR lpszcmdline,int

icmdshow)

{

MSG msg;

WNDCLASS wc;

char cname[] = "my own win";

wc.style=CS_HREDRAW | CS_VREDRAW;

wc.lpfnWndProc=windowproc;

wc.cbClsExtra=0;

wc.cbWndExtra=0;

wc.hInstance=hint;

wc.hIcon=LoadIcon(0,IDI_APPLICATION);

wc.hCursor=LoadCursor(0,IDC_ARROW);

wc.hbrBackground=static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH));

wc.lpszMenuName=NULL;

wc.lpszClassName=cname;

RegisterClass(&wc);

hwnd=CreateWindow(cname,"mywindow",WS_OVERLAPPEDWINDOW|

WS_VSCROLL,CW_USEDEFAULT,

CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,NULL,NULL,hint,NULL);

Page 10: Record

ShowWindow(hwnd,icmdshow);

UpdateWindow(hwnd);

while(GetMessage(&msg,NULL,0,0)==TRUE)

{

TranslateMessage(&msg);

DispatchMessage(&msg);

}

return msg.wParam;

}

long WINAPI windowproc(HWND hwnd,UINT m,WPARAM w,LPARAM l)

{

HDC hdc;

static int cxchar, cxcaps, cychar, cyclient,ivspos;

RECT rect;

TEXTMETRIC tm;

PAINTSTRUCT ps;

char buff[100];

int i, y;

switch(m)

{

case WM_CREATE:

hdc = GetDC(hwnd);

GetTextMetrics(hdc,&tm);

cychar = tm.tmHeight + tm.tmExternalLeading;

ReleaseDC(hwnd,hdc);

SetScrollRange(hwnd,SB_VERT,0,NUMLINES-1,FALSE);

SetScrollPos(hwnd,SB_VERT,ivspos,TRUE);

return 0;

case WM_SIZE:

Page 11: Record

cyclient = HIWORD(l);

return 0;

case WM_VSCROLL:

switch(LOWORD(w))

{

case SB_LINEUP:

ivspos -=1;

break;

case SB_LINEDOWN:

ivspos +=1;

break;

case SB_PAGEUP:

ivspos -= cyclient/cychar;

break;

case SB_PAGEDOWN:

ivspos += cyclient/cychar;

break;

case SB_THUMBTRACK:

ivspos = HIWORD(w);

break;

case SB_THUMBPOSITION:

ivspos = HIWORD(w);

break;

default:

Page 12: Record

break;

}

ivspos = max(0,min(ivspos,NUMLINES-1));

if(ivspos != GetScrollPos(hwnd, SB_VERT))

{

SetScrollPos(hwnd,SB_VERT,ivspos,TRUE);

InvalidateRect(hwnd,NULL,TRUE);

}

return 0;

case WM_PAINT:

hdc=BeginPaint(hwnd,&ps);

for ( i=0; i < NUMLINES; i++)

{

y = cychar*(i-ivspos);

wsprintf(buff,"%d",Message[i].index);

TextOut(hdc,0,y,buff,strlen(buff));

}

EndPaint(hwnd,&ps);

break;

case WM_DESTROY:

MessageBox(hwnd,"win. des,.","des",MB_OK);

PostQuitMessage(0);

return 0;

}

return DefWindowProc(hwnd,m,w,l);

}

RESULT

Thus a VC++ program is written to display a scroll bar in the client area.

Page 13: Record

CHILD WINDOW CONTROLS

AIM

Page 14: Record

MODAL DIALOG BOX

AIM

To write a program in VC++ to display a modal dialog box in the view window.

ALGORITHM

STEP 1: Choose File New MFC AppWizard(exe) and type name of the project as

ModalDialog

STEP 2: Select Single Document and press next

STEP 3: Then accept all the default settings of MFC AppWizard and press finish

STEP 4: Select InsertResourceDialog, a new dialog box will appear with default ID as

IDD_DIALOG1 and default OK and CANCEL buttons.

STEP 5: Delete the cancel button and change the caption of OK button as CLICK ME

STEP 6: Select class wizard from the view menu so that a new dialog box appears, to create a

new dialog- press OK

STEP 7: Type the name for new dialog box as CMessageDlg

STEP 8: Add the message handler for OK button and also add the message handler for

WM_LBUTTONDOWN for the view class

STEP 9: Edit the OnOk function in MessageDlg.cpp and OnLButtonDown in

ModalDialogView.cpp to create the dialog box using DoModal() function.

STEP 10: Include the header file #include “MessageDlg.h” in the ModalDialogView.cpp file

STEP 11: Then build the program and execute it.

STEP 12: The output appears in which the user cannot work elsewhere unless closing the dialog

box

PROGRAM

MessageDlg.cpp

void CMessageDlg::OnOk()

{

Page 15: Record

MessageBox(“HELLO”, “WELCOME”,3);

CDialog::OnOk();

}

ModalDialogView.cpp

void CModalDialogView :: OnLButtonDown(UINT nFlags, CPoint point)

{

CMessageDlg dlg;

Dlg.DoModal();

CView::OnLButtonDown(nFlags, point);

}

//Include the header file #include “MessageDlg.h” in ModalDialogView.cpp

RESULT

Thus the VC++ program is written to display the modal dialog box.

Page 16: Record

BITMAP DISPLAY

AIM

To create a VC++ program for displaying the specified bitmap pattern brush on the output window.

ALGORITHM

STEP 1: Choose File New MFC AppWizard(exe) and type name of the project as

Bitmapbrush.

STEP 2: Select Single Document and press next

STEP 3: Then accept all the default settings of MFC AppWizard and press finish

STEP 4: Select InsertResourceBitmap, and load a bitmap image.

STEP 5: Then edit the OnDraw function in BitmapbrushView.cpp file.

STEP 6: Then build and execute the program.

STEP 7: The output appears in which the created bitmap is displayed in a specified shape.

PROGRAM

BitmapbrushView.cpp

Void CBitmapbrushView::OnDraw(CDC* pDC)

{

CBitmapbrushDoc* pDoc = GetDocument();

ASSERT_VALID(pDoc);

CBrush brPattern;

CBitmap Bmp;

CBrush *pBrush;

Bmp.LoadBitmap(IDB_BITMAP1);

brPattern.CreatePatternBrush(&Bmp);

pBrush= pDC->SelectObject(&brPattern);

pDC->Rectangle(50,50,300,300);

pDC->SelectObject(pBrush);

}

Page 17: Record

RESULT

Thus the VC++ program is created to display the specified bitmap brush.

Page 18: Record

SINGLE DOCUMENT INTERFACE AND

MULTIPLE DOCUMENT INTERFACE

AIM

To develop a VC++ program to draw inside the view window in Single Document

Interface (SDI) and in Multiple Document Interface (MDI).

ALGORITHM

STEP 1: Choose File New MFC AppWizard(exe) and type name of the project as Single.

STEP 2: Select Single Document and press next

STEP 3: Then accept all the default settings of MFC AppWizard and press finish

STEP 4: Add the member variables in SingleView.h

STEP 5: Edit the OnDraw function in SingleView.cpp

STEP 6: Also add the code for specified geometric shape in LBUTTONDOWN and

RBUTTONDOWN function.

STEP 7: In case of MDI, instead of Single Document, select Multiple Document in the second

step and follow the same procedures.

STEP 7: Build and execute the file

STEP 8: For SDI, the output appears in which the displayed geometric shapes can be resized in

the view window.

STEP 9: For MDI, the output appears in which the displayed geometric shapes can be resized in

the separate window created inside the view window.

PROGRAM

SingleView.h

Public:

int x;

int y;

SingleView.cpp

CSinglView::CSingleView()

Page 19: Record

{

x=50;

y=50;

// TODO: add construction code here

}

void CSingleView::OnDraw(CDC* pDC)

{

CSinglDoc* pDoc = GetDocument();

ASSERT_VALID(pDoc);

pDC->Ellipse(50,50,x,y);

}

void CSingleView::OnLButtonDown(UINT nFlags, CPoint point)

{

CView::OnLButtonDown(nFlags, point);

x += 50;

y += 50;

CClientDC dc(this);

dc.Ellipse(50,50,x,y);

InvalidateRect(FALSE);

}

void CSingleView::OnRButtonDown(UINT nFlags, CPoint point)

{

CView::OnRButtonDown(nFlags, point);

x -= 50;

y -= 50;

CClientDC dc(this);

dc.Ellipse(50,50,x,y);

InvalidateRect(FALSE);

}

Page 20: Record

RESULT

Thus a VC++ program was developed to draw inside the view window in Single

Document Interface (SDI) and in Multiple Document Interface (MDI).

Page 21: Record

SPLITTER WINDOWS

AIM

To write a program in VC++ to dynamically split the view into four panes with four

separate view objects.

ALGORITHM

STEP 1: Choose File New MFC AppWizard (exe) and type name of the project as Splitter.

STEP 2: Select Single Document and press next

STEP 3: Click the Advanced button in the AppWizard Step4 dialog

STEP 4: Click on the window styles tab, and select Use Split Window

STEP 5: Once the split window check box is clicked, AppWizard adds code to CMainFrame

class of an existing application to add splitter capability.

STEP 6: When AppWizard generates an application with a splitter frame, it includes a Split

option in the project’s View menu and the command ID is ID_WINDOW_SPLIT

STEP 7: The application’s main frame window class has splitter window data member and a

prototype for an overridden OnCreateClient function in MainFrm.h

STEP 8: The application framework calls the CFrameWnd::OnCreateClient virtual member

function when the frame object is created.

STEP 9: Edit the OnDraw function in SplitterView.cpp

STEP 10: Build and Execute.

PROGRAM

MainFrm.h

Protected:

CSplitterWnd m_wndSplitter;

Public:

Virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs,CCreateContext* pContext);

Page 22: Record

MainFrm.cpp

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,CCreateContext*

pContext);

{

return m_wndSplitter.Create(this,2,2, CSize(10,10), pContext);

}

SplitterView.cpp

Void CSplitterView::OnDraw(CDC* pDC)

{

pDC-> TextOut(100,100,”Splitter Window”);

}

RESULT

Thus the program in VC++ is written to dynamically split the view into four panes with

four separate view objects.

Page 23: Record

TOOLBAR

AIM

To write a program in VC++ to display a toolbar with two special-purpose buttons that

draws square along with the pattern on the view window.

ALGORITHM

STEP 1: Choose File New MFC AppWizard(exe) and type name of the project as ToolBar.

STEP 2: Select Single Document and press next

STEP 3: Then accept all the default settings of MFC AppWizard and press finish.

STEP 4: Use the resource editor to edit the application’s main menu.

STEP 5: In Resource View, double-click on IDR_MAINFRAME under menu and Edit the

IDR_MAINFRAME menu resource to create a menu

STEP 6: Add a menu as Draw, using the menu item properties by specifying &Draw in the

caption box.

STEP 7: Add the menu items as square and pattern in the Draw menu, by specifying its ID as

ID_DRAW_SQUARE (caption: &Square) and ID_DRAW_PATTERN (caption: &Pattern)

STEP 8: Use the resource editor to update the application’s toolbar.

STEP 9: Edit the IDR_MAINFRAME toolbar resource to create a bitmap.

STEP 10: Assign the ID’s as ID_DRAW_SQUARE and ID_DRAW_PATTERN to the two new

buttons.

STEP 11: Use Class Wizard to add CToolBarView view class message handlers for the

COMMAND and UPDATE_COMMAND_UI messages.

STEP 12: Add the necessary data members in ToolBarView.h and edit the functions in

ToolBarView.cpp

PROGRAM

ToolBarView.h

Private:

CRect m_rect;

BOOL m_bSquare;

BOOL m_bPattern;

Page 24: Record

ToolBarView.cpp

CToolBarView::CToolBarView():m_rect(0,0,100,100)

{

m_bSquare = TRUE;

m_bPattern = FALSE;

}

Void CToolBarView::OnDraw(CDC* pDC)

{

CBrush brush(HS_BDIAGONAL,0L);

if(m_bPattern){

pDC->SelectObject(&brush);

}

else

{

pDC->SelectStockObject(WHITE_BRUSH);

}

if (m_bSquare) {

pDC->Rectangle(m_rect);

}

pDC->SelectStockObject(WHITE_BRUSH);

}

void CToolBar::OnDrawSquare()

{

m_rect += CPoint(25, 25);

InvalidateRect(m_rect);

}

Page 25: Record

Void CToolBar::OnDrawPattern()

{

m_bPattern ^=1;

}

Void CToolBarView :: OnUpdateDrawSquare(CCmdUI* pCMDUI)

{

pCmdUI->Enable(m_bSquare);

}

Void CToolBar::OnUpdateDrawPattern(CCmdUI *pCmdUI)

{

pCmdUI->SetCheck(m_bPattern);

}

RESULT

Thus a program in VC++ is written to display a toolbar with two special-purpose buttons

that draws square along with the pattern on the view window.

Page 26: Record

STATUS BARS

AIM

To write a program in VC++ to display the status bar in the view window.

ALGORITHM

STEP 1: Choose File New MFC AppWizard(exe) and type name of the project as

StatusBar.

STEP 2: Select Single Document and press next

STEP 3: Then accept all the default settings of MFC AppWizard and press finish

STEP 4: Use the string editor to update the string table resource by selecting the string table on

the resource view.

STEP 5: Double-Click on the empty entry at the end of the list in the string table and add the ID

as ID_INDICATOR_RIGHT (Caption: RIGHT) and ID_INDICATOR_LEFT (Caption: LEFT)

STEP 6: Choose Resource Symbols from the View menu and add the new status bar with ID as

ID_MYOWN_STATUSBAR and accept the default value and press ok

STEP 7: Use Class Wizard to add View menu command handlers in the class CMainFrame

STEP 8: Add the function prototypes to MainFrm.h

STEP 9: Modify the original indicators array in the MainFrm.cpp

STEP 10: Add the message map entries in the CMainFrame class

STEP 11: Define the necessary functions in the MainFrame.cpp file

STEP 12: Edit the OnDraw function in StatusBar.cpp file

STEP 13: Include the following header file at the top of the StatusBarView.cpp file as # include

“MainFrm.h”

STEP 14: Build and execute

PROGRAM

MainFrm.h

afx_msg void OnUpdateLeft(CCmdUI* pCmdUI);

afx_msg void OnUpdateRight(CCmdUI* pCmdUI);

Page 27: Record

MainFrm.cpp

static UINT indicators[] = {

ID_SEPERATOR,

ID_SEPERATOR,

ID_INDICATOR_LEFT,

ID_INDICATOR_RIGHT,

};

// Add the following code on OnCreate member function in MainFrm.cpp along with the existing

code.

if(!m_wndStatusBar.Create(this,WS_CHILD| WS_VISIBLE|

CBRS_BOTTOM,ID_MYOWN_STATUSBAR) \\!

m_wndStatusBar.SetIndicators(indicators,sizeof (indicators)/sizeof(UINT)))

{

TRACE0(“Failed to create statusbar\n”);

Return -1;

}

CMainFrame Class

ON_UPDATE_COMMAND_UI(ID_INDICATOR_LEFT, OnUpdateLeft)

ON_UPDATE_COMMAND_UI(ID_INDICATOR_LEFT, OnUpdateRight)

MainFrame.cpp

Void CMainFrame::OnUpdateLeft(CCmdUI* pCmdUI)

{

pCmdUI->Enable(::GetKeyState(VK_LBUTTON)<0);

}

Page 28: Record

Void CMainFrame::OnUpdateRight(CCmdUI* pCmdUI)

{

pCmdUI->Enable(::GetKeyState(VK_RBUTTON)<0);

}

Void CMainFrame::OnViewStatusBar()

{

m_wndStatusBar.ShowWindow((m_wndStatusBar.GetStyle() & WS_VISIBLE)==0);

RecalcLayout();

}

Void CMainFrame::OnUpdateViewStatusBar(CCmdUI* pCmdUI)

{

pCmdUI->SetCheck((m_wndStatusBar.GetStyle() & WS_VISIBLE)!=0);

}

StatusBarView.cpp

Void CStatusBarView:: OnDraw(CDC* pDC)

{

pDC->TextOut(0,0,”watch the status bar”);

}

//include the header file #include “MainFrm.h”

RESULT

Thus a program in VC++ is written to display the status bar in the view window.

Page 29: Record

ACTIVEX CONTROL

AIM

To write a VC++ program for using Active X Control to display a calendar and to access various methods with respect to calendar control.

ALGORITHM


Recommended