on 2016 Feb 10 3:52 PM
Hi All,
I’m using PB 12.5 Build 2511 on Windows 10.
I've been using SocketTools' File Transfer Control 8.0 since a long time ago and have been using its ActiveX control with PB with no problems until now. Well, sort of because now I'm trying to do something new.
The way I normally use the control in PB is by declaring an OLEObject variable and calling the pertinent methods from the object. Here is a code example of how I use it and works ok (I excluded error handling):
OleObject lole_ftp
lole_ftp = create OleObject
lole_ftp.ConnectToNewObject("SocketTools.FileTransfer.8")
lole_ftp.Initialize('<product key>')
lole_ftp.ServerName = ‘…’
lole_ftp.ServerPort = 21
lole_ftp.UserName = ‘…’
lole_ftp.Password = ‘…’
lole_ftp.TimeOut = 30
lole_ftp.Options = 1
lole_ftp.Connect()
lole_ftp.GetFile('c:\somefile.zip', 'somefile.zip')
lole_ftp.Disconnect()
lole_ftp.Reset()
Destroy lole_ftp
All this works perfectly, but the thing is, now I want to access the ActiveX control events so I can write some script and show a progress bar of the copy process. I understand I cannot do this by using the current method so I read PB's documentation and learned that I have to create an OLE control inside a Window so that the control events get exposed. I did this and now I can see the OnProgress event which according to the manufacturer’s documentation gets fired once a second or so.
So I inserted a line of code to update a progress static text (see image) but the code in the event doesn’t gets executed even though the file gets copied. It could be a fault in the ActiveX control but I seriously doubt it because the control has been in the market for many years and it even includes code examples for doing this using Visual Basic 6 and C++. PowerBuilder is mentioned as a language that can use the control but there are no examples using it for this case.
Any help would be greatly appreciated.
Ricardo
Request clarification before answering.
We're also long time users of the Sockettools controls.
I've just tried this out in PB 12.5.2 build 5801 and it does work.
Steps I took to create test code:
create app
Create window
Create MLE status area (mle_status)
Insert OLE control on the window (SocketTools File Transfer Protocol Control 8.0) (ole_1)
Create button (cb_1)
ole_1.onProgress event
mle_status.text += mle_status.text += string(filename) + ", " + string(filesize) + ", " + string(bytescopied) + ", " + string(percent) + "~r~n"
cb_1.clicked event
long rtn
ole_1.object.Intialize("")
mle_1.text = ""
rtn = ole_1.object.connect("ftp.local.server", 21, "user", "password", "", 10, 11) // 11 = passive + firewall + keepalive
mle_status.text = "connect = " + string(rtn) + "~r~n"
if rtn = 0 then
rtn = ole_1.object.GetFile("c:\localfile.psd", "localfile.psd", 0, 0)
mle_status.text += "xfer = " + string(rtn) + "~r~n"
end if
if ole_1.object.connected() then
ole_1.object.disconnect()
end if
Result was a mle_status having a couple entries of info in it from the transfer. It's a fast connection (local network), so it doesn't have many events hit.
Result looks like this:
connect = 0
localfile.psd, 15569912, 8192, 0
localfile.psd, 15569912, 15569912, 100
xfer = 0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Brad,
Thank you so much for your time in creating and trying a test case. The fact that it worked for you prompted me to experiment with some changes until I finally got it working too!
Although your code is practically the same as my code I noticed you use an additional parameter in the GetFile function. After a closer look I also noticed you use SocketTools File Transfer Protocol Control 8.0, which comes as part of SocketTools ActiveX set of controls, whereas I use the stand alone SocketTools File Transfer Control 8.0.
So this prompted me to uninstall one control and install the other to see if this was the cause of the problem. In the process, I also changed my strategy by inserting the control directly into the window instead of building an ancestor and here is where I noticed something different. The window painter showed me a different set of properties than the ones I saw in the standard visual object painter:
To make a long story short, the problem was that I was inserting an OLE Control instead of an OLE Custom Control. When using ActiveX controls you must insert them as OLE Custom Controls and not as OLE Controls which are used for OLE automation.
When selecting Create OLE Control from the Window Painter a dialog opens with three tabs: Create New, Create From Files, and Insert Control. I was choosing the Create New tab when I should be choosing the Insert Control tab to select and insert the control.
Incorrect selection method for inserting ActiveX controls:
Correct selection method for inserting ActiveX controls:
After I inserted the control as an OLE Custom Control the status text began showing the progress of the download process.
Again, thank you, and everyone else who commented on this post, for your time.
Regards,
Ricardo Jasso
| User | Count |
|---|---|
| 9 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.