Re: TimerProc and accessing dialog members
From: Scott McPhillips [MVP] (org-dot-mvps-at-scottmcp)
Date: 11/26/04
- Next message: Andy Mortimer [MS]: "RE: CFileDialog causes application to Hang on Windows 2000"
- Previous message: Mike Gleason Jr Couturier: "Some advice to guide my search"
- In reply to: Daniel Lidström: "Re: TimerProc and accessing dialog members"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 26 Nov 2004 09:08:38 -0500
Daniel Lidström wrote:
> No, not quite. What I'm trying to do is this:
>
> void SurfPage::OnLoop()
> {
> if( m_looping )
> ::KillTimer(NULL, m_nTimer);
> else
> m_nTimer = ::SetTimer(NULL, 1, 100, (TIMERPROC)TimerProc);
>
> m_looping = !m_looping;
> }
>
> /* static */
> VOID CALLBACK SurfPage::TimerProc(
> HWND hwnd, // handle to window
> UINT uMsg, // WM_TIMER message
> UINT_PTR idEvent, // timer identifier
> DWORD dwTime // current system time
> )
> {
> // set m_val to something
> // then update CEdit control in SurfPage.
> // m_val is connected to the CEdit box through
> // DDX. How can I change the displayed value in the
> // CEdit box? This is a static function, that is the
> // whole problem.
> }
>
> Thanks!
>
The static function needs a static variable that is a pointer to the
dialog box. When you create the dialog set the pointer. The static
function can use it to call a dialog function, or to send/post a message
to the dialog. Then a dialog function should do the update.
But why not use a WM_TIMER message handler? If you do that then MFC
solves this problem for you, by calling your nonstatic handler function.
If you are trying to update the dialog from a separate thread then
neither approach will work, and you asked the wrong question.
-- Scott McPhillips [VC++ MVP]
- Next message: Andy Mortimer [MS]: "RE: CFileDialog causes application to Hang on Windows 2000"
- Previous message: Mike Gleason Jr Couturier: "Some advice to guide my search"
- In reply to: Daniel Lidström: "Re: TimerProc and accessing dialog members"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|