In an MFC application for one document (SDI) or multiple documents (MDI), I created an application timer in the view. The timer will be a checkmark while the application is running, and will cause some periodic actions.
How can I do the same with a Dialog-based MFC application?
Are there better methods for doing this?
The timer also works in the dialog application as an SDI or MDI application. OTOH, timers (mostly) remain from 16-bit Windows. If you want to do things periodically, a workflow is usually the best way to do this (and yes, Windows Mobile supports multiple threads).
: ( ) . , . - MFC , .
MFC , , , , . DoModal(), , .
, - . , , .
- .
IMO, , . , , , MFC , .
, , ( KISS)
SetTimer , .
- CWinApp ( - )
static void CALLBACK OnTimer(HWND, UINT, UINT, DWORD);
InitInstance SetTimer(0, [eventid], [time period], OnTimer);
InitInstance
SetTimer(0, [eventid], [time period], OnTimer);
OnTimer CWinApp AfxGetApp() theApp, .
OnTimer
AfxGetApp()
theApp
: .
MFC Dialog . , CWinApp. InitInstance() CDialog:: DoModal(). , .
, CWinApp , WM_TIMER.
.
. , , .
, .. Create() DoModal(). Create() ( ). CWinApp . , CWinApp . ( , ).
mesage CWinApp. , .
You can create a dedicated timer thread. You will probably do this from the CWinApp class before it creates a dialog, but other strategies are possible.
How does any of these patterns sound like they fit your needs? If not, perhaps you can explain your needs in more detail, and we can come up with something suitable.
Source: https://habr.com/ru/post/1730498/More articles:Free static check for HiTech / Microchip C? - cWPF equivalent to ActiveControl? - vb.netHow to avoid leakage to prevent XSS attacks? - escapinghow to allow ruby ββto use default browser to open local file - ruby ββ| fooobar.comCan I reset an event from the main page on ASPX? - asp.netWhy can a CSRF attack be prevented by a random CSRF secret? - securityHow to remove slides from PowerPoint using C #? - c #Any way to execute inline javascript as a url? - javascriptFinding a set of add-ons on Unix - linuxConverting decimal to binary numbers - computer-scienceAll Articles