Drag and drop 跨MDI子窗体拖放操作
我正在尝试执行一个简单的拖放操作,从一个MDI子窗体中的一个按钮开始,到另一个MDI子窗体中的另一个按钮。然而,由于某些原因,当我尝试将一个按钮拖动到另一个按钮时,DragDrop事件从未被触发。值得注意的是,当我拖动按钮时,我的光标变成了黑色的取消图标 我的代码:Drag and drop 跨MDI子窗体拖放操作,drag-and-drop,mdi,Drag And Drop,Mdi,我正在尝试执行一个简单的拖放操作,从一个MDI子窗体中的一个按钮开始,到另一个MDI子窗体中的另一个按钮。然而,由于某些原因,当我尝试将一个按钮拖动到另一个按钮时,DragDrop事件从未被触发。值得注意的是,当我拖动按钮时,我的光标变成了黑色的取消图标 我的代码: #region ActivatesDragDropControl [DllImport ("user32.dll")] public static extern int SendMessage(IntPtr
#region ActivatesDragDropControl
[DllImport ("user32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
private const int WM_NCACTIVATE = 0x0086;
#endregion
private void button1_MouseDown(object sender, MouseEventArgs e)
{
DoDragDrop(LocationNode, DragDropEffects.Link);
// to deactivate
SendMessage(Handle, WM_NCACTIVATE, 0, 0);
}
private void button1_DragDrop(object sender, DragEventArgs e)
{
//never gets here...
}
private void button1_DragEnter(object sender, DragEventArgs e)
{
// to activate
SendMessage(Handle, WM_NCACTIVATE, 1, 0);
}
好的,所以我玩了一点,使用DragEnter是不够的;我必须设置DragEventArgs的事件值。就我而言:
e.Effect = DragDropEffects.Link;
好的,所以我玩了一点,使用DragEnter是不够的;我必须设置DragEventArgs的事件值。就我而言:
e.Effect = DragDropEffects.Link;