DirectX and tabpages

Started by
5 comments, last by remigius 18 years ago
Hi, I'm sorry, I know this is a game dev forum, but I can't find info (C#) anywhere else and I'm hoping someone here could help me out. I have a normal windows form with a bunch of tabpages on it. But in the beginning, I want to do a little DirectX intro (which I've already created) in a class that I've been running separately. Now I'm not sure how to put them together without having to close the intro form and then open the main form. Can anyone direct me to examples showing how to create a surface or something on the main form that will run the directx stuff? Thanks for any guidance!!! Melanie
Advertisement
hi, not sure on this, but can you get the hdc of the form? As "windows are windows", kind of thing theoretically you should be able to target d3d at any thing you want - even a button etc? I don't know how it is in winforms, but if you can get the handle to the form, or hdc, surface or something it may be possible.
When you make the d3d device pass it the handle/idenifier of the form.
Hi again,
I'm now trying to figure this part out:

"When you make the d3d device pass it the handle/identifier of the form."

I can't find anything online to guide me through this process, so this is what I'm trying:
In the main form I say
Intro intro = new Intro();
and then under (Intro) InitializeGraphics() I use something like
PresentParameters pp = new PresentParameters();
pp.DeviceWindowHandle = ...somehow say it's the form...
and then create the device.
device = new Device(0, DeviceType.Hardware, this, createFlags.SoftwareVertexProcessing, pp);

I guess it just comes down to not knowing how to tell the device that the form is the handle.
Again, thanks so much for any help!
Mel
Hi, (I was the anomynous poster), I think its you r "this" parameter you need to change, can you get a handle to the tabed thingy on your form (the actual item where you want the d3d to go).

If you had to do something else with it what would you use to communicate with it? For instance in normal win32 you would get a handle to something first (such as a dialog box), then you could send it a message, with "sendmessage(..). I'm guessing your "this" parameter might be your main window or something? Try to pass the tabbed bit instead.

Hope that helps


PS I don't really know winforms etc I'm just going by how it would be in normal windows.
On the tab you can place a panel which is probably the best control to render to. You should also explicitly pass the handle of the control to the device constructor.
i.e.
device = new Device(... panel.Handle ...);

I have come across some problems when that is not done.

I hope this helps.
Take care.
If you want to see a code sample for the sound advices above, you might want to check out the sources for this tool, the VolumeViewer class in particular. It's a user control with a device attached to it that's used on a TabPage in the project, so it might be worth taking a look at.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement