Direct3D child window within a GDI main window

Started by
2 comments, last by superpig 19 years, 3 months ago
Hi all, I would like to embed a Direct3D child window a standard GDI parent window (containing other child windows/common controls) in my UI editor application. Is it going to require a funky initialization and setup process? Any guidance would be much appreciated :) edit: Oh yeah, and I'm using pure win32 API -- no MFC for me...
Advertisement
Hi there, yes it can be done, make the second window a child of the first window -in the create window function one of the parameters is for the parent window. It can get tricky though, for some reason windows seems to want duplicate (any buttons etc), which you put in the first window, into the second window. A way around this might be to write a second WINCLASS for the the second window?

BTW, Some people use wxwindows, or visual basic for doing a windows gui, the reason for this is it can become quite hard doing it by hand, you can end up with masses of code like a "createwindow" for every single button etc. hy not try using the new d3dx gui? or like me try making your own one with sprites, and rectangle/mouseclick checking?
The only possibly really difficult thing of doing your own gui, is when you may want to do text input, I am considering doing this with buffered directinput & strings/chararrays and d3dx text.

Tip; if you do it this way, think carefully about it and only implement what you really need- or want, no point trying to implement your own whole "windows gui", also you can make a class for the sprites & rectangle checking, then somesort of simple message checking, like was a button pressed?.

wish you luck & Happy new year.
Thanks for the reply Stevieboy.

Actually, I'm merely trying to create a win32 GUI tool (using VC++) to layout my own UI elements for a certain project. So the tool itself is going to have a standard main window that uses win32 common controls to select, edit and manage the layout of my own UI widgets and a D3D child window to display the result.

Is the init process just going to be something like this? ---

1. hMainWindow = CreateWindowEx(...) // Create my custom main window
2. hChildWindow = CreateWindowEx(... , hMainWindow, ...) // Create my custom child window
3. Get the IDirect3D9 object
4. CreateDevice(..., hChildWindow, ...) // Create D3D device with the child window handle

Would I have to worry about the implications of embedding a Direct3D draw buffer within a GDI hdc?

[Edited by - barfy on January 2, 2005 2:35:58 AM]
Nope. If you intercept WM_PAINT, and WM_ERASEBKGND (or just don't give the window class a background brush) for the child window, then the GDI device context is basically never used.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

This topic is closed to new replies.

Advertisement