17 October 2008, 11:17 PM

When creating custom design in C# you want to move your application these codes will enable the whole application or just the outsides to move.

using Microsoft.Win32;
using System.Runtime.InteropServices;

On Form1 add this code


public Form1()
        {
            InitializeComponent();
        }
            public const int WM_NCLBUTTONDOWN = 0xA1;
            public const int HT_CAPTION = 0x2;

            [DllImportAttribute("user32.dll")]
            public static extern int SendMessage(IntPtr hWnd,
                int Msg, int wParam, int lParam);

            [DllImportAttribute("user32.dll")]
            public static extern bool ReleaseCapture();

        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }



Or if you wish to apply it to move by an object only add

private void Object_MouseDown(object sender, MouseEventArgs e)
       {
            if (e.Button == MouseButtons.Left)
            {
                ReleaseCapture();
                SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);
            }
        }




We have a large portfolio of work we have completed for clients. Our portfolio always carries our current new iPhone applications. Take a look

Follow us on Twitter, We aim to provide Live Information - @olliekett
 

© OKD Limited 2010 | Contact Us
OKD Limited is a private registered company in England and Wales.
 
Ollie Kett Designs - Tracking System