How do I Inlize into a child window

Started by
3 comments, last by Namethatnobodyelsetook 18 years, 8 months ago
I am trying to make a map editor and need to load my tiles to a child window but I cant figure out how to load DirectDraw to a child window. Can any one help with this?
Advertisement
Simply supply the window handle of the item you wish to link D3D to in the hDeviceWindow parameter of the D3DPRESENT_PARAMETERS structure when creating or resetting your device.
Not many people are still using DirectDraw, as Microsoft doesn't support it any longer, and you can get faster 2D with D3D along with hardware accelerated alpha-blending, scaling, rotation, etc. While I completely forget how initializing DDraw works, it may be similar to D3D, so I'll mention how D3D works.

In D3D you specify two window handles. One is specified in your present parameters, passed to CreateDevice, Reset, or CreateAdditionalSwapChain. This is the window you want drawn on. It can also be overridden in Present(), which is what swaps the front/back buffers. The second window handle is specified to the CreateDevice function directly. This handle should be to your application's main top-level window.
well your first point is that directdraw is dead . well if you could show me how to use d3d just like ddraw to create a 2d game I would be more then happy to use it. But at this time there is no way I could do that.

your second point could you explain it a little more?

I know I have to assigne a handle to the device but do I have to assigne a handle to the parent the a handel to the child.

could you just show me some code that sets the hanles properly?

thanks for all the help so far
I don't (well, I didn't when I started this post) know how it's done in DirectDraw. In D3D you need BOTH window handles, the child you want to draw to, and the parent window. I was just pointing it out in case DDraw has two places which take window handles. If it does, they're likely the same idea. One is the top-level parent window, and one is the child you want to render to.

Looking in google/msdn, I see SetCooperativeLevel needs the top level window, not the child.

Digging further (my god, there's no good DDraw docs!) I see an article here about using windowed mode. It's about 80% of the way down. They create a clipper, set the hwnd of the child in the clipper, then associate the clipper with the primary surface. According to MSDN you can keep setting this hwnd any time you want to draw to another window.

This topic is closed to new replies.

Advertisement