Archived

This topic is now archived and is closed to further replies.

thorpe

Child window as CDialog?

Recommended Posts

thorpe    122
I have created an class called COptionsDialog which extends CDialog. This dialog opens when someone presses a button in my main dialog. I somehow want to install a timer in the options dialog but I just can''t figure out how. I cannot create a new timer with settimer (I can compile it like that but windows gives me an error msg once the code is run). I could use the timer in the main app but it somehow stops ticking once this new dialog is opened (I open it with DoModal()). Another strange thing is that I am not allowed to run UpdateData(FALSE) in COptionsDialog (I get the same error message when the program runs), why not? I don''t want to use Invalidate(), how should I do it? Johan Torp - http://www.destruction.nu

Share this post


Link to post
Share on other sites
felisandria    739
Timers should work fine in dialogs. Did you explicitly declare the resource ID of the timer involved? I need to know the error to see what''s really wrong with it.

UpdateData should work, with a few gotchas. For one thing you shouldn''t call UpdateData in the constructor, the first valid place to call it is in OnInitDialog. Again, though, need to see the error to see the problem.

-fel

Share this post


Link to post
Share on other sites
thorpe    122
I found the error while copying code to have in my reply =)

The error was that somehow (this is very strange, please explain) after that I called DoModal(); no code further down was executed;

RegDlg = new CRegretsDialog(this);
ShuttingDown=TRUE;
RegDlg->DoModal();
// I used to have some code here under but it wasn''t executed!!!


Btw, since I create the "subdialogs" with new, do I need to delete them or atleast post them a quit message manually?


Johan Torp - http://www.destruction.nu

Share this post


Link to post
Share on other sites
felisandria    739
I see.

DoModal means "bring everything else to a screeching halt while we pay attention to a dialog now".

If you want stuff to happen in the background you need a modeless dialog. Otherwise, nothing, at all, that isn't separately threaded, and certainly nothing in the rest of the function, is going to happen so long as your dialog is up, until you hit the okay or cancel.

If you want a timer to affect stuff inside the dialog you need to put that timer inside the dialog. If you want to call UpdateData you need to do it from inside the dialog.

Why did you create the subdialogs with new? If they're modal they are only potentially resident as a window between the DoModal and the DoModal's return.

-fel

Edited by - felisandria on November 12, 2001 12:18:32 PM

Share this post


Link to post
Share on other sites
thorpe    122
>DoModal means "bring everything else to a screeching halt while >we pay attention to a dialog now".

Ah, ok. So the code have been run after the dialog exited.

>If you want stuff to happen in the background you need a >modeless dialog. Otherwise, nothing, at all, that isn''t >separately threaded, and certainly nothing in the rest of the >function, is going to happen so long as your dialog is up, >until you hit the okay or cancel.

Actually I use a timer in the main dialog which was running though I didn''t know it because I supposed that the code after DoModal() had been run (which would change the behavious of the timer).


>Why did you create the subdialogs with new? If they''re modal >they are only potentially resident as a window between the >DoModal and the DoModal''s return.

Because I need to use the "subdialog" inside my timer (the timer in the main dialog keeps ticking in the background).
Do I need to delete them?


Thanks for your help...

Share this post


Link to post
Share on other sites