Home > Software engineering >  About MFC timer?
About MFC timer?

Time:10-06

 BOOL CJSQDlg: : OnInitDialog () 
{
CDialogEx::OnInitDialog();

//will "about... "Menu item added to the system menu,

//IDM_ABOUTBOX must be in the system command range,
ASSERT ((IDM_ABOUTBOX & amp; 0==IDM_ABOUTBOX xfff0));
ASSERT (IDM_ABOUTBOX & lt; 0 xf000);

CMenu * pSysMenu=GetSystemMenu (FALSE);
If (pSysMenu!=NULL)
{
BOOL bNameValid;
Cstrings strAboutMenu;
BNameValid=strAboutMenu. LoadString (IDS_ABOUTBOX);
ASSERT (bNameValid);
if (! StrAboutMenu. IsEmpty ())
{
PSysMenu - & gt; The AppendMenu (MF_SEPARATOR);
PSysMenu - & gt; AppendMenu (MF_STRING IDM_ABOUTBOX, strAboutMenu);
}
}

//set this dialog ICONS, when the application is the main window is not a dialog, the framework will automatically
//do this
SetIcon (m_hIcon, TRUE);//set the large icon
SetIcon (m_hIcon, FALSE);//set the small icon

//TODO: add additional initialization code in the
The SetTimer (TIMER2, 5000, 0);
The SetTimer (TIMER1, 3000, 0);

return TRUE;//unless set focus to the control, return TRUE
}


Void CAboutDlg: : OnTimer (UINT_PTR nIDEvent)
{
//TODO: add the message handler code and/or invoke the default

The switch (nIDEvent)
{
Case TIMER1:

Str1="123";
GetDlgItem (IDC_JSQ1) - & gt; SetWindowText (str1);
break;
Case TIMER2:
Str2="456";
GetDlgItem (IDC_JSQ2) - & gt; SetWindowText (str2);
break;

}

CDialogEx: : OnTimer (nIDEvent);
}
However the timer doesn't start put the SETTIMER in the following code, click on the button is still not start
Void CJSQDlg: : OnBnClickedButton1 ()
{
//TODO: add the control notification handler code
Cstrings str3;
The SetTimer (TIMER2, 5000, 0);
The SetTimer (TIMER1, 3000, 0);
Str3="asd";
GetDlgItem (IDC_JSQ1) - & gt; SetWindowText (str3);


}


Or have a timer code in the home, you can use the first IMER1, but TIMER2 anyway don't start, using breakpoint found CASE2 start the program to directly, ranging from time,
Who has the multiple timer timing case more detail for a thank you,

CodePudding user response:

CAboutDlg : : OnTimer
CJSQDlg : : OnBnClickedButton1

In two classes in a play?

CodePudding user response:

CodePudding user response:

Yes, in the two classes is certainly no problem, there is a program that first timers can be used, a bad case timer2, came up and went inside

CodePudding user response:

reference u010039362 reply: 3/f
yes, in the two classes is certainly no problem, there is a program that first timers can be used, a bad case timer2, came up and went inside the

haven't you see...
CAboutDlg : : OnTimer
CJSQDlg : : OnBnClickedButton1
You put the timer to another class in the... How could effect ~

CodePudding user response:

Should the response CJSQDlg OnTimer

CodePudding user response:

reference 4 floor mjdy123 response:
Quote: reference u010039362 reply: 3/f

Yes, in the two classes is certainly no problem, there is a program that first timers can be used, a bad case timer2, came up and went inside the

haven't you see...
CAboutDlg : : OnTimer
CJSQDlg : : OnBnClickedButton1
You put the timer to another class in the... How will effect ~


The building Lord, to pay attention to the red font

CodePudding user response:

I try, critical me another program T1, T2 why not directly go in the

CodePudding user response:

The response of CJSQDlg OnTimer

CodePudding user response:

Or understand
  • Related