Click here to Skip to main content
15,885,835 members
Articles / Multimedia / GDI+

Customizable Tree Control with Animation Support

Rate me:
Please Sign up or sign in to vote.
4.72/5 (17 votes)
8 Apr 2008CPOL4 min read 107.7K   23   115  
A tree control implementation, allowing complete customization and animation support
/////////////////////////////////////////////////////////////////////////////
//
// (c) 2007 BinaryComponents Ltd.  All Rights Reserved.
//
// http://www.binarycomponents.com/
//
/////////////////////////////////////////////////////////////////////////////

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace BinaryComponents.Utility.Win32
{
	[CLSCompliant( false )]
	public static class User
	{
		[Flags]
		public enum DrawTextFlags : uint
		{
			DT_TOP = 0x0,
			DT_LEFT = 0x0,
			DT_CENTER = 0x1,
			DT_RIGHT = 0x2,
			DT_VCENTER = 0x4,
			DT_BOTTOM = 0x8,
			DT_WORDBREAK = 0x10,
			DT_SINGLELINE = 0x20,
			DT_EXPANDTABS = 0x40,
			DT_TABSTOP = 0x80,
			DT_NOCLIP = 0x100,
			DT_EXTERNALLEADING = 0x200,
			DT_CALCRECT = 0x400,
			DT_NOPREFIX = 0x800,
			DT_INTERNAL = 0x1000,
			DT_EDITCONTROL = 0x2000,
			DT_PATH_ELLIPSIS = 0x4000,
			DT_END_ELLIPSIS = 0x8000,
			DT_MODIFYSTRING = 0x10000,
			DT_RTLREADING = 0x20000,
			DT_WORD_ELLIPSIS = 0x40000,
			DT_NOFULLWIDTHCHARBREAK = 0x80000,
			DT_HIDEPREFIX = 0x100000,
			DT_PREFIXONLY = 0x200000
		}

		[DllImport( "user32.dll", CharSet = CharSet.Auto )]
		public extern static bool DestroyIcon( IntPtr handle );

		[DllImport( "user32.dll", CharSet = CharSet.Auto )]
		public extern static int DrawText( IntPtr hDC, string lpString, int nCount, ref Common.RECT lpRect, DrawTextFlags uFormat );

		[DllImport( "user32.dll" )]
		public static extern int DrawTextEx( IntPtr hdc, StringBuilder lpchText, int cchText, ref Common.RECT lprc, Win32.User.DrawTextFlags dwDTFormat, ref DRAWTEXTPARAMS lpDTParams );
		[DllImport( "user32.dll" )]
		public static extern int DrawTextEx( IntPtr hdc, StringBuilder lpchText, int cchText, ref Common.RECT lprc, Win32.User.DrawTextFlags dwDTFormat, IntPtr lpDTParams );

		[DllImport( "user32.dll" )]
		public extern static IntPtr SetActiveWindow( IntPtr handle );

		[DllImport( "user32.dll" )]
		public static extern uint RegisterWindowMessage( string lpString );

		[DllImport( "user32.dll" )]
		public static extern int SendMessage( IntPtr hwnd, Messages wMsg, IntPtr wParam, IntPtr lParam );

		[DllImport( "user32.dll", ExactSpelling = true, SetLastError = true )]
		public static extern bool UpdateLayeredWindow( IntPtr hwnd, IntPtr hdcDst, ref Common.POINT pptDst, ref Common.SIZE psize, IntPtr hdcSrc, ref Common.POINT pprSrc, Int32 crKey, ref BLENDFUNCTION pblend, Int32 dwFlags );

		[DllImport( "user32.dll", ExactSpelling = true, SetLastError = true )]
		public static extern IntPtr GetDC( IntPtr hWnd );

		[DllImport( "user32.dll" )]
		public static extern void DisableProcessWindowsGhosting();

		[DllImport( "user32.dll" )]
		public static extern IntPtr GetDCEx( IntPtr hwnd, IntPtr hrgnclip, uint fdwOptions );

        [DllImport("user32.dll")]
        public static extern IntPtr GetWindowDC( IntPtr hwnd );

		[DllImport( "user32.dll" )]
		public static extern Int32 SetWindowPos( IntPtr hWnd, IntPtr hWndAfter, Int32 x, Int32 y, Int32 cx, Int32 cy, UInt32 uFlags );

		[DllImport( "user32.dll" )]
		public static extern bool RedrawWindow( IntPtr hWnd, IntPtr rectUpdate, IntPtr hrgnUpdate, RedrawWindowOptions flags );

		[DllImport( "user32.dll" )]
		public static extern bool RedrawWindow( IntPtr hWnd, ref Common.RECT rectUpdate, IntPtr hrgnUpdate, RedrawWindowOptions flags );

		[DllImport( "user32.dll" )]
		public static extern bool PeekMessage( ref System.Windows.Forms.Message msg, IntPtr hwnd, int msgMin, int msgMax, int remove );

		[DllImport( "user32.dll" )]
		public static extern bool SetLayeredWindowAttributes( IntPtr hwnd, uint crKey, byte bAlpha, uint dwFlags );

		[DllImport( "user32.dll", SetLastError = true )]
		public static extern bool PostMessage( IntPtr hWnd, Utility.Win32.Messages Msg, IntPtr wParam, IntPtr lParam );

		[DllImport( "user32.dll" )]
		public static extern uint SendInput( uint nInputs, INPUT[] pInputs, int cbSize );

		[DllImport( "user32.dll" )]
		public static extern IntPtr GetMessageExtraInfo();

		[DllImport( "user32.dll" )]
		public static extern bool SetWindowPos( IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, SetWindowPosOptions uFlags );

		[DllImport( "user32.dll" )]
		public static extern int ShowWindow( IntPtr hWnd, ShowWindowOptions nCmdShow );

		[DllImport( "user32.dll" )]
		public static extern bool GetWindowPlacement( IntPtr hWnd, ref WINDOWPLACEMENT lpwndpl );

		[DllImport( "user32.dll" )]
		public static extern bool GetClientRect( IntPtr hWnd, out Common.RECT lpRect );

		[DllImport( "user32.dll" )]
		public static extern bool GetWindowRect( IntPtr hWnd, out Common.RECT lpRect );

		[DllImport( "user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.Winapi )]
		public static extern IntPtr GetFocus(); 
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United Kingdom United Kingdom
I'm currently working for a small start-up company, BinaryComponents Ltd, producing the FeedGhost RSS reader.

FeedGhost RSS Reader:
http://www.feedghost.com

Bespoke Software Development
http://www.binarycomponents.com

Comments and Discussions