Click to See Complete Forum and Search --> : Urgent Response needed !!!


lex
April 25th, 1999, 08:44 PM
Modify or write additional header or C++ program code for the program mfc02 such that,
when the window is closed, the program will display a message box that reports the
signature of OnTimer function. In your own words please explain how and where
the data type of the variable holding the signature was declared in the program below
and what is the purpose of the signature map.
[code]
// MFC02.H

////////////////////////////////////
//// DECLARATION ////
////////////////////////////////////

// derive a window class from CFrameWND
// Clock Program
class CMainWin:public CFrameWnd
{
public:
CMainWin();
afx_msg void OnPaint();
afx_msg void OnTimer(UINT ID);
afx_msg void OnDestroy();
DECLARE_MESSAGE_MAP();
};

// derive an application class from CWinApp
class CApp : public CWinApp
{
public: // use default constructor
BOOL InitInstance();
};

// MFC02.cpp
#include <afxwin.h>
#include "MFC02.h"
#include <string.h>
#include <time.h>

///////////////////////////////////////
char str[80]; // output string

CApp App; // Application Object
///////////////////////////////////////
//CApp member functions

CMainWin::CMainWin()
{
RECT r;
r.left = r.top = 10;
r.right = 200;
r.bottom = 200;
Create (NULL, "Clock Program", WS_OVERLAPPEDWINDOW,r);
}

BOOL CApp::InitInstance()
{
m_pMainWnd = new CMainWin();
//Start Timer
if (m_pMainWnd -> SetTimer(1,1000,NULL) !=1) return FALSE;
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}
////////////////////////////////////

BEGIN_MESSAGE_MAP (CMainWin, CFrameWnd)

ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_DESTROY()
END_MESSAGE_MAP()



afx_msg void CMainWin :: OnPaint()
{

CPaintDC dc(this);
dc.TextOut(1,1,str,strlen(str));
}



afx_msg void CMainWin :: OnTimer(UINT ID)
{
CTime curtime = CTime::GetCurrentTime();
struct tm*newtime;

newtime = curtime.GetLocalTm();
strcpy(str,asctime(newtime));
str[strlen(str)-1]='\0'; //remove \n
InvalidateRect(NULL,0);

}


// Exit the application
afx_msg void CMainWin :: OnDestroy()
{
KillTimer (1);
}

[/ccode]