HD2 Multi-
Touch
Library
HD2 / Leo Multitouch .NET CF DLL

SciLor's HD2 / Leo Multitouch .NET CF DLL

v0.2

Write your own apps with multitouch for your HTC HD2

Support us


PayPal

Flattr

Bitcoin


Send bitcoins to: 19nKUQzjtKjEWe5d7yRLPCpK9SLXM76p9B
SciLor's .NET CF MultiTouch DLL v0.1 adds MultiTouch-Support to your existing .NET CF software very easily (Currently only for the HD2):
If I release a new DLL, it WILL be fully compatible to the previous one!


First of all you will have to add your app to the PinchToZoom Whitelist in the registry:
		[HKEY_LOCAL_MACHINE\Software\HTC\TouchGL\Pinch\WhiteList\YourApp]
		"ProcName"="YouAppProcessName.exe"
		
After adding, soft reset!

Then add the "SciLors-MultiTouch.dll" as reference in your Visual Studio project. Beware, it is not allowed to change the assembly name! It must stay "SciLors-MultiTouch.dll" or it will not work!

Afterwards declare the MultiTouch Class:
VB.NET:
		Dim myMultiTouch As New SciLorsMultiTouch.SciLorsMultiTouch
		

C#:
		SciLorsMultiTouch.SciLorsMultiTouch myMultiTouch = new SciLorsMultiTouch.SciLorsMultiTouch();
		

Then you add following to your Form_Load event:
VB.NET:
		Call myMultiTouch.CatchWndProc(Me)
		AddHandler myMultiTouch.MouseDown, AddressOf frmMain_MouseDown
		AddHandler myMultiTouch.MouseMove, AddressOf frmMain_MouseMove
		AddHandler myMultiTouch.MouseUp, AddressOf frmMain_MouseUp
		

C#:
		myMultiTouch.CatchWndProc(this);
		myMultiTouch.MouseDown += frmMain_MouseDown;
		myMultiTouch.MouseMove += frmMain_MouseMove;
		myMultiTouch.MouseUp += frmMain_MouseUp;
		

Now, at every MultiTouch Event it gets delegated to your frmMain_Mouse* procedures (There will be always 2 Events fired due to there existing 2 Fingers on the screen ;) ). You can easily detect wheather the mouse event comes from a normal mouse-press or a multitouch finger.
		Single Finger:
			Windows.Forms.MouseButtons.None or MouseButton = Windows.Forms.MouseButtons.Left
		MultiTouch:
			Finger 1: Windows.Forms.MouseButtons.Middle
			Finger 2: Windows.Forms.MouseButtons.Right
		

Code Examples:
VB.NET:
		Public Structure MouseState
			Dim Position As Point
			Dim MouseDown As Boolean
		End Structure

		Public Fingers(2) As MouseState

		Public Sub frmMain_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseDown
			Dim ButtonID As Byte = ButtonToID(e.Button)
			With Fingers(ButtonID)
				.Position.X = e.X
				.Position.Y = e.Y
				.MouseDown = True
			End With
		End Sub

		Public Sub frmMain_MouseMoveByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseMove
			Dim ButtonID As Byte = ButtonToID(e.Button)
			With Fingers(ButtonID)
				.Position.X = e.X
				.Position.Y = e.Y
				.MouseDown = True
			End With
		End Sub

		Public Sub frmMain_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles frmMain.MouseUp
			Dim ButtonID As Byte = ButtonToID(e.Button)
			With Fingers(ButtonID)
				.Position.X = e.X
				.Position.Y = e.Y
				.MouseDown = False
			End With
		End Sub

		Private Function ButtonToID(ByVal MouseButton As MouseButtons)
			If MouseButton = Windows.Forms.MouseButtons.None Or MouseButton = Windows.Forms.MouseButtons.Left Then
				Return 0
			ElseIf MouseButton = Windows.Forms.MouseButtons.Middle Then
				Return 1
			Else
				Return 2
			End If
		End Function
		

C#:
		public struct MouseState
		{
			public Point Position;
			public bool MouseDown;
		}
		public MouseState[] Fingers = new MouseState[3];

		public void pctDraw_MouseDown(object sender, MouseEventArgs e)
		{
			int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));
			this.Fingers[ButtonID].Position.X = e.X;
			this.Fingers[ButtonID].Position.Y = e.Y;
			this.Fingers[ButtonID].MouseDown = true;
		}

		public void pctDraw_MouseMove(object sender, MouseEventArgs e)
		{
			int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));
			this.Fingers[ButtonID].Position.X = e.X;
			this.Fingers[ButtonID].Position.Y = e.Y;
			this.Fingers[ButtonID].MouseDown = true;
		}

		public void pctDraw_MouseUp(object sender, MouseEventArgs e)
		{
			int ButtonID = Conversions.ToByte(this.ButtonToID(e.Button));
			this.Fingers[ButtonID].Position.X = e.X;
			this.Fingers[ButtonID].Position.Y = e.Y;
			this.Fingers[ButtonID].MouseDown = false;
		}

		private object ButtonToID(MouseButtons MouseButton)
		{
			if ((MouseButton == MouseButtons.None) | (MouseButton == MouseButtons.Left))
			{
				return 0;
			}
			if (MouseButton == MouseButtons.Middle)
			{
				return 1;
			}
			return 2;
		}
		


Function Description/Documentation:
-CatchWndProc(myForm, Optional PositionFixX, Optional PositionFixY): Redirects the Windows Messages from the "myForm" to the Multitouch Class. If you want to use it for a Control on top of the Form, the PositionFix can add/remove constant values to the returned MouseMessages.
-RestoreWndProc(): Detaches the Multitouch Class from the Form to restore the normal Window Message flow.
-UpdatePositionFix(PositionFixX, PositionFixY): If your control has changed it's position you can change its position in the class
-UpdateFormTopLeft(PositionFixLeft, PositionFixTop): If the Top-Left Corner of the Form changes you may use this.
-GetInformation(): Gives a Information String of the Multitouch DLL. It includes the version and some contact information.


-Multiple Instances per Form are not supported and not needed (Multitouch events fire allways, everywhere on the form)!
-The Mouse-Coordinates are allways relative to the forms top-left corner.
v0.2 (2010-02-15)
-Enhancement: Added "UpdatePositionFix"/"UpdateForm" and "RestoreWndProc"
-Enhancement: Added some Documentation

-----------------------

v0.1 (2009-12-07)
-Initial Release

HTC HD2 using MultiTouch screen with "SciLors-MultiTouch.dll" by nico331977

v0.2

ZIP

Mirror

Older Versions

v0.1

ZIP

Mirror

CONNECT WITH US