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 :)
Showing posts with label MFC. Show all posts
Showing posts with label MFC. Show all posts
Friday, June 6, 2008
Thursday, May 15, 2008
And Life Goes On...
I did it, I broke down and got Visual Studios 2008 professional edition. I can continue now with my original plan for my editor.
A thing of note: Using a dialog in an application of its own - easy. Using dialogs in combination, when you want more than one dialog on the screen and active at the same time - eh... not so easy. The key is to use Modaless dialog boxes (those created with the .Create(IID, hwnd) function instead of the DoModal() function), be sure to keep a reference to these dialog boxes outside of the InitInstance() funciton of your main app class otherwise, when the function ends, so will the app. Then map the OnClose message handler to the window (or windows) that you want to be the "Main Window" of the application. This handler should then post the PostQuitMessage() function to kill the application in the even that the window is closed.
I ran into this issue because I have two dialogs, an editor window, and a properties window (which seems to stay on top of the editor window all the time - this is a different issue though), and these windows, when closed do not by default kill the application when set up in a Modal fashion. So now I have my editor set up as my "Main Window" (by keeping a reference outside of the InitInstance() function and setting the m_pMainWnd pointer equal to my Editor dialog, and when ever this window is closed, the Editor posts the quit message so the app will close.
I didn't really want to use a Window Frame here or an MDI style application as I want my editor to have a Gimp like feel, with all the tools/properties windows being a movable separate entity from the viewport I am working on.
As such as this post is so well entitled, Life does go on... and so does development.
A thing of note: Using a dialog in an application of its own - easy. Using dialogs in combination, when you want more than one dialog on the screen and active at the same time - eh... not so easy. The key is to use Modaless dialog boxes (those created with the .Create(IID, hwnd) function instead of the DoModal() function), be sure to keep a reference to these dialog boxes outside of the InitInstance() funciton of your main app class otherwise, when the function ends, so will the app. Then map the OnClose message handler to the window (or windows) that you want to be the "Main Window" of the application. This handler should then post the PostQuitMessage() function to kill the application in the even that the window is closed.
I ran into this issue because I have two dialogs, an editor window, and a properties window (which seems to stay on top of the editor window all the time - this is a different issue though), and these windows, when closed do not by default kill the application when set up in a Modal fashion. So now I have my editor set up as my "Main Window" (by keeping a reference outside of the InitInstance() function and setting the m_pMainWnd pointer equal to my Editor dialog, and when ever this window is closed, the Editor posts the quit message so the app will close.
I didn't really want to use a Window Frame here or an MDI style application as I want my editor to have a Gimp like feel, with all the tools/properties windows being a movable separate entity from the viewport I am working on.
As such as this post is so well entitled, Life does go on... and so does development.
Subscribe to:
Posts (Atom)