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