Click here to Skip to main content
14,269,309 members

C / C++ / MFC

 
AnswerRe: academic question - usage of class variable Pin
Stefan_Lang16-Jan-19 22:26
memberStefan_Lang16-Jan-19 22:26 
QuestionChanging CMainFrame Minimize ICON Pin
ForNow9-Jan-19 14:02
memberForNow9-Jan-19 14:02 
QuestionRe: Changing CMainFrame Minimize ICON Pin
David Crow10-Jan-19 4:07
memberDavid Crow10-Jan-19 4:07 
AnswerRe: Changing CMainFrame Minimize ICON Pin
ForNow10-Jan-19 4:39
memberForNow10-Jan-19 4:39 
GeneralRe: Changing CMainFrame Minimize ICON Pin
David Crow10-Jan-19 4:42
memberDavid Crow10-Jan-19 4:42 
GeneralRe: Changing CMainFrame Minimize ICON Pin
ForNow10-Jan-19 5:09
memberForNow10-Jan-19 5:09 
QuestionUsage of bitset ? Pin
Vaclav_9-Jan-19 5:12
memberVaclav_9-Jan-19 5:12 
AnswerRe: Usage of bitset ? Pin
Daniel Pfeffer9-Jan-19 5:46
professionalDaniel Pfeffer9-Jan-19 5:46 
AnswerRe: Usage of bitset ? Pin
k50549-Jan-19 6:09
memberk50549-Jan-19 6:09 
GeneralRe: Usage of bitset ? Pin
Daniel Pfeffer9-Jan-19 21:38
professionalDaniel Pfeffer9-Jan-19 21:38 
GeneralRe: Usage of bitset ? Pin
Vaclav_10-Jan-19 4:39
memberVaclav_10-Jan-19 4:39 
QuestionVC++ 2017 redistributables versions. Pin
Maximilien8-Jan-19 4:21
memberMaximilien8-Jan-19 4:21 
AnswerRe: VC++ 2017 redistributables versions. Pin
Victor Nijegorodov8-Jan-19 8:43
memberVictor Nijegorodov8-Jan-19 8:43 
GeneralRe: VC++ 2017 redistributables versions. Pin
Maximilien8-Jan-19 9:01
memberMaximilien8-Jan-19 9:01 
GeneralRe: VC++ 2017 redistributables versions. Pin
Victor Nijegorodov8-Jan-19 9:03
memberVictor Nijegorodov8-Jan-19 9:03 
QuestionSubclassing a listcontrol in dialog bar Pin
manoharbalu6-Jan-19 23:48
membermanoharbalu6-Jan-19 23:48 
AnswerRe: Subclassing a listcontrol in dialog bar Pin
Victor Nijegorodov7-Jan-19 2:12
memberVictor Nijegorodov7-Jan-19 2:12 
Questionupdating output value with timer and resetting if the timer exceeds a certain time or it has a new input value Pin
crucial19536-Jan-19 14:42
membercrucial19536-Jan-19 14:42 
SuggestionRe: updating output value with timer and resetting if the timer exceeds a certain time or it has a new input value Pin
David Crow6-Jan-19 14:59
memberDavid Crow6-Jan-19 14:59 
AnswerRe: updating output value with timer and resetting if the timer exceeds a certain time or it has a new input value Pin
leon de boer6-Jan-19 16:17
memberleon de boer6-Jan-19 16:17 
To do it by polling which you sort of imply with your pseudocode (It is better with interrupts if possible to trigger the 1 event).

You define an ID for the timer and a timer sample count
#define	IDT_TIMER_0 WM_USER + 100

UINT sampleCount = 0;

You set the timer interval
SetTimer(IDT_TIMER_0, 10, NULL);//10ms poll x 30 samples  = 300ms

You do the checks in on_timer call back function and reset the sample count if you find what you wanted
void OnTimer (UINT TimerVal)
{
    sampleCount++;
    if (sample_whatever == 1)
    {
         // output your 1
         sampleCount = 0;
    } else if (sampleCount == 30) 
    {
        // output your 0
        sampleCount = 0;     
    }
}

You can use KillTimer with the id to kill the timer at any time you like
KillTimer(IDT_TIMER_0);

There are more advanced techniques like using WaitForSingleObject but we need to know more about what the 1 is coming from.
In vino veritas


modified 6-Jan-19 22:33pm.

QuestionSeperate source code for the tokens in the compiler c++ Pin
Member 141086114-Jan-19 20:10
memberMember 141086114-Jan-19 20:10 
AnswerRe: Seperate source code for the tokens in the compiler c++ Pin
Richard MacCutchan4-Jan-19 22:08
protectorRichard MacCutchan4-Jan-19 22:08 
AnswerRe: Seperate source code for the tokens in the compiler c++ Pin
jschell5-Jan-19 5:59
memberjschell5-Jan-19 5:59 
QuestionPostmessage Not Working With WH_GETMESSAGE-MFC Pin
srinivasankrishnaa1-Jan-19 20:11
membersrinivasankrishnaa1-Jan-19 20:11 
AnswerRe: Postmessage Not Working With WH_GETMESSAGE-MFC Pin
Richard MacCutchan1-Jan-19 22:08
protectorRichard MacCutchan1-Jan-19 22:08 

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.