Click here to Skip to main content
15,887,175 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionVC++ Graphs. Pin
Vijay Rajanna23-Sep-11 7:08
Vijay Rajanna23-Sep-11 7:08 
AnswerRe: VC++ Graphs. Pin
Rajesh R Subramanian23-Sep-11 7:20
professionalRajesh R Subramanian23-Sep-11 7:20 
AnswerRe: VC++ Graphs. Pin
Albert Holguin23-Sep-11 8:36
professionalAlbert Holguin23-Sep-11 8:36 
AnswerRe: VC++ Graphs. Pin
Vijay Rajanna23-Sep-11 9:01
Vijay Rajanna23-Sep-11 9:01 
GeneralRe: VC++ Graphs. Pin
Software_Developer23-Sep-11 9:37
Software_Developer23-Sep-11 9:37 
AnswerRe: VC++ Graphs. Pin
Cedric Moonen25-Sep-11 20:31
Cedric Moonen25-Sep-11 20:31 
QuestionCan I use a SetTimer() API in a console c++ app. Pin
JosephJohnAllen23-Sep-11 5:57
JosephJohnAllen23-Sep-11 5:57 
AnswerRe: Console SetTimer Pin
Software_Developer23-Sep-11 6:14
Software_Developer23-Sep-11 6:14 
The following console program works. It sets a timer using SetTimer
then loops in a message loop. The message loop receives and processes WM_TIMER messages
and the timer callback also is called for each time interval.


C++
#define STRICT 1 
#include <windows.h>
#include <iostream.h>

VOID CALLBACK TimerProc(HWND hWnd, UINT nMsg, UINT nIDEvent, DWORD dwTime) 
{
  cout << "Time: " << dwTime << '\n';
  cout.flush();
}

int main(int argc, char *argv[], char *envp[]) 
{
	int Counter=0;
	MSG Msg;

    UINT TimerId = SetTimer(NULL, 0, 500, &TimerProc); //SetTimer

    cout << "TimerId: " << TimerId << '\n';
   if (!TimerId)
	return 16;
    
   while (GetMessage(&Msg, NULL, 0, 0)) 
   {
    	++Counter;
    	if (Msg.message == WM_TIMER)
		cout << "Counter: " << Counter << "; timer message\n";
    	else
		cout << "Counter: " << Counter << "; message: " << Msg.message << '\n';
    	DispatchMessage(&Msg);
	}
    
   KillTimer(NULL, TimerId);
return 0;
}

GeneralRe: Console SetTimer Pin
Albert Holguin23-Sep-11 8:39
professionalAlbert Holguin23-Sep-11 8:39 
GeneralRe: Console SetTimer Pin
Software_Developer23-Sep-11 21:43
Software_Developer23-Sep-11 21:43 
AnswerRe: Can I use a SetTimer() API in a console c++ app. Pin
André Kraak23-Sep-11 8:46
André Kraak23-Sep-11 8:46 
QuestionRe: Can I use a SetTimer() API in a console c++ app. Pin
Randor 23-Sep-11 15:19
professional Randor 23-Sep-11 15:19 
AnswerRe: Can I use a SetTimer() API in a console c++ app. Pin
Jörgen Sigvardsson24-Sep-11 6:39
Jörgen Sigvardsson24-Sep-11 6:39 
GeneralRe: Can I use a SetTimer() API in a console c++ app. Pin
Randor 24-Sep-11 12:41
professional Randor 24-Sep-11 12:41 
GeneralRe: Can I use a SetTimer() API in a console c++ app. Pin
Jörgen Sigvardsson24-Sep-11 13:00
Jörgen Sigvardsson24-Sep-11 13:00 
QuestionPostThreadMessage does not work sometimes Pin
rahul.kulshreshtha23-Sep-11 1:26
rahul.kulshreshtha23-Sep-11 1:26 
AnswerRe: PostThreadMessage does not work sometimes Pin
Rajesh R Subramanian23-Sep-11 4:05
professionalRajesh R Subramanian23-Sep-11 4:05 
GeneralRe: PostThreadMessage does not work sometimes Pin
Albert Holguin23-Sep-11 5:15
professionalAlbert Holguin23-Sep-11 5:15 
GeneralRe: PostThreadMessage does not work sometimes Pin
Rajesh R Subramanian23-Sep-11 5:23
professionalRajesh R Subramanian23-Sep-11 5:23 
GeneralRe: PostThreadMessage does not work sometimes Pin
Albert Holguin23-Sep-11 5:27
professionalAlbert Holguin23-Sep-11 5:27 
GeneralRe: PostThreadMessage does not work sometimes Pin
Rajesh R Subramanian23-Sep-11 5:46
professionalRajesh R Subramanian23-Sep-11 5:46 
GeneralRe: PostThreadMessage does not work sometimes Pin
Albert Holguin23-Sep-11 6:04
professionalAlbert Holguin23-Sep-11 6:04 
GeneralRe: PostThreadMessage does not work sometimes Pin
Rajesh R Subramanian23-Sep-11 6:07
professionalRajesh R Subramanian23-Sep-11 6:07 
GeneralRe: PostThreadMessage does not work sometimes Pin
Albert Holguin23-Sep-11 6:11
professionalAlbert Holguin23-Sep-11 6:11 
GeneralRe: PostThreadMessage does not work sometimes Pin
Rajesh R Subramanian23-Sep-11 6:14
professionalRajesh R Subramanian23-Sep-11 6:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.