views:

54

answers:

1

Hi, I'm looking for a method to specify parent window in *.rc file.

In *.rc file, it contains the layout and controls of a dialog. Any new control added into it, will automatically become a child window of Dialog itself.

But I want to add a custom draw window into dialog, and some other controls which has that "custom draw window" as parent window, not dialog itself.

I know I can use ::CreateWindow(...) API to dynamic create a window in code, and specify the custom draw window as parent HWND. But we already has child controls layout in *.rc file, I just want to reuse them, without create HWND again.

Thanks,

William L.

A: 

It is not possible to specify a parent window for the controls defined in the resource file. All controls in the resource file have the dialog set as the parent when the dialog is created.

You can try rolling out your own dialog manager - Raymond Chen has a 9-part series of blog posts on it (Part 1, Part 2, Part 3, Part 4, Part 5, Part 6, Part 7, Part 8, Part 9) - but it might be overkill for this situation.

What is your custom draw window doing anyway?

In silico
Thanks! It seems there is no way to do this in *.rc file.I will have to use ::SetParent(...) API to change the parent window in init method.
welemon
I do have to warn that some controls do not expect to be reparented (see http://blogs.msdn.com/b/oldnewthing/archive/2010/03/16/9979112.aspx)
In silico