如何在 Windows 窗体中显示过剩窗口?
glutCreateWindow("Example") 创建另一个表单,
glutCreateSubWindow(hwnd, 0, 0, 100, 100),其中 hwnd 是我在 C# 中的主窗口窗体的句柄,我得到一个 AccessViolation 异常。
Glut 程序位于 C++ DLL 中。我的应用程序在 C# WPF 上。我需要在我的 C# 表单中显示过剩视图
C++ 代码:
extern "C"
{
__declspec(dllexport) int InitGlut(int hwnd, int top, int left, int width, int height)
{
glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowPosition(top,left);
glutInitWindowSize(320,320);
//glutCreateWindow("Example");
glutCreateSubWindow(hwnd, top, left, width, height);
glutDisplayFunc(renderScene);
glutMainLoop();
return 0;
}
}
C#代码:
const string pathToDll = "../../../Release/MyDLL.dll";
[DllImport(pathToDll)]
public static extern int InitGlut(IntPtr hwnd, int top, int left, int width, int height);
private void Window_Loaded(object sender, RoutedEventArgs e)
{
IntPtr hwnd = new WindowInteropHelper(Application.Current.MainWindow).Handle;
InitGlut(hwnd, 0, 0, 100, 100);
}