gpt4 book ai didi

c# - 移动 SDL 视频表面

转载 作者:太空狗 更新时间:2023-10-29 23:04:19 34 4
gpt4 key购买 nike

有谁知道如何移动我的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);

我在 SurfaceVideo 中找不到任何可以完成这项工作的属性,并且 FromHandle 返回 Null。

窗口正在初始化,从屏幕底部掉落。 alt text

有什么想法吗?

更新:

我看过这段代码,但无法计算出等效的 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++ 涉及多少工作?

谢谢。

最佳答案

您需要这些声明:

    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()。

关于c# - 移动 SDL 视频表面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2618673/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com