Site Sections

Friday, June 6, 2008

Timers and Direct X

Does anyone know how to get timers to work with Direct X? I have been having one heck of a time getting it to work. Strangest thing:

This is what I got so far... I have a Non-Modal MFC dialog, this is my main dialog. It is using Direct X to draw to the CWnd object of the dialog to control my Editor View. It also launches another Non-Modal MFC dialog that is my properties window. This has nested dialogs associated with tabs on an MFC Tab Control.

Now, I want some CEdit controls attached to these custom dialogs to update every x number of milliseconds. To do this I was going to use a timer. However, it seems that I am doing something wrong. I set up the ON_WM_TIMER handler and create the void OnTimer(UINT_PTR nIDValue) function to handle my timer event. I called SetTimer(1, 100, NULL) to set the timer in the OnInit() function and call it again in my OnTimer function. However, it doesn't seem to ever call the OnTimer function. I can get this to work in a new project on a single dialog. I have also tried to get this to work on all the other dialog classes in the project to no avail.

Is there a conflict with timers and the Direct X loop? Please feel free to comment on this if you think you might know what the problem is... I will love you forever if you can help :)

1 comment:

Unknown said...

Well, I ended up using a messaging system for this problem instead of using a timer. Thus anytime the position has changed based on user controls, it signals the other panel to update.

I think this is much cleaner and easier to control than timers.