Hi,
Which one would be correct ? I want to put the OCX(object) into vObj1.
Maybe neither one is correct... anyone wish to assist! Thanks
DIM vObj1 AS Variant
Set vObj1 = IDC_FORM1_OCXCONTROL1
or
Set vObj1 = DISPATCH_FORM1_OCXCONTROL1
Once I see it - it might bring a little understand...
Regards
Mike
IDC_FORM1_OCXCONTROL1 contains the identifier of the window used to host the control, whereas DISPATCH_FORM1_OCXCONTROL1 is a dispatch variable that contains the reference to the dispatch interface of the control.
So the answer is:
Set vObj1 = DISPATCH_FORM1_OCXCONTROL1
Thanks Jose!
That's what I thought - but then - as I went searching... found
more questions than answers.
Great
Thanks Again
Mike
Jose, Tech-Support!
In VB:
Dim WithEvents xMain As OCXCONTROL1
Here's what I got so far...
GLOBAL xMain as Variant
When the main form is created...
Set xMain = DISPATCH_FORM1_OCXCONTROL1
This all works fine....
Notice the WithEvents (top of this message) in the DIM statement.
In VB - I can write a sub like:
Private Sub xMain_GlobalStatus(Byxxx As Long, ByVal yyy As Long)
Label1.caption = xxx
Label2.caption = yyy
DoEvents
End Sub
However - When I do this in FireFly:
Sub xMain_GlobalStatus(ByVal xxx As Long, ByVal yyy As Long)
FF_Control_SetText HWND_FORM1_LABEL1, str$(xxx)
FF_Control_SetText HWND_FORM1_LABEL2, str$(yyy)
FF_DoEvents
End Sub
Nothing Happens.......
I know there is a way - to capture the events of the object: xMain
I just can't put my finger on it...
I even tried the event in the ActiveX1_Events.inc - where the event - ActiveX.GlobalStatus() where it states:
===============================
' *** Put your code here ***
FF_Control_SetText HWND_FORM1_LABEL1, str$(xxx)
FF_Control_SetText HWND_FORM1_LABEL2, str$(yyy)
FF_DoEvents
' ===============================
And again - nothing happens...
Any help would be appreciated.
Thanks
Mike
When you put an OCX in the form, choose the ProgID and save the generated events code in a file, FireFly generates code in the Projectx_Form1_Form.inc file to connect with the events fired by this control: Call Activex1_SetEvents(ObjPtr(DISPATCH_FORM1_OCXCONTROL1), COOKIE_FORM1_OCXCONTROL1).
The events code is added to the project as a module. Click it to bring it into the editor, search the wanted event function and put your code before Function = 0. Forget about DoEvents or FF_DoEvents because this has nothing to do with the OCX events.
If nothing happens check if COOKIE_FORM1_OCXCONTROL1 has a value. If it is 0, events connection has failed else it has succeeded and you should receive events notification in the functions of the Activex1_Events.inc module.
Jose,
Everything I tried - still get 0 (ZERO) - upon return. But the OCX works great. Just can't get the events to give me EventData....
Thanks
Mike
' ********************************************************************************************
' Establishes a connection between the connection point object and the client's sink.
' Returns a token that uniquely identifies this connection.
' ********************************************************************************************
FUNCTION ActivexEvents1_SetEvents (BYVAL pthis AS DWORD, BYREF pdwCookie AS DWORD) AS DWORD
LOCAL HRESULT AS DWORD ' HRESULT code
LOCAL pCPC AS DWORD ' IConnectionPointContainer
LOCAL pCP AS DWORD ' IConnectionPoint
LOCAL IID_CPC AS GUID ' IID_IConnectionPointContainer
LOCAL IID_CP AS GUID ' Events dispinterface
LOCAL pSink AS DWORD ' Pointer to our sink interface
LOCAL dwCookie AS DWORD ' Returned token
STATIC Vtbl AS TB_IDispatchVtbl ' Vtbl structure
IID_CPC = GUID$("{B196B284-BAB4-101A-B69C-00AA00341D07}")
IID_CP = GUID$("{8E27C92D-1264-101C-8A2F-040224009C02}")
HRESULT = IUnknown_QueryInterface(pthis, IID_CPC, pCPC)
IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION
HRESULT = IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
IUnknown_Release pCPC
IF HRESULT <> 0 THEN FUNCTION = HRESULT : EXIT FUNCTION
Activex1Events1_BuildVtbl(Vtbl)
pSink = VARPTR(Vtbl)
HRESULT = IConnectionPoint_Advise(pCP, BYVAL VARPTR(pSink), dwCookie)
pdwCookie = dwCookie
IUnknown_Release pCP
FUNCTION = HRESULT
END FUNCTION
' ********************************************************************************************
In the Activex1_Events.inc file you will find a function like the above one.
After the line
HRESULT = IUnknown_QueryInterface(pthis, IID_CPC, pCPC)
put a message box to show the value of pCPC.
After the line
HRESULT = IConnectionPointContainer_FindConnectionPoint(pCPC, IID_CP, pCP)
put a message box to show the value of pCP.
and after the line
HRESULT = IConnectionPoint_Advise(pCP, BYVAL VARPTR(pSink), dwCookie)
put a message box to show the value of dwCookie.
If all the values are <> 0 then the connection has succeeded and you should be receiving the events (put message boxes in the other events function to see if they are fired) else this OCX doesn't implement and standard way to fire events (it happens sometimes with OCX made for VB).
Jose,
That's what I did - but 0's it is...
Like I said, that's ok - because it does have a property that I can read that changes values, depending on what it does. It's not as extensive,
will let's me know what operation is taking place.
Thanks for all your help.
Mike