Sign in to follow this  
Numsgil

Embedding Tao.SDL into a windows form

Recommended Posts

Numsgil    501
I'm using Tao.SDL (very new to SDL, not so new to C#). What I'd like to do is have a windows form with an SDL surface "embedded" inside it. So that I can have a little C# control panel GUI to control what's being drawn to the SDL surface. Is there a way to do this?

Share this post


Link to post
Share on other sites
Fiddler    860
I haven't used SDL extensively, but I'm currently creating a C# windowing library for Tao, so I'll draw some ideas from that.

First of all, I don't think SDL provides some method to 'hook' onto existing windows, so you'll need to find some hacky way of achieving this.

One line of attack would be to create some custom Control (derived from Windows.Forms.UserControl), and hack SDL to use control's window handle, instead of creating it's own. You'd then have to override the control's WndProc to call the internal SDL message loop. This probably means changing the SDL source code to expose the relevant functions, so it might be a good idea to investigate some other alternatives first.

Another idea would be to use Tao.Sdl to render normally on a window (possibly offscreen), and then copy that window's contents to a Bitmap that gets displayed on your control. I'm not sure how, but there's bound to be a system call for this.

Last, maybe SDL allows to create a window without decorations (the X button etc), which you can then position by hand inside the Windows.Form? You'd have to respond to all move, size etc messages, and I don't know how good it would look, but it could work.

Share this post


Link to post
Share on other sites
Numsgil    501
Quote:
Original post by Fiddler
Last, maybe SDL allows to create a window without decorations (the X button etc), which you can then position by hand inside the Windows.Form? You'd have to respond to all move, size etc messages, and I don't know how good it would look, but it could work.


This last one seems a viable possibility. Would be tricky to set up, but the complexity could probably be hidden inside a control.

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