custom Class calling outside

I will try to write my question as clear as possible as I’m not native english.

With a custom class, for example CustomCanvas, and then an instance is added to a window. Canvas1 with superclass CustomCanvas
The Canvas1 show an image that can be zoomed, and scrolled.

CustomCanvas has several events for example “KeyDown” event:

// Move the scrollbar Select Case Asc(Key) Case kLeftArrow MainWindow.HorizontalScrollBar.Value = MainWindow.HorizontalScrollBar.Value - kScrollUnit etc.

Now the question.
Is there a way to abbreviate the reference to, for example, MainWindow.HorizontalScrollBar or MainWindow.VerticalScrollBar or any reference to objects in the window?
For example defining wh as MainWindow.HorizontalScrollBar? and then using
wh.value = wh.value - kScrollUnit
Imagine I add a property to CustomCanvas: wh as reference to MainWindow.HorizontalScrollBar.
Later when porting CustomCanvas to another project I just redefine that reference with the name of the window and object and the CustomCanvas instances are running.

Maybe is a silly question, then I’m sorry.

With the events of any object that is dragged to a window, use Self to refer to the host window or Container Control, and Me to refer to the object itself.

In your case, your Canvas1.MouseDown event might contain code like:

if self.HorizontalScrollbar.Value = 1 then
  me.wh = something
end if

Your custom canvas class can have a reference to the scroller that belongs to the canvas. Something like

setScroller(theScroller as scrollbar) myScroller = theScroller

Then you can use the myScroller property in your canvas. Even better you can give an error message when there is no scroller.

[quote=482841:@Kem Tekinay]With the events of any object that is dragged to a window, use Self to refer to the host window or Container Control, and Me to refer to the object itself.

In your case, your Canvas1.MouseDown event might contain code like:

if self.HorizontalScrollbar.Value = 1 then me.wh = something end if [/quote]
Kem, but I want my instance is free, so the events and methods are in the CustomCanvas.

[quote=482843:@Beatrix Willius]Your custom canvas class can have a reference to the scroller that belongs to the canvas. Something like

setScroller(theScroller as scrollbar) myScroller = theScroller

Then you can use the myScroller property in your canvas. Even better you can give an error message when there is no scroller.[/quote]
Oh, thank you Beatrix, I’ll try this maybe is what I was looking for.

u can also define a event and at key press u just raise this event with some information.
in this event in the window where the custom canvas was placed you can do something.
events can have data as arguments and a return value.

// Move the scrollbar Select Case Asc(Key) Case kLeftArrow RaiseEvent HorizontalScroll -kScrollUnit etc.

Thanks all for answering.
The Beatrix solution math exactly what I was looking for.