Xojo Conferences
XDCMay2019MiamiUSA

Referring to the window your custom class is in (Real Studio getting started Mailinglist archive)

Back to the thread list
Previous thread: PPAT
Next thread: Help please - JPeg and PDF Drag 'N Drop


RB Database   -   tom.russell transport.alstom.com
  Referring to the window your custom class is in   -   Ian R
   Re: Referring to the window your custom class is in   -   Phil M
   Re: Referring to the window your custom class is in   -   Charles Yeomans
   Re: Referring to the window your custom class is in   -   Ian R
   Re: Referring to the window your custom class is in   -   Phil M

Referring to the window your custom class is in
Date: 06.02.06 06:04 (Mon, 6 Feb 2006 00:04:03 -0500)
From: Ian R

Hey there--

This is probably the most basic question ever, but I swear to god I
can't get this to work.

Say you create a custom control with the superclass ListBox, call it
dbListBox, and there's an instance of dbListBox in ListWindow. And
you have multiple instances of ListWindow. And ListWindow has a
method called LoadList.

How can I call LoadList from an instance of dbListBox? I had thought
I could say "self.LoadList", but it doesn't autocomplete or compile.
Doesn't "self" refer to the window the control is in?

Anyway. Can somebody please clear up what I assume is... maybe not
the smartest question?

Ian
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Referring to the window your custom class is in
Date: 06.02.06 06:51 (Sun, 5 Feb 2006 21:51:56 -0800)
From: Phil M
On Feb 5, 2006, at 9:04 PM, Ian R wrote:

> This is probably the most basic question ever, but I swear to god I
> can't get this to work.
>
> Say you create a custom control with the superclass ListBox, call
> it dbListBox, and there's an instance of dbListBox in ListWindow.
> And you have multiple instances of ListWindow. And ListWindow has
> a method called LoadList.
>
> How can I call LoadList from an instance of dbListBox? I had
> thought I could say "self.LoadList", but it doesn't autocomplete or
> compile. Doesn't "self" refer to the window the control is in?
>
> Anyway. Can somebody please clear up what I assume is... maybe not
> the smartest question?

I big subject, so let me just touch on a few points...

When you write a class, you usually want to make it as generic as
possible so that you can use it in other projects. So when you write
the class, you usually just limit it's influence to the class itself,
or possibility subclass derivatives. But when you drag a class or
control to the window, this is where you usually implement code
specific to the purpose.

For example, a PushButton has properties and one essential purpose...
to do "something" when the button is pushed. You could write a
PushButton subclass called ClosePushButton to which the only purpose
is to close the window it lives on; but this class would be of
limited use especially since you can just implement the Action event
when you drag the control to the Window.

In the case of Listbox controls, it is not nearly as simple as a
PushButton... ListBox controls can have a lot of custom features and
behavior styles and it would make sense to make a subclass. But if
at all possible, avoid making a subclass which refers to a specific
Window, because this subclass is not easily implemented in other
projects and other windows. If you follow the model where the
ListBox only modifies it's own data/properties (even if they are
other subclasses), then you could use the new ListBox control in any
project where it would be useful.

Self does refer to the Window when you are implementing events for a
ListBox you drag to a Window. When you are working on a subclass,
Self and Me refer to the same thing... the object instance.

If you want to refer to the window generically, you can use the
Window property of the RectControl (the ListBox super class). This
means that you can substitute Window anywhere that you would use Self
when you are writing a custom ListBox subclass. This will allow you
to modify or get any of the standard window properties... but if you
want to access another control or a method in a specific window, then
this technique will not work. This is because when you create a new
window, it is like you are really creating a new subclass of type
Window.

That is all that I have time for right now, so let me (or the list)
know if you need to access a specific window and then we can explain it.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Referring to the window your custom class is in
Date: 06.02.06 17:19 (Mon, 6 Feb 2006 11:19:31 -0500)
From: Charles Yeomans

On Feb 6, 2006, at 12:04 AM, Ian R wrote:

>
> Hey there--
>
> This is probably the most basic question ever, but I swear to god I
> can't get this to work.
>
> Say you create a custom control with the superclass ListBox, call it
> dbListBox, and there's an instance of dbListBox in ListWindow. And
> you have multiple instances of ListWindow. And ListWindow has a
> method called LoadList.
>
> How can I call LoadList from an instance of dbListBox? I had thought
> I could say "self.LoadList", but it doesn't autocomplete or compile.
> Doesn't "self" refer to the window the control is in?
>
> Anyway. Can somebody please clear up what I assume is... maybe not
> the smartest question?
>

Actually, it's a good question; it's a question of where the LoadList
method should live. One way to determine that is by the location of
the data it needs. If the data is with the window, then probably
LoadList should be a ListWindow method. If so, then you may not need a
dbListBox class; instead, use a Listbox in the ListWindow and pass a
Listbox parameter to LoadList.

--------------
Charles Yeomans

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Referring to the window your custom class is in
Date: 06.02.06 17:55 (Mon, 6 Feb 2006 11:55:46 -0500)
From: Ian R
>>
>> Say you create a custom control with the superclass ListBox, call
>> it dbListBox, and there's an instance of dbListBox in ListWindow.
>> And you have multiple instances of ListWindow. And ListWindow has
>> a method called LoadList.
>>
>> How can I call LoadList from an instance of dbListBox? I had
>> thought I could say "self.LoadList", but it doesn't autocomplete
>> or compile. Doesn't "self" refer to the window the control is in?
>>
>> Anyway. Can somebody please clear up what I assume is... maybe
>> not the smartest question?
>>
> Actually, it's a good question; it's a question of where the
> LoadList method should live. One way to determine that is by the
> location of the data it needs. If the data is with the window,
> then probably LoadList should be a ListWindow method. If so, then
> you may not need a dbListBox class; instead, use a Listbox in the
> ListWindow and pass a Listbox parameter to LoadList.

Thanks Phil & Charles, you've given me a bit to think about. You're
probably right, now that I think of it, I probably don't need dbListBox.

Do you ever do that thing where you were so sure there was a specific
thing you needed to do, but then you couldn't remember why? I can't
wait to get back to my code.

Ian
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Referring to the window your custom class is in
Date: 06.02.06 18:55 (Mon, 6 Feb 2006 09:55:27 -0800)
From: Phil M
On Feb 6, 2006, at 8:55 AM, Ian R wrote:

> Thanks Phil & Charles, you've given me a bit to think about.
> You're probably right, now that I think of it, I probably don't
> need dbListBox.

There are good reasons to have a subclassed Listbox, and from the
name you gave it it sounds like it has something to do with a
Database (which is a good reason). If written in a generic way, you
could have a LoadData method in dbListBox -- but triggering the
LoadData method should probably occur from outside the class such as
in the Action() event of a PushButton.

> Do you ever do that thing where you were so sure there was a
> specific thing you needed to do, but then you couldn't remember
> why? I can't wait to get back to my code.

That is what comments are suppose to be for. =)

Explain the why, not the how, so that you know what the block of code
achieves.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>