Click to See Complete Forum and Search --> : Creating a dialog at runtime


Anders Eriksson
June 1st, 1999, 05:17 AM
I'm trying to create a dialog at runtime. I have used the DLGTMPL sample as a start. I have gotten it to work with the standard controls, like editcontrol, static text and buttons! But I having trouble with nonstandard control like the DateTimePick control. The reason is of cause that I don't understand what MS is doing in the DemoIt function (that's where they create the dialog and run it)

Are there some easiar way of doing this then what MS has done?

If not how do you create a non-standard control at runtime?

// Anders

Robert Rolls
June 1st, 1999, 11:21 AM
wrer did you get the example from? url? MSDN?

Anders Eriksson
June 2nd, 1999, 03:47 AM
Hello! Yes the example is on the MSDN Library CD that accompanies Visual Studion 6 (I've got the enterprise version)

It's to much code to include here(?) but it should be available on the msdn web

Thank you for the reply! It's always nice when people care!

// Anders

Robert Rolls
June 2nd, 1999, 09:07 AM
After looking at the example and reading through the docs - looking at MFC's source code OCCMGR.CPP it's a little more complicated than simply supplying some data. The reason I asked was in my current project we have to write a class for doing this exact thing. It's a little difficult if your a novice the code within the example is pretty striagh forward. But quite useless. I suggest looking through the OCCmgr.cpp source... I'll probably post the source for the class here at codeguru.

Gomez Addams
June 2nd, 1999, 01:52 PM
In my company's app we do something similar to this. Actually, we read real-live
.RC files and generate dialogs 'on-the-fly'. We do this using the dialog template
in memory method as shown in the DLGTMPL sample. What we do that is a
bit different though is we create only the dialog frame in the template. We
create all of the controls in the OnInitDialog method of a dialog-driving class
the we made. This is done using the Create members of the various control
classes. So, we make an object for each control and create them when the
dialog is created.