@@ -101,22 +101,28 @@ public static IntPtr WindowsDelegateImplementaion ( IntPtr hwnd, uint msg, IntPt
101101 return 0 ;
102102 }
103103
104- public void CreateMainWindow ( int width , int height , bool enableDebug = false , bool enableFeature = false ) {
104+ public void CreateMainWindow ( int width = 0 , int height = 0 , bool enableDebug = false , bool enableFeature = false ) {
105105 if ( enableDebug ) m_basicApi . SciterSetOption ( IntPtr . Zero , RtOptions . SCITER_SET_DEBUG_MODE , new IntPtr ( 1 ) ) ;
106106 if ( enableFeature ) m_basicApi . SciterSetOption ( IntPtr . Zero , RtOptions . SCITER_SET_SCRIPT_RUNTIME_FEATURES , new IntPtr ( ( int ) DefaultRuntimeFeatures ) ) ;
107107
108- var rectangle = new SciterRectangle ( 0 , 0 , width , height ) ;
109-
108+ var rectangePointer = nint . Zero ;
109+ if ( width > 0 && height > 0 ) {
110+ var rectangle = new SciterRectangle ( 0 , 0 , width , height ) ;
111+ rectangePointer = Marshal . AllocHGlobal ( Marshal . SizeOf < SciterRectangle > ( ) ) ;
112+ Marshal . StructureToPtr ( rectangle , rectangePointer , false ) ;
113+ }
110114 var ptr = Marshal . GetFunctionPointerForDelegate < WindowDelegate > ( WindowsDelegateImplementaion ) ;
111115
112116 m_mainWindow = m_basicApi . SciterCreateWindow (
113117 WindowsFlags . Main | WindowsFlags . Resizeable | WindowsFlags . Titlebar | WindowsFlags . Controls ,
114- ref rectangle ,
118+ rectangePointer ,
115119 RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? ptr : IntPtr . Zero ,
116120 IntPtr . Zero ,
117121 IntPtr . Zero
118122 ) ;
119123
124+ if ( rectangePointer != nint . Zero ) Marshal . FreeHGlobal ( rectangePointer ) ;
125+
120126 if ( enableDebug ) {
121127 m_basicApi . SciterSetupDebugOutput (
122128 m_mainWindow ,
0 commit comments