Script Help

Why O why?

So anyway here goes. I have the following script in my launch button for an ActiveX object that functions as a basic note editor:

Dim IsVisible
Dim IsState
Sub Object_OnScriptEnter
IsVisible = False
End Sub

Sub Object_OnStateChange(state)
IsState = state
If IsState = "Mouse Down" Then (this needs to be "Mouse down") thx rabidrobot
If IsVisible Then
DesktopX.Object("PadText").Text = DesktopX.ScriptObject("TextEditor").Control.Text
IsVisible = False
Else
DesktopX.ScriptObject("TextEditor").Control.Text = DesktopX.Object("PadText").Text
IsVisible = True
End If
End If
End Sub

'Called when the script is terminated
Sub Object_OnScriptExit
IsVisible = False
End Sub

My intention behind this VB script is to pass text between these 2 objects. It doesn't work. The only way I have found to even have anything functional with this ActiveX object (it's a DesktopX Edit Control) is with this script:

Sub Control_OnKeyPress(Key)
DesktopX.Object("PadText").text = Control.text
End Sub

This of course is from within the ActiveX control object and only works one-way. I simply can't find any conceivable way to put text into the edit control for editing. Anyone have any ideas? I am new to VB scripting and it's been slow and painful to learn. Is there anyway to test if the ActiveX object is visible? If so, how? How can you pass text to an ActiveX edit control?
3,890 views 3 replies
Reply #1 Top
When checking the state in this manner, exact syntax is required. In this case it is usually "Mouse down" with a lower-case "d"

Also, ActiveX objects don't receive the mouse over, down, etc. messages that normal dx objects do (if they are intended to respond to mouse controls, they will have their own behavior, such as the Edit Box places the cursor and sets focus for typing). This check of state, then, won't work for the TextEditor object.
Reply #2 Top
Oakie doke. I'll try it. If it works I'll let you know, thanks.
Reply #3 Top
Okay thanks to rabidrobot (please extinguish all smoking materials I'm writing from a fire hazard zone), my script now works and I can pass text in both directions. The boolean variable IsVisible does works as a surrogate for a visible ActiveX property. I had previously experimented with the edit field object (from Tiggz, I think) but it didn't provide nearly sufficient edit controls and would have been beyond my programming skills to program a flashing cursor, scrolling, line-wrap, etc., although I did add a little functionality with testing for more scan keys. Anyway, thanks again. By the way do you think this edit box I'm typing my comment in is an ActiveX edit control? Probably is. I will now turn my attention to how to select fonts for the edit control. Wish me luck, I think I'm gonna need it.