Is there any difference between the functions Create and CreateIndirect?

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Re: Is there any difference between the functions Create and CreateIndirect?

Originally Posted by S_M_A

Come on Larry, isn't MSDN available in your country? From MSDN:
MFC or if you actually use Win32

Probably I had a too general title for my question. Actually I know the difference in superficial sense as MSDN points out. One is used to create a modaless dialog from resource and another one is used to create a modaless dialog from memory. But the REAL question is why would we create a modaless dialog from memory?Does it imply sometimes it fails to create a modaless dialog from resource so CreateIndirect comes to remedy?
BTW, I assume this forum is a quality forum.

Re: Is there any difference between the functions Create and CreateIndirect?

Originally Posted by LarryChen

But the REAL question is why would we create a modaless dialog from memory?

Try to create your own resource editor program or a program that builds and runs dialogs on the fly. You don't know beforehand the number of edit controls, list boxes, combo boxes, static text, etc. and you don't know the positions, sizes and tab order of these controls. All of that information is only known at runtime when the user has selected the controls and characteristics of each control.

So the only way to get something like this to work is to build the resources yourself at runtime, in memory. Granted that it isn't trivial to do (to build your own resource from scratch was something that required knowledge of the internals of the resources), but Windows allows you to create dialogs without a physical resource defined, and CreateDialogIndirect() is the hook into doing this. If you did a web search on "Dynamic Dialog Boxes", you should find code on how this is done.

Re: Is there any difference between the functions Create and CreateIndirect?

Originally Posted by LarryChen

Does it imply sometimes it fails to create a modaless dialog from resource so CreateIndirect comes to remedy?

This may imply most probably that CreateDialog makes use of CreateDialogIndirect internally. The action appears to be two-phased, first it loads resource to memory, and then it creates the dialog window by the in-memory template as is. As long as there may be some use of CreateDialogIndirect itself (what Paul and OReubens have already explained), the API is exposed as an independent and standalone entry.

This multi phase approach is very typical for API design, not only Windows but of any kind.

Re: Is there any difference between the functions Create and CreateIndirect?

It can also be needed if you load the resource template into memory yourself, do some changes to it (such as changing the font to match the system font, or changing/removing/adding controls), then create the dialog from the modified resource in memory.

* The Perfect Platform for Game Developers: Android
Developing rich, high performance Android games from the ground up is a daunting task. Intel has provided Android developers with a number of tools that can be leveraged by Android game developers.

* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.