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!

How to Install a Timer in an SDI application?

Status
Not open for further replies.

archaven

Programmer
Oct 10, 2002
2
0
0
US
How to Install a Timer in an SDI application?

Hallo guys. I used to install a timer in a Dialog-Based application
and have no problems implementing it. Usually the Timer is installed
during OnInitDialog. Below is how i usually write the code in a Dialog
based application.

int iInstallTimer = SetTimer(1,500,NULL);
if(!iInstallTimer)
{
MessageBox("Unable to install a timer!");
OnOK();
}

However, when I try to add these lines of code into an SDI application
in the Document class OnNewDocument, It has errors when compiling.
It stated that:

i. SetTimer function does not takes 3 parameters.
ii. MessageBoxA does not takes 1 parameters;
iii. Undeclared identifier OnOK;

Thanks in advance for any guidance.
 
The SetTimer() api call takes 4 parameters with some variations for nulls. Are sure your' hWnd is 1? Hmmm...

I think you may want to start there...

UINT_PTR SetTimer(
HWND hWnd, // handle to window
UINT_PTR nIDEvent, // timer identifier
UINT uElapse, // time-out value
TIMERPROC lpTimerFunc // timer procedure
);

The MessageBox() call is thus...

int MessageBox(
HWND hWnd, // handle to owner window
LPCTSTR lpText, // text in message box
LPCTSTR lpCaption, // message box title
UINT uType // message box style
);

Darrell 'We all must do the hard bits so when we get bit we know where to bite' :)
 

Hi,

CDocument has no timer because it is a storage class. It's no supposed to be doing anything but storing data and saving data. So it doesn't need a timer.

CMainFrame, CView, and CDialog already have timers. There's a reason for this. There're to ones doing the work. If you're adding a timer to your document class you should re-think your code. CMainFrame and CView all have access to your document class. Use thier timers to modify your document.

Brother C
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top