[ Zevs85 @ 12.10.2006. 20:29 ] @
Pozdrav

Imam formu za koju sam kao FormBorderStyle izabrao none, sta treba da uradim da bih klikom ne neki label (ili sta je vec potrebno za to) mogao da pomeram prozor?

hvala
[ Zevs85 @ 12.10.2006. 23:03 ] @
Mozda nekom zatreba...
Code:
Two ways. First:

//API functions to move the form
public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2;
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);

And in your mouse down event of the form:

public void Form1_MouseDown(object sender, MouseEventArgs e)
{
//If the left mouse is pressed, release form for movement
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}

 

Second:

protected override void WndProc(ref Message m)
{
            base.WndProc(ref m);

            int WM_NCHITTEST = 0x84;
            if (m.Msg == WM_NCHITTEST)
            {
                int HTCLIENT = 1;
                int HTCAPTION = 2;
                if (m.Result.ToInt32() == HTCLIENT)
                    m.Result = (IntPtr)HTCAPTION;
            }
}

Preuzeto sa: http://forums.microsoft.com/MS...spx?PostID=754166&SiteID=1
Primer: http://www.codeproject.com/csharp/csharpmovewindow.asp