A
aName
How can this work ?
http://msdn.microsoft.com/library/d...lrfsystemwindowsformsdragactionclasstopic.asp
In Vbasic( see code below) e is pass ByVal so a copy is put on the stack when the handler is called and it is not suppose to have side effect.
But they clearly do side effect e.Action = DragAction.Cancel
To do that shouldn't we have at least ByRef Argument ????
WTF ?
PS
The c++ version is ok 'cause they pass a pointer to e
Private Sub ListDragSource_QueryContinueDrag(ByVal sender As Object, ByVal e As QueryContinueDragEventArgs) Handles ListDragSource.QueryContinueDrag
' Cancel the drag if the mouse moves off the form.
Dim lb as ListBox = CType(sender, System.Windows.Forms.ListBox)
If Not (lb is nothing) Then
Dim f as Form = lb.FindForm()
' Cancel the drag if the mouse moves off the form. The screenOffset
' takes into account any desktop bands that may be at the top or left
' side of the screen.
If (((Control.MousePosition.X - screenOffset.X) < f.DesktopBounds.Left) Or _
((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) Or _
((Control.MousePosition.Y - screenOffset.Y) < f.DesktopBounds.Top) Or _
((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom)) Then
e.Action = DragAction.Cancel
End If
End if
End Sub
[C++]
private:
void ListDragSource_QueryContinueDrag(Object* sender,
System::Windows::Forms::QueryContinueDragEventArgs* e) {
// Cancel the drag if the mouse moves off the form.
ListBox* lb = dynamic_cast<ListBox*>(sender);
if (lb != 0) {
Form* f = lb->FindForm();
// Cancel the drag if the mouse moves off the form. The screenOffset
// takes into account any desktop bands that may be at the top or left
// side of the screen.
if (((Control::MousePosition.X - screenOffset.X) < f->DesktopBounds.Left) ||
((Control::MousePosition.X - screenOffset.X) > f->DesktopBounds.Right) ||
((Control::MousePosition.Y - screenOffset.Y) < f->DesktopBounds.Top) ||
((Control::MousePosition.Y - screenOffset.Y) > f->DesktopBounds.Bottom))
{
e->Action = DragAction::Cancel;
}
}
}
http://msdn.microsoft.com/library/d...lrfsystemwindowsformsdragactionclasstopic.asp
In Vbasic( see code below) e is pass ByVal so a copy is put on the stack when the handler is called and it is not suppose to have side effect.
But they clearly do side effect e.Action = DragAction.Cancel
To do that shouldn't we have at least ByRef Argument ????
WTF ?
PS
The c++ version is ok 'cause they pass a pointer to e
Private Sub ListDragSource_QueryContinueDrag(ByVal sender As Object, ByVal e As QueryContinueDragEventArgs) Handles ListDragSource.QueryContinueDrag
' Cancel the drag if the mouse moves off the form.
Dim lb as ListBox = CType(sender, System.Windows.Forms.ListBox)
If Not (lb is nothing) Then
Dim f as Form = lb.FindForm()
' Cancel the drag if the mouse moves off the form. The screenOffset
' takes into account any desktop bands that may be at the top or left
' side of the screen.
If (((Control.MousePosition.X - screenOffset.X) < f.DesktopBounds.Left) Or _
((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) Or _
((Control.MousePosition.Y - screenOffset.Y) < f.DesktopBounds.Top) Or _
((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom)) Then
e.Action = DragAction.Cancel
End If
End if
End Sub
[C++]
private:
void ListDragSource_QueryContinueDrag(Object* sender,
System::Windows::Forms::QueryContinueDragEventArgs* e) {
// Cancel the drag if the mouse moves off the form.
ListBox* lb = dynamic_cast<ListBox*>(sender);
if (lb != 0) {
Form* f = lb->FindForm();
// Cancel the drag if the mouse moves off the form. The screenOffset
// takes into account any desktop bands that may be at the top or left
// side of the screen.
if (((Control::MousePosition.X - screenOffset.X) < f->DesktopBounds.Left) ||
((Control::MousePosition.X - screenOffset.X) > f->DesktopBounds.Right) ||
((Control::MousePosition.Y - screenOffset.Y) < f->DesktopBounds.Top) ||
((Control::MousePosition.Y - screenOffset.Y) > f->DesktopBounds.Bottom))
{
e->Action = DragAction::Cancel;
}
}
}