473,474 Members | 1,310 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VB Guru please explain me how this can work ?


How can this work ?
http://msdn.microsoft.com/library/de...classtopic.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;
}
}
}
Sep 25 '06 #1
2 1118
aName wrote:
How can this work ?
Because the QueryContinueDragEventArgs argument (e) is a reference
type. When a reference type is passed ByVal, then what is passed is a
*copy* of the reference. But changing the properties etc of the copy
of the reference changes the original object.

Please see the following article for a more in depth explanation:

http://www.yoda.arachsys.com/csharp/parameters.html
<snip>

Sep 25 '06 #2
aName wrote:
How can this work ?
Because the QueryContinueDragEventArgs argument (e) is a reference
type. When a reference type is passed ByVal, then what is passed is a
*copy* of the reference. But changing the properties etc of the copy
of the reference changes the original object.

Please see the following article for a more in depth explanation:

http://www.yoda.arachsys.com/csharp/parameters.html
<snip>

Sep 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Accolo1 | last post by:
Help we are looking for this person, do you know them? William wjohnson@accolo.com Title: BEA WebLogic Portal Guru Job #: 03-04468 Check the pulse of your career! Evolve our eCommerce web...
3
by: Richard | last post by:
Trying to wrap my brain around Regex for the first time... I need to be able to replace Sql @NamedParameters with "?" for compliance with an extremely lame 3rd party Odbc driver. I know that...
16
by: Singulus | last post by:
Hello all, I've searched for similar threads, I've found some bit of useful info here and there, but nevertheless I want to post my questions...So, how can I (we, in fact the forum can benefit...
8
by: Chris LaVelle | last post by:
I don't know the easiest way to explain this so, I'm going to give an example of how it is today....and what I'm trying to accomplish. in the header... typedef struct XXX_ELEMENT_tag { UINT8 ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.