DesktopX Script Assistance

VB who knew?

Oh well, never thought I would be trying scripting like I am, but I might get this yet. Anyway I was following the example in DesktopX 3.2 article when I discovered I don't know how to pass the text from the ActiveX control (DesktopX Edit Control) to my text field that sits as a layer on top of my graphic image. I've tried DesktopX.Object("Mytextfield").text = DesktopX.Object("MyDesktopXEditControl").text, but that passes control codes and no usable text. I've also tried testing the key code with If szKey > 31 Then If szKey < 128 before passing the text to my object, but then nothing passes. So, any of you DesktopX script guys and gals know how to do this? I can work with simple programming tasks, so I will need some specific instructions on this one. Or, where to look for VB script examples, tutorials etc.
5,064 views 8 replies
Reply #1 Top
I think it might be DesktopX.Object("MyDesktopXEditControl").Control.Text

Check out "ActiveX Controls" in the docs for more info: https://www.stardock.com/products/desktopx/documentation/index.html

Note that the event listed on that page isn't completely explained well. To use the events for an ActiveX control it's like adding events for an Object except you prefix it with Sub Control_ instead. ie.: Sub Control_OnSelect(Item As Long, string As String)

And to access the ActiveX control you use Control. ie.: Control.Enabled = True
Reply #2 Top
Thanks. I think you are right. Didn't realise that ActiveX controls were added to the docs or, had I missed them previously? Anyway, I will try using the indicated syntax (or is that sintax? oops, thats right, I don't care what the mayor says I won't pay those anymore!). So there. Later, thanks again.
Reply #3 Top
Okay my request for help still remains. I've tried everything I can think of and there is no way I can find to refer to the "Control.text" as mentioned for ActiveX controls. Text is clearly documented as being a property of the DesktopX Edit Control. Yet, I have found no way to refer to this text from other scripts in other DesktopX Objects, etc. or for that matter from within the script of the Control object. So.. If anyone knows how to have DesktopX.Object("MyTextField").text = Control.text please let me know. Okay I've worked a little more at this and found a significant part of the answer. I had to enable the Control_OnKeyPress(Key) method. From within this method I have currently one line of code:
DesktopX.Object("MyTextField").text = Control.text and walla it works. But alas, my new found success is quickly dashed since I can't find anyway to refer to the Control.text from outside the DesktopX Edit Control. I now have no means of editing pre-existing text using DesktopX edit control. So ... how do I pass existing text to the edit control for editing?
Reply #4 Top
It appears my first response did not make it to thread. I'll try again! When you want to access an attribute, or property, function, variable, etc. that exists as a result of a script, you need to use slightly different syntax. Instead of Object("myObject") you will use ScriptObject("myObject") You will use both syntaxes, depending on what you want to get or set - just try and remember to use Script if a script is involved directly. As it is in this case! DesktopX.ScriptObject("MyActiveXEditBox").Control.Text = DesktopX.Object("MyRegularTextObject").Text or vice versa should work. You can omit DesktopX.ObjectType("ObjectName") when referrring to self object, as you know, so the exact line above would be used in a third object. But it's the ScriptObject bit that'll get you rolling. If I can get this to post! Edited trying to improve layout.
Reply #5 Top
I apologise, but I have done my very best to follow your example to the letter. It doesn't work. The only means I have found so far to refer to "MyActiveEditBox" is as control.text from within the control. So far all outside references fail. My one suspect culprit at this point is that I am trying to test whether the edit box is visible or not. Could be the ActiveX control doesn't have a visible property like other DesktopX objects do. Makes it more difficult to work with, oh well.
Reply #6 Top
Try to test the object that is hosting the ActiveX instead.
Reply #7 Top
It's hard to say if visibility test is an issue without seeing the code (which would be no fun until forums start including line feeds again!). I do know that visibility, transparency, and ActiveX controls can be serious trouble. Back up your objects frequently, saving as both desktops and dxpacks when playing with those combos (although this issue may have been fixed).

You can type in your own line feeds, I see.
I made a sample object: http://feebdack.com/storage/ScriptObjectSample.dxpack
Reply #8 Top
I like your idea perhaps if I make a regular DesktopX object the parent of my ActiveX control and test it for visiblity I will have that problem solved, but I still have found no way possible to send text to the ActiveX Edit Control. I haven't worked with global variables before, but that might be the only solution. I also posted a Script Help thread today which shows my script and darned if I can figure out why it doesn't work. Keep plugging I guess.

Posted via WinCustomize Browser/Stardock Central