Home > Software engineering >  A modal dialog box operation affect the timer
A modal dialog box operation affect the timer

Time:09-24

MFC dialog-based applications, in the main dialog statement with the SetTimer a timer, drawing in the timer response function, in the main dialog to add a button, click on the button, pop up a modal dialog box, the modal dialog on the drop-down list control,
Above the basic function for the program, the program compiled through, began to run, all OK., click on the button, popup a modal dialog box, is everything OK at this time, drag a modal dialog box or click on the drop-down list control, the main dialog box drawing work stopped in the timer, time grows, the program card dead are directly,
To solve this problem, I remove the timer, open a thread in the main program for drawing, successfully solve the problem,
In practical application, however, have to use a timer (SetTimer) for drawing, so only in a modal dialog box to find a way to, was not recruit, BBS Daniel guidance, genuflect is begged

CodePudding user response:

I also encountered this problem before,
Back to find the solution: when will need to bring up a dialog box to turn off the timer KillTimer, then in child dialogs initialization function, then obtain the main dialog pointer, and open the timer,

CodePudding user response:

The timer messages lowest priority!

CodePudding user response:

Drawing operations should write in the OnPaint function all
Timer just modify the parameter called Invalid redrawn to activate

CodePudding user response:

reference 1st floor chen_JADE response:
I also encountered this problem before,
Back to find the solution: when will need to bring up a dialog box to turn off the timer KillTimer, then in child dialogs initialization function, then obtain the main dialog pointer, and open the timer,
there's no way I'm click on the button code first KillTimer (1) and then write out a modal dialog box code and then the modal dialog initialization function to restart the timer in OnInitDialog: : SetTimer (m_pDlg -> m_hWnd, 1, 30, NULL) natural can't you see I have something wrong?

CodePudding user response:

Try
The use of multimedia timer timeSetEvent () function

CodePudding user response:

reference 5 floor schlafenhamster reply:
try
Using multimedia timer timeSetEvent () function
tried the situation is a must use SetTimer only in a modal dialog box to find a way to here

CodePudding user response:

1 in fact, your threads are realized, can replace the timer thread,
2 try CreateWaitableTimer

CodePudding user response:

reference xianglitian reply: 3/f
drawing operations should write in the OnPaint function all
To invoke Invalid timer just modify the parameters of activated redraw

Truth, not a drawing is blind ball placed in the OnPaint,,,

CodePudding user response:

Put in the OnPaint tried still doesn't work

CodePudding user response:

references 9 f weixin_40994171 response:
put in the OnPaint tried still no
how did you try?

CodePudding user response:

Drawing code in OnPaint timer invokes the redraw

CodePudding user response:

Contact me, look at how to solve,



The main dialog box timers, had nothing to do with a modal dialog box!!!!!!!!!!

CodePudding user response:

This is your window covers, be covered the window without modification is not redrawn before operation, in order to save resources

CodePudding user response:

30 ms timer is too short, try to 3 seconds
  • Related