2
0
Эх сурвалжийг харах

* Control.cs:
* Label.cs: changed CreateHandle method to use CreateParams property
* README: added instructions for building and using project
* makefile: removed monostart.c from makefile
* monostart.c:
* test.sh
* build.sh: no longer used, removed

svn path=/trunk/mcs/; revision=8202

John Sohn 23 жил өмнө
parent
commit
40f69d7379

+ 19 - 21
mcs/class/System.Windows.Forms/System.Windows.Forms/Control.cs

@@ -75,7 +75,6 @@ namespace System.Windows.Forms {
 		bool tabStop;
 		string text;
 		bool visible;
-		CreateParams createParams;
 
 		// --- Constructors ---
 		public Control ()
@@ -109,7 +108,6 @@ namespace System.Windows.Forms {
 			visible = true;
 			parent = null;
 			window = null;
-			createParams = new CreateParams ();
 		}
 		
 		// according to docs, the constructors do not create 
@@ -421,6 +419,24 @@ namespace System.Windows.Forms {
 		
 		protected virtual CreateParams CreateParams {
 			get {
+				CreateParams createParams = new CreateParams ();
+				createParams.Caption = Text;
+				createParams.ClassName = "mono_native_window";
+				createParams.X = Top;
+				createParams.Y = Left;
+				createParams.Width = Width;
+				createParams.Height = Height;
+				createParams.ClassStyle = 0;
+				createParams.ExStyle = 0;
+				createParams.Param = 0;
+				
+				if (parent != null)
+					createParams.Parent = parent.Handle;
+				else 
+					createParams.Parent = (IntPtr) 0;
+
+				createParams.Style = (int) Win32.WS_OVERLAPPEDWINDOW;
+
 				return createParams;
 			}
 		}
@@ -943,25 +959,7 @@ namespace System.Windows.Forms {
 		protected virtual void CreateHandle ()
 		{
 			window = new ControlNativeWindow (this);
-			
-			createParams.Caption = Text;
-			createParams.ClassName = "mono_native_window";
-			createParams.X = Top;
-			createParams.Y = Left;
-			createParams.Width = Width;
-			createParams.Height = Height;
-			createParams.ClassStyle = 0;
-			createParams.ExStyle = 0;
-			createParams.Param = 0;
-
-			if (parent != null)
-				createParams.Parent = parent.Handle;
-			else 
-				createParams.Parent = (IntPtr) 0;
-
-			createParams.Style = (int) Win32.WS_OVERLAPPEDWINDOW;
-
-			window.CreateHandle (createParams);
+			window.CreateHandle (CreateParams);
 		}
 	
 		protected virtual void DefWndProc (ref Message m)

+ 17 - 22
mcs/class/System.Windows.Forms/System.Windows.Forms/Label.cs

@@ -20,7 +20,6 @@ namespace System.Windows.Forms {
 	
 	public class Label : Control {
 
-		CreateParams createParams;
 		Image backgroundImage;
 		BorderStyle borderStyle;
 		bool autoSize;
@@ -178,6 +177,23 @@ namespace System.Windows.Forms {
 
 		protected override CreateParams CreateParams {
 			get {
+				CreateParams createParams = new CreateParams ();
+				window = new ControlNativeWindow (this);
+
+				createParams.Caption = Text;
+				createParams.ClassName = "STATIC";
+				createParams.X = Top;
+				createParams.Y = Left;
+				createParams.Width = Width;
+				createParams.Height = Height;
+				createParams.ClassStyle = 0;
+				createParams.ExStyle = 0;
+				createParams.Param = 0;
+				createParams.Parent = Parent.Handle;
+				createParams.Style = (int) (
+					Win32.WS_CHILD | 
+					Win32.WS_VISIBLE | Win32.SS_LEFT );
+				window.CreateHandle (createParams);
 				return createParams;
 			}
 		}
@@ -266,27 +282,6 @@ namespace System.Windows.Forms {
 //  			throw new NotImplementedException ();
 //  		}
 
-		protected override void CreateHandle () 
-		{
-			CreateParams createParams = new CreateParams ();
-			window = new ControlNativeWindow (this);
-
-			createParams.Caption = Text;
-			createParams.ClassName = "STATIC";
-			createParams.X = Top;
-			createParams.Y = Left;
-			createParams.Width = Width;
-			createParams.Height = Height;
-			createParams.ClassStyle = 0;
-			createParams.ExStyle = 0;
-			createParams.Param = 0;
-			createParams.Parent = Parent.Handle;
-			createParams.Style = (int) (
-				Win32.WS_CHILD | 
-				Win32.WS_VISIBLE | Win32.SS_LEFT );
-			window.CreateHandle (createParams);
-		}
-
 		protected new virtual void Dispose()
 		{
 			//throw new NotImplementedException ();

+ 51 - 0
mcs/class/System.Windows.Forms/System.Windows.Forms/README

@@ -0,0 +1,51 @@
+Since a WineLib application is a Windows application that is compiled under 
+Unix/Linux as a shared library it needs to be started differently than other
+applications. The WineLib application is started as any other Windows
+application running under Wine using the wine command. You cannot simply link 
+in libwine (gcc myapp.c -lwine) to use Win32 functions.
+
+In order to use WineLib/Win32 functions under Mono I have created a small
+"stub" application that embeds the Mono engine inside the WineLib application.
+This is basically a replacement for the "mono" command that can be used
+to call the Win32 API (using WineLib) within an application written for Mono.
+
+To get started I suggest installing Wine and Mono first if they are not
+already installed. I am usually using the latest Wine snapshots built from 
+source and installed under /usr/local. Also be sure to build/use a version of 
+Mono with garbage collection disabled as there is a problem using WineLib with 
+garbage collection enabled (check the mono-list archives for this discussion). 
+You can disable garbage collection when building mono by adding --with-gc=none 
+to the configure command. In the mono directory I build mono as:
+     ./configure --with-gc=none
+
+In the WINELib makefile you may have set these to the appropriate files and/or
+paths on your PC: 
+
+X11R6_INCLUDE=/usr/X11R6/include
+WINE_INCLUDE=/usr/local/include/wine
+WINE_LIB=/usr/local/lib/wine
+LIBMONO=/usr/local/lib/libmono.a
+
+If you type make from the mcs/class/System.Windows.Forms/WINELib
+directory it should build: 
+
+System.Windows.Forms.dll - 
+The current (if largely incomplete) Windows Forms package. 
+
+FormTest.exe, NativeWindowTest.exe, Test.exe - 
+Test applications which link to and tests the System.Windows.Forms.dll 
+
+monostub.exe.so - 
+The WineLib application that starts the Mono/WineLib application. This
+small WineLib application embeds the Mono JIT engine allowing any Mono
+application running in it access to WineLib/Win32 function calls. 
+
+Before starting any of the applications set the LD_LIBRARY_PATH to the
+current directory (so DllImport can find the monostub.exe.so library):
+        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
+
+To start any of the applications you type (from the WINELib directory): 
+        wine monostub.exe.so mono-winelibapp.exe 
+
+John Sohn
[email protected]

+ 2 - 5
mcs/class/System.Windows.Forms/System.Windows.Forms/makefile

@@ -108,7 +108,7 @@ monostub.exe.so: monostub.o monostub.exe.spec.o monostub.exe.dbg.o
 	monostub.exe.spec.o \
 	monostub.o monostub.exe.dbg.o -I/usr/local/include \
 	 $(GLIB20_INCUDE) -L/usr/lib \
-	/usr/local/lib/libmono.a  \
+	/usr/local/lib/libmono.a  -lgc \
 	-lwine -lntdll.dll $(GLIB20_LIB) -lm -lpthread 
 
 clean:	
@@ -117,10 +117,7 @@ clean:
 monostub.o: monostub.c
 	gcc -c -I. -I$(WINE_INCLUDE)  $(GLIB20_INCLUDE) -g -O2 -Wall -I$(X11R6_INCLUDE) -D_REENTRANT -DWINELIB -o monostub.o monostub.c
 
-monostart.o: monostart.c
-	gcc -c -I. -g -O2 -Wall -I$(X11R6_INCLUDE) -D_REENTRANT -DWINELIB -o monostart.o monostart.c $(GLIB20_INCLUDE) -I$(WINE_INCLUDE)
-
-monostub.exe.tmp.o: monostub.o monostart.o
+monostub.exe.tmp.o: monostub.o 
 	ld -r  monostub.o -o monostub.exe.tmp.o  
 	strip --strip-unneeded monostub.exe.tmp.o
 

+ 9 - 0
mcs/class/System.Windows.Forms/System.Windows.Forms/ochangelog

@@ -1,3 +1,12 @@
+2002-10-12 John Sohn <[email protected]>
+	* Control.cs: 
+	* Label.cs: changed CreateHandle method to use CreateParams property
+	* README: added instructions for building and using project
+	* makefile: removed monostart.c from makefile
+	* monostart.c:
+	* test.sh
+	* build.sh: no longer used, removed
+	
 2002-9-29  John Sohn <[email protected]>
 	* Form.cs: Site property now calls base class
 	* FormTest.cs: set label position on test form

+ 19 - 21
mcs/class/System.Windows.Forms/WINELib/Control.cs

@@ -75,7 +75,6 @@ namespace System.Windows.Forms {
 		bool tabStop;
 		string text;
 		bool visible;
-		CreateParams createParams;
 
 		// --- Constructors ---
 		public Control ()
@@ -109,7 +108,6 @@ namespace System.Windows.Forms {
 			visible = true;
 			parent = null;
 			window = null;
-			createParams = new CreateParams ();
 		}
 		
 		// according to docs, the constructors do not create 
@@ -421,6 +419,24 @@ namespace System.Windows.Forms {
 		
 		protected virtual CreateParams CreateParams {
 			get {
+				CreateParams createParams = new CreateParams ();
+				createParams.Caption = Text;
+				createParams.ClassName = "mono_native_window";
+				createParams.X = Top;
+				createParams.Y = Left;
+				createParams.Width = Width;
+				createParams.Height = Height;
+				createParams.ClassStyle = 0;
+				createParams.ExStyle = 0;
+				createParams.Param = 0;
+				
+				if (parent != null)
+					createParams.Parent = parent.Handle;
+				else 
+					createParams.Parent = (IntPtr) 0;
+
+				createParams.Style = (int) Win32.WS_OVERLAPPEDWINDOW;
+
 				return createParams;
 			}
 		}
@@ -943,25 +959,7 @@ namespace System.Windows.Forms {
 		protected virtual void CreateHandle ()
 		{
 			window = new ControlNativeWindow (this);
-			
-			createParams.Caption = Text;
-			createParams.ClassName = "mono_native_window";
-			createParams.X = Top;
-			createParams.Y = Left;
-			createParams.Width = Width;
-			createParams.Height = Height;
-			createParams.ClassStyle = 0;
-			createParams.ExStyle = 0;
-			createParams.Param = 0;
-
-			if (parent != null)
-				createParams.Parent = parent.Handle;
-			else 
-				createParams.Parent = (IntPtr) 0;
-
-			createParams.Style = (int) Win32.WS_OVERLAPPEDWINDOW;
-
-			window.CreateHandle (createParams);
+			window.CreateHandle (CreateParams);
 		}
 	
 		protected virtual void DefWndProc (ref Message m)

+ 17 - 22
mcs/class/System.Windows.Forms/WINELib/Label.cs

@@ -20,7 +20,6 @@ namespace System.Windows.Forms {
 	
 	public class Label : Control {
 
-		CreateParams createParams;
 		Image backgroundImage;
 		BorderStyle borderStyle;
 		bool autoSize;
@@ -178,6 +177,23 @@ namespace System.Windows.Forms {
 
 		protected override CreateParams CreateParams {
 			get {
+				CreateParams createParams = new CreateParams ();
+				window = new ControlNativeWindow (this);
+
+				createParams.Caption = Text;
+				createParams.ClassName = "STATIC";
+				createParams.X = Top;
+				createParams.Y = Left;
+				createParams.Width = Width;
+				createParams.Height = Height;
+				createParams.ClassStyle = 0;
+				createParams.ExStyle = 0;
+				createParams.Param = 0;
+				createParams.Parent = Parent.Handle;
+				createParams.Style = (int) (
+					Win32.WS_CHILD | 
+					Win32.WS_VISIBLE | Win32.SS_LEFT );
+				window.CreateHandle (createParams);
 				return createParams;
 			}
 		}
@@ -266,27 +282,6 @@ namespace System.Windows.Forms {
 //  			throw new NotImplementedException ();
 //  		}
 
-		protected override void CreateHandle () 
-		{
-			CreateParams createParams = new CreateParams ();
-			window = new ControlNativeWindow (this);
-
-			createParams.Caption = Text;
-			createParams.ClassName = "STATIC";
-			createParams.X = Top;
-			createParams.Y = Left;
-			createParams.Width = Width;
-			createParams.Height = Height;
-			createParams.ClassStyle = 0;
-			createParams.ExStyle = 0;
-			createParams.Param = 0;
-			createParams.Parent = Parent.Handle;
-			createParams.Style = (int) (
-				Win32.WS_CHILD | 
-				Win32.WS_VISIBLE | Win32.SS_LEFT );
-			window.CreateHandle (createParams);
-		}
-
 		protected new virtual void Dispose()
 		{
 			//throw new NotImplementedException ();

+ 51 - 0
mcs/class/System.Windows.Forms/WINELib/README

@@ -0,0 +1,51 @@
+Since a WineLib application is a Windows application that is compiled under 
+Unix/Linux as a shared library it needs to be started differently than other
+applications. The WineLib application is started as any other Windows
+application running under Wine using the wine command. You cannot simply link 
+in libwine (gcc myapp.c -lwine) to use Win32 functions.
+
+In order to use WineLib/Win32 functions under Mono I have created a small
+"stub" application that embeds the Mono engine inside the WineLib application.
+This is basically a replacement for the "mono" command that can be used
+to call the Win32 API (using WineLib) within an application written for Mono.
+
+To get started I suggest installing Wine and Mono first if they are not
+already installed. I am usually using the latest Wine snapshots built from 
+source and installed under /usr/local. Also be sure to build/use a version of 
+Mono with garbage collection disabled as there is a problem using WineLib with 
+garbage collection enabled (check the mono-list archives for this discussion). 
+You can disable garbage collection when building mono by adding --with-gc=none 
+to the configure command. In the mono directory I build mono as:
+     ./configure --with-gc=none
+
+In the WINELib makefile you may have set these to the appropriate files and/or
+paths on your PC: 
+
+X11R6_INCLUDE=/usr/X11R6/include
+WINE_INCLUDE=/usr/local/include/wine
+WINE_LIB=/usr/local/lib/wine
+LIBMONO=/usr/local/lib/libmono.a
+
+If you type make from the mcs/class/System.Windows.Forms/WINELib
+directory it should build: 
+
+System.Windows.Forms.dll - 
+The current (if largely incomplete) Windows Forms package. 
+
+FormTest.exe, NativeWindowTest.exe, Test.exe - 
+Test applications which link to and tests the System.Windows.Forms.dll 
+
+monostub.exe.so - 
+The WineLib application that starts the Mono/WineLib application. This
+small WineLib application embeds the Mono JIT engine allowing any Mono
+application running in it access to WineLib/Win32 function calls. 
+
+Before starting any of the applications set the LD_LIBRARY_PATH to the
+current directory (so DllImport can find the monostub.exe.so library):
+        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
+
+To start any of the applications you type (from the WINELib directory): 
+        wine monostub.exe.so mono-winelibapp.exe 
+
+John Sohn
[email protected]

+ 0 - 42
mcs/class/System.Windows.Forms/WINELib/build.sh

@@ -1,42 +0,0 @@
-# OBSOLETE!!!! NOW USING MAKEFILE
-# this file builds the stub wine application that loads a mono application
-# calling WINELib functions
-# 
-# 
-#
-X11R6_INCLUDE=/usr/X11R6/include
-WINE_INCLUDE=/usr/local/include/wine
-WINE_LIB=/usr/local/lib/wine
-GLIB20_INCLUDE=/usr/include/glib-2.0
-GLIB20_LIB_INCLUDE=/usr/lib/glib-2.0/include
-LIBMONO=/usr/local/lib/libmono.a
-
-# The Mono 0.13 build used at the time this code was written is missing
-# some object code in the static libs. Due to conflicts between functions
-# in the shared libs of Mono and Wine this stub at this point it seems
-# we will need to statically link the embedded Mono engine.
-#
-# These are the two object files are missing in the libmono.a so link these 
-# in also:
-LIBMETADATA=/home/john/mono-src/mono-0.13/mono/metadata/.libs/libmetadata.al 
-LIBMONORUNTIME=/home/john/mono-src/mono-0.13/mono/metadata/.libs/libmonoruntime.al
-
-gcc -c -I. -I$WINE_INCLUDE  -g -O2 -Wall -I$X11R6_INCLUDE -o monostub.o monostub.c
-
-gcc -c -I. -g -O2 -Wall -I$X11R6_INCLUDE $I-o monostart.o monostart.c -I$GLIB20_INCLUDE -I$GLIB20_LIB_INCLUDE -I$WINE_INCLUDE
-
-ld -r  monostub.o -o monostub.exe.tmp.o  
-
-strip --strip-unneeded monostub.exe.tmp.o
-
-winebuild -sym monostub.exe.tmp.o -o monostub.exe.spec.c -exe monostub.exe -mgui -L$WINE_LIB  -lcomdlg32 -lshell32 -luser32 -lgdi32 -lkernel32
-
-gcc -c -I. -I. -I$WINE_INCLUDE -g -O2 -I$X11R6_INCLUDE -o monostub.exe.spec.o monostub.exe.spec.c
-
-winebuild -o monostub.exe.dbg.c -debug -C. monostub.c
-
-gcc -c -I. -I. -I$WINE_INCLUDE  -g -O2 -I$X11R6_INCLUDE -o monostub.exe.dbg.o monostub.exe.dbg.c
-
-gcc -shared -Wl,-Bsymbolic -o monostub.exe.so monostub.exe.spec.o monostub.o monostart.o -L$WINE_LIB -L/usr/lib -L. -lm -L/usr/local/lib -lglib-2.0 -L/usr/lib -lmono -lgc -lnsl -lrt -lgd -lgmodule-2.0  -lwine
-
-gcc -shared -Wl,-Bsymbolic -o monostub.exe.so monostub.exe.spec.o monostub.o monostart.o -I/usr/local/include -I -I$GLIB20_INCUDE -I$GLIB20_LIB_INCLUDE -L/usr/lib $LIBMONO -lwine -lntdll.dll -lglib-2.0 -lgmodule-2.0 -lm $LIBMETADATA $LIBMONORUNTIME

+ 9 - 0
mcs/class/System.Windows.Forms/WINELib/changelog

@@ -1,3 +1,12 @@
+2002-10-12 John Sohn <[email protected]>
+	* Control.cs: 
+	* Label.cs: changed CreateHandle method to use CreateParams property
+	* README: added instructions for building and using project
+	* makefile: removed monostart.c from makefile
+	* monostart.c:
+	* test.sh
+	* build.sh: no longer used, removed
+	
 2002-9-29  John Sohn <[email protected]>
 	* Form.cs: Site property now calls base class
 	* FormTest.cs: set label position on test form

+ 2 - 5
mcs/class/System.Windows.Forms/WINELib/makefile

@@ -108,7 +108,7 @@ monostub.exe.so: monostub.o monostub.exe.spec.o monostub.exe.dbg.o
 	monostub.exe.spec.o \
 	monostub.o monostub.exe.dbg.o -I/usr/local/include \
 	 $(GLIB20_INCUDE) -L/usr/lib \
-	/usr/local/lib/libmono.a  \
+	/usr/local/lib/libmono.a  -lgc \
 	-lwine -lntdll.dll $(GLIB20_LIB) -lm -lpthread 
 
 clean:	
@@ -117,10 +117,7 @@ clean:
 monostub.o: monostub.c
 	gcc -c -I. -I$(WINE_INCLUDE)  $(GLIB20_INCLUDE) -g -O2 -Wall -I$(X11R6_INCLUDE) -D_REENTRANT -DWINELIB -o monostub.o monostub.c
 
-monostart.o: monostart.c
-	gcc -c -I. -g -O2 -Wall -I$(X11R6_INCLUDE) -D_REENTRANT -DWINELIB -o monostart.o monostart.c $(GLIB20_INCLUDE) -I$(WINE_INCLUDE)
-
-monostub.exe.tmp.o: monostub.o monostart.o
+monostub.exe.tmp.o: monostub.o 
 	ld -r  monostub.o -o monostub.exe.tmp.o  
 	strip --strip-unneeded monostub.exe.tmp.o
 

+ 0 - 76
mcs/class/System.Windows.Forms/WINELib/monostart.c

@@ -1,76 +0,0 @@
-#include <mono/jit/jit.h>
-#include <mono/metadata/debug-helpers.h>
-#include <stdio.h>
-
-static unsigned int application_instance;
-MonoMethod *wndproc_method = NULL;
-
-// wrapped in the Mono class, enables the embedded application
-// to get the HINSTANCE
-int GetInstance()
-{
-	return application_instance;
-}
-
-// WndProc for registered class, calls embeded Mono WndProc function
-unsigned long __attribute__((__stdcall__)) WndProc(unsigned int hWnd, unsigned int msg, unsigned int wParam, long lParam)
-{
-	MonoObject *return_object = NULL;
-	gpointer params[4];
-
-	printf("WndProc begin\n");
-
-	params[0] = &hWnd;
-	params[1] = &msg;
-	params[2] = &wParam;
-	params[3] = &lParam;
-
-	return_object = mono_runtime_invoke(wndproc_method, NULL, params, NULL);
-	printf("WndProc end\n");
-
-	return (long) &return_object->vtable;
-}
-
-// uses Mono embedding API to execute application
-int mono_start(unsigned int hInstance, unsigned int hPrevInstance, char* lpszCmdLine, int nCmdShow)
-{
-	MonoDomain *domain = NULL;
-	MonoAssembly *assembly = NULL;
-	MonoMethodDesc* desc = NULL;
-	MonoImage *image = NULL;
-  
-	application_instance = hInstance;
-
-      	printf("initializing JIT engine\n");	
-	domain = mono_jit_init(lpszCmdLine);
-
-	// helper to allow embedded application to get the HINSTANCE
-	// (not sure if we need this in the latest Win32 API's)
-	//printf("adding internal calls\n");
-	//mono_add_internal_call ("Application::GetInstance", 
-	//			GetInstance);
-
-	printf("opening assembly\n");
-	assembly = mono_domain_assembly_open (domain, lpszCmdLine);
-
-	// setup WNDPROC method in embedded application
-	desc = mono_method_desc_new ("System.Windows.Forms.Application:_ApplicationWndProc", TRUE);
-	printf("finding method(s)\n");
-	image = mono_image_loaded ("System.Windows.Forms");
-
-	if (image && desc)
-	  wndproc_method = mono_method_desc_search_in_image (desc, image);
-
-	if (!wndproc_method) {
-	  printf("error: Application:_ApplicationWndProc not found\n");
-	  return 1;
-	}
-
-	printf("executing assembly\n");
-	mono_jit_exec(domain, assembly, 0, 0);
-	
-	printf("calling JIT cleanup\n");
-	mono_jit_cleanup(domain);
-
-	return 0;
-}

+ 0 - 1
mcs/class/System.Windows.Forms/WINELib/test.sh

@@ -1 +0,0 @@
-# wine monostub.exe.so Window.exe