Sign in to follow this  
blahpers

Direct3D in windowed mode: Mixing with common controls

Recommended Posts

Greetings, it's been a while. My current project requires me to build an application using the old Win32 C++ API (yeah, I know, Vista will phase it out, but them's the breaks). The application uses several of the common controls (e.g., buttons, static labels, trackbar). However, I also want to have a Direct3D view on the same window. Anyone who has done this: What's the easiest method? Should I simply send the window handle to IDirect3D9::CreateDevice (per the normal procedure for windowed Direct3D) but only draw on part of the window? Or should I create a custom control as a child of the main window and send its handle instead? I don't have much experience messing with controls on the Win32 level, but neither MFC, third-party libraries, nor managed/.NET languages are an option. Thanks in advance.

Share this post


Link to post
Share on other sites
The most common way I've seen this done is to do it map-editor style, where you have a normal app (with all your controls and stuff), but then a display in the middle or something. IIRC, you can do this with an Image Box control. Just get the HWND of the image box, and give it to CreateDevice(). Then, your device will just present into that box.

This way is pretty clean, because you pretty much just embed your renderer into that one image box.

Share this post


Link to post
Share on other sites
Thanks circlesoft,

The closest Win32 control I can find to ImageBox is a static control with the SS_OWNERDRAW window style. This may be what I end up using, but I'm somewhat concerned that static controls cannot gain keyboard focus, and I'd like to be able to give the control keyboard focus so that I can use keyboard controls to navigate the 3D environment.

Perhaps I can make an owner-drawn button instead, since those can have keyboard focus. Alternatively, I might just make a standard window with no frame, make it a child of the main window, and handle WM_SIZE in the main window to make sure the child window is always in the correct position relative to the parent.

Share this post


Link to post
Share on other sites
Quote:
Original post by blahpers
Thanks circlesoft,

The closest Win32 control I can find to ImageBox is a static control with the SS_OWNERDRAW window style. This may be what I end up using, but I'm somewhat concerned that static controls cannot gain keyboard focus, and I'd like to be able to give the control keyboard focus so that I can use keyboard controls to navigate the 3D environment.

Perhaps I can make an owner-drawn button instead, since those can have keyboard focus. Alternatively, I might just make a standard window with no frame, make it a child of the main window, and handle WM_SIZE in the main window to make sure the child window is always in the correct position relative to the parent.

The last approach is guaranteed to work. Come back and tell us if you get it to work with the other approaches, though [smile].

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this