Le 22 mars 07 à 18:34 Soir, Carlos M a écrit:
> Other example:
> I had a problem once with some custom controls on a window that
> needed to know
> when a resized event occured on the window in order to do some
> stuff. This would
> be easy if I had just one or two. But with several this would
> require some more
> work everytime I wanted to add or remove a control. By using an
> interface, when
> the window resizes, all controls that implements the interface are
> automatically
> notified. Sure there are other ways to do this (and maybe even
> better) but to me
> it seemed, at that time, the best approach to solve the problem.
Thanks for the example.
I tried to reproduce it, but I run into a problem.
I wanted to have a class of push buttons and another of edit field
that both are notified of the window's resized event.
I added an interface (I keep the name "Interface1").
In it, I added that method: Resized(NewWidth As integer,NewHeight As
integer,OldWidth As integer,OldHeight As integer)
Then I added 2 classes:
EFCustom As EditField
PBCustom As EditField
In both classes, I added "Interface1" in the "Interfaces" field. RB
told me if I wanted to add the methods of Interface1 and I choose
naturally "yes".
Then, I wrote the code in the new Resized "event" ("method"?).
For the push button, which is "single line", I put this code:
me.Width=me.Width+(NewWidth-OldWidth)
For the edit field, which is multi lines, I put this code:
me.Width=me.Width+(NewWidth-OldWidth)
me.Height=me.Height+(NewHeight-OldHeight)
(so that I can differentiate them to see them working)
I added 2 properties (OldWidth as Integer,OldHeight as Integer),
which are set in the Resized (and Open) events.
Now, my problem is in the Resized event of the window.
I tried that:
dim o As Interface1
o=new PBCustom
o.Resized me.Width,me.Height,OldWidth,OldHeight
OldWidth=me.Width
OldHeight=me.Height
But that resizes a new PBCustom.
If I try:
o=PBCustom1 'The instance in my window
then only the push button is notified, not the edit field.
How can I "broadcast" the message to every Interface1 (my push button
and my edit field)?
(I think you are saying it is a purpose of the interface object).
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>