[Mono-devel-list] System.Windows.Froms on win32 platform

Aleksandar Dezelin dezelin32 at fastmail.fm
Wed Sep 29 03:40:20 EDT 2004


Hi,

I'm just curious, does Mono use Wine to emulate System.Windows.Forms on
win32? Is it possible to run a SWF application  under Mono on win32?
When I try to run it I get the following exception dump:

Unhandled Exception: System.ArgumentException: Invalid Parameter. A null
referen
ce or invalid value was found.
in <0x00073> System.Drawing.GDIPlus:CheckStatus (System.Drawing.Status)
in <0x00182> System.Drawing.Font:FromHfont (intptr)
in <0x00015> System.Windows.Forms.Control:get_DefaultFont ()
in <0x001af> System.Windows.Forms.Control:.ctor ()
in <0x00010> System.Windows.Forms.ScrollableControl:.ctor ()
in <0x00012> System.Windows.Forms.ContainerControl:.ctor ()
in <0x00016> System.Windows.Forms.Form:.ctor ()
in <0x0006c> Informatika.Infos.Foundation.WinClient.WinClientHost:.ctor
()
in <0x0004c> (wrapper remoting-invoke-with-check)
Informatika.Infos.Foundation.W
inClient.WinClientHost:.ctor ()
in <0x0001b> Informatika.Infos.Foundation.WinClient.WinClientHost:Main
()



I think I've found figured it out. This is the problematic method:

System\Drawing\Font.cs:

		public static Font FromHfont (IntPtr Hfont)
		{
			OperatingSystem	osInfo = Environment.OSVersion;
			IntPtr			newObject;
			IntPtr			hdc;
			IntPtr			oldFont;
			FontStyle		newStyle = FontStyle.Regular;
			float			newSize;
			LOGFONTA		lf = new LOGFONTA ();

			// Sanity. Should we throw an exception?
			if (Hfont == IntPtr.Zero) {
				Font result = new Font ("Arial", (float)10.0, FontStyle.Regular);
				return(result);
			}

Why internal method
Environment.Platform returns 128
as a PlatformID on Win32? 
OS isn't Unix!
-------------------->   if ((int) osInfo.Platform == 128) {
			// If we're on Unix we use our private gdiplus API to avoid Wine 
			// dependencies in S.D

				lock (typeof (Font))
				{
					Status s = GDIPlus.GdipCreateFontFromHfont (Hfont, out newObject, ref lf);
					GDIPlus.CheckStatus (s);
				}
			} else {

				// This needs testing
				// GetDC, SelectObject, ReleaseDC GetTextMetric and
				// GetFontFace are not really GDIPlus, see gdipFunctions.cs

				newStyle = FontStyle.Regular;

				lock (typeof (Font))
				{
					hdc = GDIPlus.GetDC (IntPtr.Zero);
					Font f = FromLogFont (lf, hdc);
					GDIPlus.ReleaseDC (hdc);
					return f;
				}
			}
...


Thanks in advance
Aleksandar Dezelin
-- 
  Aleksandar Dezelin
  dezelin32 at fastmail.fm




More information about the Mono-devel-list mailing list