Формы, которые не имеет рамку, отдаленно напоминают плитки в Windows 8. Но их нельзя перемещать. Попробуем это изменить. Сделаем так, что бы кликнув на форме левой кнопкой мыши ее можно было перемещать.
Form1.cs
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0013 {-
publicpartialclassForm1 : Form { -
publicForm1() { -
InitializeComponent(); -
//убираем рамку -
this.FormBorderStyle = FormBorderStyle.None; -
//изменяем цвет -
this.BackColor = Color.FromArgb(59, 169, 222); -
button1.BackColor = Color.FromArgb(99, 219, 252); -
} -
//создание констант -
privateconstintWM_NCHITTEST=0x84; -
privateconstintHTCLIENT=0x1; -
privateconstintHTCAPTION=0x2; -
//переопределяем метод -
protectedoverridevoidWndProc(refMessage m) { -
switch(m.Msg) { -
caseWM_NCHITTEST: -
base.WndProc(refm); -
if( (int)m.Result==HTCLIENT ) { -
m.Result=(IntPtr)HTCAPTION; -
return; -
} -
break; -
} -
base.WndProc(refm); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
Application.Exit(); -
} -
} }
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespace_0013 {-
publicpartialclassForm1 : Form { -
publicForm1() { -
InitializeComponent(); -
//убираем рамку -
this.FormBorderStyle = FormBorderStyle.None; -
//изменяем цвет -
this.BackColor = Color.FromArgb(59, 169, 222); -
button1.BackColor = Color.FromArgb(99, 219, 252); -
} -
//создание констант -
privateconstintWM_NCHITTEST=0x84; -
privateconstintHTCLIENT=0x1; -
privateconstintHTCAPTION=0x2; -
//переопределяем метод -
protectedoverridevoidWndProc(refMessage m) { -
switch(m.Msg) { -
caseWM_NCHITTEST: -
base.WndProc(refm); -
if( (int)m.Result==HTCLIENT ) { -
m.Result=(IntPtr)HTCAPTION; -
return; -
} -
break; -
} -
base.WndProc(refm); -
} -
privatevoidbutton1_Click(objectsender, EventArgs e) { -
Application.Exit(); -
} -
} }