Hi,
I was wondering if there are any other examples of using activex, with FF/PB. I have been using the email components from http://www.codestone.co.uk for a while in VB. I would like to use them with FF/PB is possible. I have managed to get some of the functions working, but not all. Are there any kind of limitations.
What FireFly foes it to create an instance of the ActiveX control using ATL as the container and providing you a dispatch variable for calling the methods and properties of the control. If you are able to use some of the properties this means that the an instance of the control has been created. If you show us the code that you are using (only the COM calls) perhaps we can give you some advice. A common problem with OCXs made for VB and VBScript is that many of them use ByRef variants and the PB compiler doesn't support them yet, although I have a workaround that perhaps will work if this happens to be the problem.
The interface generated by the PB COM browser will be also useful to see if there are INOUT parameters.
BTW the OCXs that you have mentioned aren't visual OCXs for what I have read in the link that you have provided.
I will sort out the code later today, I have been able to connect to the mail server and check for messages. In VB, when you retrieve the messages, they are placed into the 'message collection'. I am unsure how/if this would be accesable via PB.
Here is some code i am trying in connection with the mail component.
DIM vHost AS VARIANT
DIM vUser AS VARIANT
DIM vPass AS VARIANT
DIM vPort AS VARIANT
DIM vmsgCount AS VARIANT
DIM vMsgIndex AS VARIANT
DIM vMsglines AS VARIANT
vHost = "127.0.0.1"
vUser = "admin"
vPass = "admin"
vPort = "110"
vMsgIndex = 1
vMsglines = 0
OBJECT CALL DISPATCH_FORM1_OCXCONTROL1.CONNECT(vHost,vUser,vPass,vPort)
' get message count
OBJECT GET DISPATCH_FORM1_OCXCONTROL1.MessageCount() TO vMsgCount
MSGBOX FORMAT$(VARIANT#(vMsgCount))
' Get Messages
DIM Msg2 AS VARIANT
DIM Msg3 AS VARIANT
Msg2 = 1
OBJECT CALL DISPATCH_FORM1_OCXCONTROL1.RetrieveMessages(vMsgIndex,vMsgLines)
OBJECT CALL DISPATCH_FORM1_OCXCONTROL1.Item(Msg2) TO Msg3
I am able to display the message count, it is the next bit I get lost on. The 'Retrieve Messages' statement places the messages into a message collection, I should then be able to access each msg in order to access the message text etc. I am sure it is something I am missing, so any advice will be welcome.
Your problem is to learn how to read collections using PB, that has not a For Each construct like VB.
OBJECT CALL DISPATCH_FORM1_OCXCONTROL1.Item(Msg2) TO Msg3
will return a reference to the interface of the message. To be able to call the properties of this message you have to assign it to a dispatch variable.
DIM oMsg AS DISPATCH
OBJECT CALL DISPATCH_FORM1_OCXCONTROL1.Item(Msg2) TO Msg3
SET oMsg = Msg3
IF ISFALSE ISOBJECT oMsg THEN
' Error
ELSE
' Call the methods and properties of the message
...
...
' Release the interface when finished
SET oMsg = NOTHING
END IF
Hope this helps.
Many Thanks.
I have been trying the code change suggested, the 'ISFALSE ISOBJECT' seems to be the result. Jose mentioned byref variants and inout parameters, I am unable to find any referneces to these.
Any further suggestions gladley welcomed.
BTW does anyone know of a forum, website that has details of com components that have been found to work with FF/PB?
Apparently, RetrieveMessages populates a collection named Messages, so try:
OBJECT CALL DISPATCH_FORM1_OCXCONTROL1.Messages.Item(Msg2) TO Msg3
> BTW does anyone know of a forum, website that has details of com components that have been found to work with FF/PB?
Unless they have something special (some are so specially made for VB that use properties of the VB runtime), all should work. The ByRef problem are usually encountered in OCXs made with VB by programmers that omit the ByVal in the IN parameters. All of the OCXs that come with VB6 Enterprise Edition work except TabCtrl, and I think that DbGrid and DbCombo had some problems.
Many Many thanks,
That seems to work a treat, where did you find the reference to the messages collection?
With a bit of luck, what I have learned from you will enable me proceed further, so again many thanks
From the documentation:
"RetrieveMessages () will populate all the elements of the Messages collection property with the messages from the maildrop and mark the messages for deletion from the server."
A problem with VB is that hides so much the details that VB examples can't be traslated easily to another language unless you really understand how COM works. I had to learn low level COM programming looking at C examples.
I just have to bow my head to Jose... the man knows so much about COM that it makes me feel like an idiot. 8)
I know how you feel, but it is nice to know that people are prepared to help. Maybe programmers should run the world!!!!