我有以下代码来拖动表单并在拖动时使其透明。问题是它闪烁并且不平滑拖动。我在表格上有一张照片,不知道是不是这个原因。我怎样才能让它不闪烁。如果我删除不透明度,那么它会被快速/平滑地拖动。
[DllImportAttribute("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam,
int lParam);
[DllImportAttribute("user32.dll")]
public static extern bool ReleaseCapture();
public void Drag(MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.Opacity = 0.9;
ReleaseCapture();
SendMessage(Handle, 0xA1, 0x2, 0);
this.Opacity = 1;
}
}
private void Body_MouseDown(object sender, MouseEventArgs e)
{
Drag(e);
}