What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Pass object to a Wnd

Pages: (2): « First [ 1 ] 2 » Last »
Pass object to a Wnd
Author: Message:
Shondoit
Full Member
***

Avatar
Hmm, Just Me...

Posts: 227
Reputation: 15
35 / Male / Flag
Joined: Jul 2006
O.P. Pass object to a Wnd
I need some kind of method, to pass a custom Object to a PlusWnd, so I can use it again when the OnWindowEvent_CtrlClicked event fires....

i.e.
code:
function CreateWnd () {
   MyObject = new Object()
   MyObject.Name = "MyCustomObject"
   MyObject.Param = "ParamValue"
   var Wnd = MsgPlus.CreateWnd("windows.xml","settings")
   Wnd.CustomObject = MyObject
}
function OnSettingsEvent_CtrlClicked (Wnd, ControlId) {
   var MyObject = Wnd.CustomObject
   Debug.Trace(MyObject.Name)
}

This doesn't work, but I need something that has the same effect
My scripts:                            [Image: shondoit.gif]
+ Timezone
+ Camelo
+ Multisearch
08-11-2006 01:56 PM
Profile PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Pass object to a Wnd
What i do is create a hidden field on the window (in the xml) set that to a random ID, then store the object in a global array with that ID then when my event fires i read the ID from the Window and look it up in the array
[Image: dt2.0v2.png]      Happy Birthday, WDZ
08-11-2006 02:09 PM
Profile PM Web Find Quote Report
Shondoit
Full Member
***

Avatar
Hmm, Just Me...

Posts: 227
Reputation: 15
35 / Male / Flag
Joined: Jul 2006
O.P. RE: Pass object to a Wnd
I already considered that, but I need the object itself, I want it to be a standalone object, not dependant of any arrays.

i.e. I have a .js with the object constructor, etc. And the Window Events, and a seperate .js with nothing more than 'obj = new MyObject()'

But thanks anyway
My scripts:                            [Image: shondoit.gif]
+ Timezone
+ Camelo
+ Multisearch
08-11-2006 02:12 PM
Profile PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: Pass object to a Wnd
well Wnd isnt a normal object, neither is any of the Plus! objects  your only real way to do what you want is via what i said, which i dont see whats so wrong about it...
[Image: dt2.0v2.png]      Happy Birthday, WDZ
08-11-2006 02:16 PM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Pass object to a Wnd
quote:
Originally posted by Shondoit
I need some kind of method, to pass a custom Object to a PlusWnd, so I can use it again when the OnWindowEvent_CtrlClicked event fires....

i.e.
code:
function CreateWnd () {
   MyObject = new Object()
   MyObject.Name = "MyCustomObject"
   MyObject.Param = "ParamValue"
   var Wnd = MsgPlus.CreateWnd("windows.xml","settings")
   Wnd.CustomObject = MyObject
}
function OnSettingsEvent_CtrlClicked (Wnd, ControlId) {
   var MyObject = Wnd.CustomObject
   Debug.Trace(MyObject.Name)
}

This doesn't work, but I need something that has the same effect


make and declare your object variable as a global variable, not as a local one:
code:
var MyObject = new Object();

function CreateWnd () {
   MyObject.Name = "MyCustomObject"
   MyObject.Param = "ParamValue"
   var Wnd = MsgPlus.CreateWnd("windows.xml","settings")
}
function OnSettingsEvent_CtrlClicked (Wnd, ControlId) {
   Debug.Trace(MyObject.Name)
}
.-= A 'frrrrrrrituurrr' for Wacky =-.
08-11-2006 06:10 PM
Profile PM Find Quote Report
Shondoit
Full Member
***

Avatar
Hmm, Just Me...

Posts: 227
Reputation: 15
35 / Male / Flag
Joined: Jul 2006
O.P. RE: Pass object to a Wnd
Well, thats what I do now, but when you do it like this, you need to now the name of the global object, and I don't want that, I want the object itself, so a user can name it whatever he likes...
But I don't think it's possible...

Perhaps Patchou can add Arguments support for Windows, so you can pass Parameters to a Window object, Patchou?... How 'bout it?
My scripts:                            [Image: shondoit.gif]
+ Timezone
+ Camelo
+ Multisearch
08-11-2006 10:58 PM
Profile PM Find Quote Report
cooldude_i06
Full Member
***

Avatar
I'm so cool I worry myself.

Posts: 272
Reputation: 9
– / Male / –
Joined: Sep 2003
RE: Pass object to a Wnd
quote:
Originally posted by Shondoit
Well, thats what I do now, but when you do it like this, you need to now the name of the global object, and I don't want that, I want the object itself, so a user can name it whatever he likes...
But I don't think it's possible...

Perhaps Patchou can add Arguments support for Windows, so you can pass Parameters to a Window object, Patchou?... How 'bout it?

Yeah, I was also looking for a way to do this. It would be great if this could be extended for methods so you could add predefined methods for a Window object. Also it would be REALLY great if you could add methods to the Window class so that all windows will inherit that method(only in the current script ofcourse).
[Image: clb2.jpg]
08-12-2006 05:40 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: Pass object to a Wnd
quote:
Originally posted by cooldude_i06
quote:
Originally posted by Shondoit
Well, thats what I do now, but when you do it like this, you need to now the name of the global object, and I don't want that, I want the object itself, so a user can name it whatever he likes...
But I don't think it's possible...

Perhaps Patchou can add Arguments support for Windows, so you can pass Parameters to a Window object, Patchou?... How 'bout it?

Yeah, I was also looking for a way to do this. It would be great if this could be extended for methods so you could add predefined methods for a Window object. Also it would be REALLY great if you could add methods to the Window class so that all windows will inherit that method(only in the current script ofcourse).

What you ask for is something entirly different than what Shondoit asks for, if I read correctly...

As a matter of fact, I don't know exactly what Shondoit tries to do though as his request is a bit vague and as it is now, it seems a bit pointless. A detailed example (pseudo-code) would be helpfull, Shondoit...

What you, cooldude_i06, ask for is adding your own methods and functions to the special interfaces of Messenger Plus!. I also requested a method for this some while ago here.

This post was edited on 08-13-2006 at 09:30 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
08-13-2006 09:28 AM
Profile PM Find Quote Report
Shondoit
Full Member
***

Avatar
Hmm, Just Me...

Posts: 227
Reputation: 15
35 / Male / Flag
Joined: Jul 2006
O.P. RE: Pass object to a Wnd
Well, actually, Cooldude wants the same as me, to pass parameters to the PlusWnd object...

Only he wants to pass a method, and I want to pass an Object

But your thread does the trick too, if it gets sorted out, that is
My scripts:                            [Image: shondoit.gif]
+ Timezone
+ Camelo
+ Multisearch
08-13-2006 12:46 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Pass object to a Wnd
quote:
Originally posted by Shondoit
Well, actually, Cooldude wants the same as me, to pass parameters to the PlusWnd object...

Only he wants to pass a method, and I want to pass an Object
Which are totally two different things...

1) You don't pass methods, you add methods to existing objects.

A method is a function. It makes no sense to "pass" it to another object. "Passing" is a term used in context of variables and functions.

2) You don't pass stuff to windows, you pass stuff to functions.

A window isn't something which can perform stuff; it's a dead thing only visible on the screen. The functions supporting the window can perform stuff. Hence it makes no sense to pass something to "a window". You pass something to the function which controls the window.

And for this you don't need any fancy thing at all, just a global variable (which holds the object or whatever else) since those are the things which are "passed" to and used between functions.


So, the two things asked are in fact two different things (unless you or cooldude described something different than what you actually wanted).

;)

As for your own problem, Shondoit, a detailed (pseudo-) code example would be very helpfull in explaining to us what you actually are trying to accomplish. And maybe in that way I also can explain better that the thing you ask for and what cooldude asks for is actually totally different.

---

To add your own methods to objects, you use the prototype method. eg:
code:
String.prototype.trim = function() {
    return this.replace(/(^\s|\s$/g, "");
}
will add a trim method to the string object.

Note that the stuff which Plus! adds to JScript aren't objects but mainly interfaces, you can not use the protoype method to add your own methods to them...

This post was edited on 12-29-2006 at 11:45 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
08-13-2006 06:10 PM
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On