Proper syntax for 'me.Parent.Left'

I have Rectangle1 on Window1. I want to be able to MouseDown on the Rectangle and Move it with MouseDrag. The x,y coordinates presented with Rectangle1.MouseDown are relative to the Rectangle. I want it relative to Window1 so I can dynamically reposition the rectangle with the drag.

System.MouseX - Window1.Left works and accomplishes this. But I want to abstract Window1 so i can use this as a custom control independent of the name of the parent window. Me.Parent.Left crashes.

What is the proper syntax to address the parent window’s left, top, width and height?

Thank you,

Use Self instead of Me.Parent to refer to the parent window from within a control.

Me.Parent refers to the parent control not the parent window; if Me is not contained within another control then Me.Parent is Nil. Accessing a Nil object raises a NilObjectException.

Thanks. That’s the solution.