Moving SDL Video

Does anyone know how to programmatically move my SDL.net video surface across the screen?

Surface videoContext = Video.SetVideoMode(1024, 768, 32, false, false, false, true, true);

var a = System.Windows.Forms.Control.FromHandle(Video.WindowHandle);
var b = System.Windows.Forms.NativeWindow.FromHandle(Video.WindowHandle);

I cannot find any properties in Surfaceor Videothat do the job, and FromHandlereturns Null.

The initialization window drops from the bottom of the screen. alt text

Any ideas?

Update:

I saw this code, but I can’t work out an equivalent C # implication. Can anybody help?

#ifdef WIN32
#include <SDL_syswm.h>
SDL_SysWMinfo i;
SDL_VERSION( &i.version );
if ( SDL_GetWMInfo ( &i) ) {
  HWND hwnd = i.window;
  SetWindowPos( hwnd, HWND_TOP, x, y, width, height, flags );
}

Otherwise, how much work does it take to incorporate some c ++ into my C # project?

Thank you

+5
source share
2 answers

You need these ads:

    private static IntPtr HWND_TOP = IntPtr.Zero;
    private static int SWP_FLAGS = 0x004 | 0x0010;
    [System.Runtime.InteropServices.DllImport("user32.dll")]
    private static extern bool SetWindowPos(IntPtr hWnd, IntPtr after, int x, int y, int width, int height, int flags);

Using:

    SetWindowPos(Video.WindowHandle, HWND_TOP, x, y, width, height, SWP_FLAGS);

x y . Control.PointToScreen(), .

+4

++, P/Invoke Win32 SetWindowPos Video.WindowHandle ( ), , , , .NET.

+3

All Articles