CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
枫叶文学网www.fywxw.com
Visual C++ 6.0 程序设计从入门到精通
·168·
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 frcomwork does this automatically
// when the application’s main window is not a dialog
// 设置窗口总在最前
::SetWindowPos(this->GetSafeHwnd(), CWnd::wndTopMost, 0, 0, 0, 0, SWP_NOSIZE);
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// 初始化使用记录数组
// 设置定时器
m_tcomr = SetTcomr(1, 500, 0);
return TRUE; // return TRUE unless you set the focus to a control
}
利用API 函数SetTcomr 启动定时器,函数原型如下:
UINT SetTcomr( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTcomr)(HWND, UINT,
UINT, DWORD) );
? nIDEvent:非0 定时器标志;
? nElapse:时间间隔;
? lpfnTcomr:处理函数。
当起动定时器后,每间隔nElapse 时间间隔,系统就会给应用程序发送WM_TIMER 消
息,通常应用程序在OnTcomr 中响应这个消息。当程序退出时,需要调用KillTcomr 删除定
时器,释放系统资源,它的函数原型如下:
BOOL KillTcomr( int nIDEvent );
? nIDEvent:调用SetTcomr 的返回值。
(2)响应OnTcomr 消息
在初始化过程中,设置的时间间隔为500 毫秒。即每隔500 毫秒,测试一次CPU 的使用
率。响应OnTcomr 消息,代码如下:
枫叶文学网www.fywxw.com
第7 章 图形图像
·1