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 = new Gdk.Pixmap(w.GdkWindow,w.Allocation.width,w.Allocation.height,-1);
My intention with the code below was to draw on a pixmap, and then to display the
pixmap in
a scrolled window. Eventually, I want to keep a list of pixmaps and display the one I
need
in the scrolled window based on certain events.
The Gtk# chapter 22 in the Gtk Manual deals with it, but unfortunately, the chapter is
not
written yet in the mono handbook, so I consulted the original manual for C, but maybe
I
misunderstood something- therefore I list my code below.
I use Gtk# 0.8 for Windows[gtk-sharp-0.8-win32-2.exe], and Windows XP.
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=null;
public static int Main(string[] args)
{
Application.Init();
Gtk.Window win = new Gtk.Window ("ScrollBox With Picture");
win.DeleteEvent += new DeleteEventHandler(Window_Delete);
Gtk.ScrolledWindow scrolled_window = new Gtk.ScrolledWindow
(new Adjustment (IntPtr.Zero), new Adjustment (IntPtr.Zero));
Gtk.DrawingArea dc = new Gtk.DrawingArea();
dc.SetSizeRequest(80,160);
scrolled_window.AddWithViewport(dc);
dc.Show();
scrolled_window.SetPolicy (PolicyType.Automatic,
PolicyType.Automatic);
win.Add (scrolled_window);
win.ShowAll ();
//This is where my code fails
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pixmap = new
Gdk.Pixmap(w.GdkWindow,w.Allocation.width,w.Allocation.height,-1);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pixmap.DrawRectangle(w.Style.WhiteGC,1,10,10,100,100);
Application.Run ();
return 0;
}
static void Window_Delete(object obj, GtkSharp.DeleteEventArgs args)
{
SignalArgs sa = (SignalArgs) args;
Application.Quit();
sa.RetVal = true;
}
}
}
_______________________________________________
Mono-list maillist - [EMAIL PROTECTED]
http://lists.ximian.com/mailman/listinfo/mono-list