[Mono-list] Gtk# problem

Willem J.W. Semmelink willems@digicore.co.za
Fri, 15 Aug 2003 09:10:01 +0200

Hi everyone

I cannot get the Gdk.Pixmap constructor to work. My app gets a run-time =
exception that the
GdkWindow parameter is null at the line
pixmap =3D new =

My intention with the code below was to draw on a pixmap, and then to =
display the pixmap in=20
a scrolled window. Eventually, I want to keep a list of pixmaps and =
display the one I need=20
in the scrolled window based on certain events.=20

The Gtk# chapter 22 in the Gtk Manual deals with it, but unfortunately, =
the chapter is not=20
written yet in the mono handbook, so I consulted the original manual for =
C, but maybe I=20
misunderstood something- therefore I list my code below.=20

I use Gtk# 0.8 for Windows[gtk-sharp-0.8-win32-2.exe], and Windows XP.=20
I used the Ms csc compiler when I got the error.

Any help appreciated.

using Gtk;
using GtkSharp;
using System;

namespace Test
	class Demo
		static Gdk.Pixmap pixmap=3Dnull;
		public static int Main(string[] args)
			Gtk.Window win =3D new Gtk.Window ("ScrollBox With Picture");
			win.DeleteEvent +=3D new DeleteEventHandler(Window_Delete);
			Gtk.ScrolledWindow scrolled_window =3D new Gtk.ScrolledWindow (new =
Adjustment (IntPtr.Zero), new Adjustment (IntPtr.Zero));
			Gtk.DrawingArea dc =3D new Gtk.DrawingArea();
			scrolled_window.AddWithViewport(dc);	=09
			dc.Show();					=09

			scrolled_window.SetPolicy (PolicyType.Automatic, =
			win.Add (scrolled_window);
			win.ShowAll ();

			//This is where my code fails =
			pixmap =3D new =

			Application.Run ();
			return 0;

		static void Window_Delete(object obj, GtkSharp.DeleteEventArgs args)
			SignalArgs sa =3D (SignalArgs) args;
			sa.RetVal =3D true;
		}	=09