here I create a DLL, and then call it from a separate console application:
namespace Project3
{
using System;
public class ClassObj1XXX
{
public static string MyToLower(string sz)
{
return sz.ToLower();
}
}
}
//#define DEBUG
using System;
using Project3;
public class Class1
{
#if DEBUG
public static int Main(string[] args)
{
Console.WriteLine("Hello Debug.");
return 0;
}
#else
public static int Main(string[] args)
{
Console.WriteLine(ClassObj1XXX.MyToLower("Hello Release."));
return 0;
}
#endif
}
All I need to do is to place the dll in the same directory as the exe. No
other registration is required!
Here I get dirty and call my old friends Sleep, MessageBox and InvalidateRect!
InvalidateRect uses a pointer!
[sysimport(dll="user32", name = "MessageBox")]
public static extern int MyBox(int h, string m, string c, int i);
[sysimport(dll="user32", name = "InvalidateRect")]
public static extern bool MyInvalidate(int h, int pr, bool b);
[sysimport(dll="kernel32", name = "Sleep")]
public static extern void MySleep(uint t);
int[] MyRect = {50, 50, 400, 400};
protected void DoClick(object sender, System.EventArgs e)
{
int i = MyBox(0, "Hello", "C#", 0);
System.Type t = button1.WindowTarget.GetType();
System.WinForms.NativeWindow n = (NativeWindow)button1.WindowTarget;
MySleep(2000);
unsafe
{
fixed(int* pRect = MyRect)
MyInvalidate(n.Handle, (int)pRect, true);
}
}

protected void OnScroll(object sender, System.EventArgs e)
{
this.Invalidate();
}
protected void OnScroll2(object sender, System.EventArgs e)
{
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs pe)
{
Graphics g = pe.Graphics;
Color foreColor = Color.White;
Color backColor = Color.Black;
Font font = new Font("Times New Roman", 20);
// place a white background
g.FillRectangle(new SolidBrush(Color.White), ClientRectangle);
g.FillRectangle(new SolidBrush(Color.FromARGB(trackBar1.Value* 4, Color.Green)), 10, 10, 500, 500);
g.DrawString("Hello Indica", font, new SolidBrush(foreColor), 250, 100);
g.DrawString((trackBar1.Value * 4).ToString(), font, new SolidBrush(foreColor), 250, 120);
g.FillRectangle(new SolidBrush(Color.Red), 200, 200, 100, 100);
g.FillRectangle(new SolidBrush(Color.FromARGB(trackBar2.Value* 4, Color.Yellow)), 250, 250, 100, 100);
}
Photos Journal
Nick's initial Agenda
Nick's first C# program
Nick's notes about C#
Andrew's comments on the PDC
Microsoft PDC site
January 2002, and Nick uses C# to write a real application!