HELP - Window control to Script Variable! |
Author: |
Message: |
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. HELP - Window control to Script Variable!
How can I set a variable to collect its contents from a window control?
Example: A user types in "test" in a text area, called "EdtMessage", within a script window. When they click Save, it is stored in a variable called "message", and a toast appears with the "test" message inside.
This post was edited on 02-17-2009 at 01:46 PM by whiz.
|
|
02-17-2009 12:30 PM |
|
|
mynetx
Skinning Contest Winner
Microsoft insider
Posts: 1175 Reputation: 33
37 / /
Joined: Jul 2007
|
RE: HELP - Window ontrol to Script Variable!
jscript code: var message;
function OnYourWindowIdEvent_CtrlClicked(objWnd, strControlId) {
switch(strControlId) {
case "BtnSave":
message = objWnd.GetControlText("EdtMessage");
MsgPlus.DisplayToast("Your script", message);
// want to close the window? uncomment the following line
// objWnd.Close(1);
break;
}
}
|
|
02-17-2009 12:41 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Window control to Script Variable!
Works great, thanks!
Another question. Well, three linked questions. How can you create a window resizable in width but not height? Can you set a default, maximum and minimum size for it? And can you set a control (like a text box) width to 100%, so that it stretches across the whole window all the time?
|
|
02-17-2009 01:46 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: HELP - Window control to Script Variable!
You are going to need to use the following
xml code:
<Window>
<Position>
<Resizable Allowed="Verticle">
<MinWidth>50</MinWidth>
<MinHeight>50</MinHeight>
</Resizable>
</Position>
</Window>
Obviously some fields are left out but you get the idea... note that all the above information is avabile in the scripting documentation you can download...
As for the other question yes you can you just need to initially set the width to stretch then use an anchor on the left and right and bottom.
|
|
02-17-2009 01:57 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Window control to Script Variable!
Okay, thanks.
And another thing... going back to the original question, I have a window for my Instant Response script so that you can change the message/timer. Is it possible for it to show the current message/timer, set by the user, in the text box by default?
|
|
02-18-2009 10:54 AM |
|
|
mynetx
Skinning Contest Winner
Microsoft insider
Posts: 1175 Reputation: 33
37 / /
Joined: Jul 2007
|
RE: HELP - Window control to Script Variable!
jscript code: objWnd.SetControlText("EdtTimer", strYourTextToSet);
|
|
02-18-2009 11:00 AM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Window control to Script Variable!
Okay, but...
1) What function would that be? Would it be like "function OnWndTimerEvent_Created(objWnd, strControlId)", or does it go in the "function OnWndTimerEvent_CtrlClicked(objWnd, strControlId)"?
2) Do I replace "YourTextToSet" with the script variable?
|
|
02-18-2009 11:18 AM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: HELP - Window control to Script Variable!
Well you would want to set the text after the widow loads right...
And yes the the second question...
|
|
02-18-2009 12:19 PM |
|
|
whiz
Senior Member
Posts: 568 Reputation: 8
– / – /
Joined: Nov 2008
|
O.P. RE: HELP - Window control to Script Variable!
Argh... nothing's happening!
I've looked in the Scripting Documentation, and there isn't a function for "on the opening of a window", so how do I do it?
|
|
02-18-2009 04:02 PM |
|
|
matty
Scripting Guru
Posts: 8336 Reputation: 109
39 / /
Joined: Dec 2002
Status: Away
|
RE: HELP - Window control to Script Variable!
You are correct there is no event for a window created... but when you create a Window you can assign the Windows object to a variable...
js code: var s = 'this is some text';
var oMyWindow = MsgPlus.CreateWnd('...', '...');
oMyWindow.SetControlText('NameOfTheControl', s);
Reading the documentation fully will help make a lot of sense of things...
This post was edited on 02-18-2009 at 04:13 PM by matty.
|
|
02-18-2009 04:12 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|