移动 SDL 视频表面
有谁知道如何移动我的 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);
我在 Surface
或 Video
中找不到执行此操作的任何属性,并且 FromHandle
返回 Null。
有什么想法吗?
更新:
我已经看过这段代码,但无法计算出等效的 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++ 需要做多少工作?
谢谢。
Does anyone know how to move my SDL.net video surface around the screen programtically?
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 can't find any properties in Surface
or Video
which do the job, and FromHandle
is returning Null.
The window is initializing falling off the bottom of the screen.
Any ideas?
Update:
I've seen this code but can't work out an equivilent C# implimentation. Can anyone 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 );
}
Failing that, how much work is involved in including some c++ in my c# project?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您找到的 C++ 代码判断,您可以 P/Invoke Win32
SetWindowPos
函数并传递Video.WindowHandle
句柄(以及您的大小和位置参数)因为.NET 似乎没有提供解决方案。Judging by the C++ code you've found, you could P/Invoke the Win32
SetWindowPos
function and pass theVideo.WindowHandle
handle (as well as your size and position parameters) since there doesn't appear to be a solution provided by .NET.您将需要这些声明:
用法:
其中 x 和 y 位于屏幕坐标中。如有必要,请使用 Control.PointToScreen()。
You'll need these declarations:
Usage:
where x and y are in screen coordinates. Use Control.PointToScreen() if necessary.