Embedding Graphics in a Windows Form (Tools Programming)

Started by
1 comment, last by Kal_Torak 15 years, 9 months ago
I'm working on a tile map editor and would like to have a part of the window show an actual representation of the map where you can lay down tiles. I'd also like a list box type item that has the tiles in it. From what I've seen online drawing DirectX to a portion of a form seems quite difficult. Also, I've heard some people suggest System.Drawing instead. Does anyone have any experience/suggestions for building a game tool like this? Any help is greatly appreciated. [Edited by - programmermattc on July 14, 2008 1:36:48 PM]

=============================RhinoXNA - Easily start building 2D games in XNA!Projects

Advertisement
Using DirectX to draw to a form is not difficult at all. All you need is the Handle property of the form to pass to DirectX. If you can stay with all managed code, I'd recommend checking out SlimDX, which is how you can access DirectX from managed code.
Mike Popoloski | Journal | SlimDX
As Mike said, rendering to a part of the window is pretty easy.

I just took about 2 minutes and changed my renderer constructor to accept a Control instead of a WinForm, and then I just added a PictureBox (any Control derived class should work) to the form I was rendering to, passed the PictureBox control to the renderer, and voilà, my game was rendering to the PictureBox which was about 1/3 the size of the WinForm.

I imagine you could switch between rendering to different Controls just as easily. I'm not sure what you'd have to do for reconstructing the device when you change Handles though, haven't done that myself.

I'm using C#/SlimDX for my game projects, it's pretty smooth.
If you gave a helpful reply, I rated you up.

This topic is closed to new replies.

Advertisement