Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SetTimer 1

Status
Not open for further replies.

gford2

Technical User
Oct 11, 2000
7
0
0
US
I am having trouble using SetTimer. If someone could give me an example on how to use it that would be great. I am also having big problems with OnTimer. Thanks
 
// In your dialog class header file
class MainDlg : public CDialog
{
/// bunch of other code snipped for brevity

protected:
UINT _idtimer;
// Generated message map functions
//{{AFX_MSG(MainDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnDestroy();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

// In your dialog class source file
BEGIN_MESSAGE_MAP(MainDlg, CDialog)
//{{AFX_MSG_MAP(MainDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_TIMER()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BOOL MainDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// bunch of stuff snipped for brevity
_idtimer = SetTimer(1, 500, NULL);

return TRUE; // return TRUE unless you set the focus to a control
}

void MainDlg::OnTimer(UINT nIDEvent)
{
TRACE("OnTimer %d\r\n", nIDEvent);
CDialog::OnTimer(nIDEvent);
}

void MainDlg::OnDestroy()
{
CDialog::OnDestroy();
KillTimer( _idtimer);
}

Hope this helps
-pete
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top