2010-04-11 15 views
5

¿Alguien sabe cómo mover mi superficie de video SDL.net por la pantalla de forma programática?superficie de video SDL en movimiento

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); 

No puedo encontrar ningún propiedades en Surface o Video el que hacer el trabajo, y FromHandle vuelve nulo.

La ventana se está inicializando cayendo desde la parte inferior de la pantalla. alt text http://i42.tinypic.com/2mespe0.png

¿Alguna idea?

Actualización:

que he visto este código, pero no puede llegar a un equivilent C# implimentation. ¿Alguien puede ayudar?

#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); 
} 

De lo contrario, ¿cuánto trabajo implica incluir algunos C++ en mi proyecto C#?

Gracias.

+0

notas a sí mismo: busque aquí las pistas cuando llegue a casa ... http://fixunix.com/xwindows/91816-coords-window-under-sdl.html, http://www.gamedev.net/ community/forums/topic.asp? topic_id = 328286 – gingerbreadboy

Respuesta

4

Tendrá que estas declaraciones:

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); 

Uso:

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

donde x e y están en coordenadas de pantalla. Use Control.PointToScreen() si es necesario.

3

A juzgar por el código C++ que ha encontrado, puede P/invocar la función Win32 SetWindowPos y pasar el identificador Video.WindowHandle (así como sus parámetros de tamaño y posición) ya que no parece haber una solución provista por .RED.

Cuestiones relacionadas