|
-
April 25th, 1999, 08:44 PM
#1
Urgent Response needed !!!
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 ublic 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]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|