jdl
jdl

Reputation: 6333

How to programmatically create a CDialog window?

I do not want to use the "graphics resources" to create the dialog!

What I have so far:

CDialog *dlgWin = new CDialog();
dlgWin->Create("hello");  // <-- but this Errors: "Debug Assertion failed!"

thx

Upvotes: 2

Views: 7507

Answers (2)

Lothar
Lothar

Reputation: 13092

I use one empty dialog template for all dialog boxes and then use my own GUI layout library to generate and manage the size of the MFC widgets. Don't know if you really want to do it because it requires a lot of additional work, gives problems but also features.

Using Qt oder GTK might be a way but i don't like them.

Upvotes: 1

littleadv
littleadv

Reputation: 20282

You need to create the dialog template in the resource editor, and provide it to the CDialog constructor.

Here's the documentation, they also explain how to dynamically create your dialog in memory, its not trivial and I'd advise against it. I'd advise against using MFC altogether.

The MSDN documentation is usually pretty well written, read it.

Upvotes: 2

Related Questions