Advertisement Jump to content


This topic is now archived and is closed to further replies.


DirectX in Child Window

This topic is 5636 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have spent the last few hours seaching for help on this, but nothing conclusive. I want to put my directX stuff in a child window leaving for the remainder of the main window for controls. When i run the program it fails at the createDevice() call. Any advise on this problem would be much appriciated, thanks.

Share this post

Link to post
Share on other sites
Thanks for the rapid responce,

// Create the Main Window

g_hWnd = CreateWindow(g_szClass, g_szCaption,
0, 0, 400, 400,
hInst, NULL );
return FALSE;

// Create the Child Window

g_hChild = CreateWindow(g_szClass, " ",
0, 0, 200, 200,
g_hWnd, NULL,
hInst, NULL );

I tinkered with the code that much i can't remeber the different variations i have tried, this was my latest attempt.

[edited by - Defcom on August 16, 2003 1:10:09 PM]

Share this post

Link to post
Share on other sites
Look up swap chains.

[edit] If you just want to render to 1 child window then there is a simpler way. Make your device for the parent window. One of the parameters for the Present call takes a handle to a HWND which will override the one the device was made with. Just use your child window handle and everything should work fine .

[edited by - Raloth on August 16, 2003 3:26:49 PM]

Share this post

Link to post
Share on other sites
Use your main window for the focus window (the parameter to CreateDevice) and the child window for the device window (in D3DPRESENT_PARAMETERS).

Additional swap chains are for when you have multiple rendering windows but if you just have the one then don''t worry about them for now.

As Raloth says it is possible to do this without a child window by overriding the default Present behavior. There are a number of things to keep in mind about this approach:

* You generally want the swap chain to be the same size as the "window" you''ll be presenting to. If you use the main window as the device window then the swap chain will take on *its* client size, which is probably bigger than you want, and if you don''t take extra steps with the viewport and source rectangle when presenting, you''ll be rendering a larger image than will actually be seen on the screen. (Present will shrink it down when blitting.) This is obviously wasteful and can affect image quality. So specify an explicit BackBufferWidth and Height when creating the device using the child "window" size, don''t rely on the defaults.
* You''re limited to D3DSWAPEFFECT_COPY. The other two don''t permit overriding the source and dest rects in Present.
* There are certain advantages that can come in handy when using an actual child window -- window styles, z-ordering, and such. With this approach, your "window" will always appear as if at the back of the z-order.

Share this post

Link to post
Share on other sites
Thankyou for the responces, I am not sure how, but i had started another project and it worked??? even though it was the same code, but i did add some files to the linker.
Thanks again.

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!