<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0pt; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:595.3pt 841.9pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:42.55pt; mso-footer-margin:49.6pt; mso-paper-source:0; layout-grid:15.6pt;} div.Section1 {page:Section1;} -->
问题:通常情况下,我们只能选中窗口最上方的标题栏才能拖动窗口,但当标题栏隐藏时,我们能否通过选中窗口的内容并进行拖动,也能实现窗口的移动呢?
解答:
方法一:
if(e.LeftButton == MouseButtonState.Pressed)
{
System.Drawing.Point MouseCursor_Point_Aux;
MouseCursor_Point_Aux = System.Windows.Forms.Cursor.Position;
if (MouseCursor_Point_Aux.X >= MouseCursor_Point.X)
this.Left += MouseCursor_Point_Aux.X - MouseCursor_Point.X;
else
this.Left -= MouseCursor_Point.X - MouseCursor_Point_Aux.X;
if (MouseCursor_Point_Aux.Y >= MouseCursor_Point.Y)
this.Top += MouseCursor_Point_Aux.Y - MouseCursor_Point.Y;
else
this.Top -= MouseCursor_Point.Y - MouseCursor_Point_Aux.Y;
}
方法二:
This.dragmove();