2010-04-11 58 views
5

有誰知道如何在編程的屏幕上移動我的SDL.net視頻表面?移動SDL視頻表面

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

我不能在SurfaceVideo該做的工作發現的任何屬性,並FromHandle是返回NULL。

窗口正在初始化從屏幕底部脫落。 alt text http://i42.tinypic.com/2mespe0.png

任何想法?

更新:

我已經看到了這個代碼,但不能制定出一個equivilent C#執行力度。誰能幫忙?

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

做不到這一點,有多少工作是參與包括一些C++在我的C#項目?

謝謝。

+0

筆記自我:當你回家時尋找線索...... http://fixunix.com/xwindows/91816-coords-window-under-sdl.html,http://www.gamedev.net/社區/論壇/ topic.asp?topic_id = 328286 – gingerbreadboy 2010-04-12 07:47:36

回答

4

你需要這些聲明:

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

用法:

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

其中x和y是屏幕座標。如有必要,使用Control.PointToScreen()。

3

根據您找到的C++代碼判斷,您可以P /調用Win32 SetWindowPos函數並通過Video.WindowHandle句柄(以及尺寸和位置參數),因爲看起來並不是由。淨。