gin*_*boy 5 c# winapi sdl sdl.net
有谁知道如何在程序上围绕屏幕移动我的SDL.net视频表面?
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);
Run Code Online (Sandbox Code Playgroud)
我找不到任何属性Surface或者Video做什么工作,并且FromHandle返回Null.
窗口正在初始化从屏幕底部掉落. 替代文字http://i42.tinypic.com/2mespe0.png
有任何想法吗?
更新:
我已经看过这段代码,但无法解决一个等效的C#implimentation.有人可以帮忙吗?
#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 );
}
Run Code Online (Sandbox Code Playgroud)
如果不这样做,在我的c#项目中包含一些c ++会涉及多少工作?
谢谢.
您将需要这些声明:
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);
Run Code Online (Sandbox Code Playgroud)
用法:
SetWindowPos(Video.WindowHandle, HWND_TOP, x, y, width, height, SWP_FLAGS);
Run Code Online (Sandbox Code Playgroud)
其中 x 和 y 是屏幕坐标。如有必要,请使用 Control.PointToScreen()。
| 归档时间: |
|
| 查看次数: |
1152 次 |
| 最近记录: |