Hi Paul,
Within FF3 designer I can use currently only registered OCX; so I have one suggestion and one question :
Suggestion: Could it be possible to add a new control in FF3 "Unregistered OCX/ActiveX" where we can set directly the necessary information for unregistered "OCX/ActiveX" : I think of CLSID, IID, Path, License key if needed, etc ...; by adding a new control for "Unregistered OCX/ActiveX", the existing FF3 projects that use the "OCX/ActiveX" control will continue to compile and execute normally.
Question. in the meantime, can you please write a small example (mini tutorial) of what need to be done for the moment in order to work with "Unregistered OCX/ActiveX" with FF3.
Thanks.
Jean-Pierre
LOCAL pWindow AS CWindow
pWindow = CWindow_GetObjectFromWindowHandle (<Form handle>)
pWindow.AddUnregOcx (...)
For the AddUnRegOcx method parameters, see the help file of my headers.
If isn't already defined in your application, you need to add %USEOLECON = 1, if the OCX is a visual control.
Thank Jose,
I will try and will post my results later.
Thanks.
Jean-Pierre
Hi Jose,
%IDC_FORM1_OCXCONTROL1 = 1001
Global HWND_FORM1_OCXCONTROL1 As Dword
'--------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ ' optional user defined Long value
) As Long
Local pWindow As IWindow
pWindow = CWindow_GetObjectFromWindowHandle(hWndForm)
HWND_FORM1_OCXCONTROL1 = pWindow.AddUnregOCX(hWndForm, %IDC_FORM1_OCXCONTROL1, $CLSID_MstGrid_grdView, $IID_MstGrid_MstGrid_grdView, Exe.Path$ & "MstGrid.ocx", "", 0, 0, 500, 310)
End Function
When I try to compile I get this message on the line pWindow.AddUnregOCX
QuoteError 598: METHOD OR PROPERTY NAME EXPECTED
Any ideas ?
Thanks.
Jean-Pierre
I find the solution.
I have to put:
%USEOLECON=1
As the first line of the FF_AppStart
Jose, Paul I hope you can help me:
This code works fine; the visual OCX control is created on the main form:
Local pWindow As IWindow
pWindow = Class "CWindow"
HWND_FORM1_CTLMSTGRID = pWindow.AddUnregOCX(hWndForm, %IDC_FORM1_CTLMSTGRID, $CLSID_MstGridgrdView, $IID__MstGridgrdView, Exe.Path$ & "MstGridOld.ocx", "", 0, 0, 500, 310, _
%WS_CHILD Or %WS_VISIBLE Or %WS_CLIPSIBLINGS Or %WS_CLIPCHILDREN)
The code below with CWindow_GetObjectFromWindowHandle method didn't work for me; if I test the pWindow after this method with ISNOTHING() it's true each time ?
Local pWindow As IWindow
pWindow = CWindow_GetObjectFromWindowHandle(hWndForm)
HWND_FORM1_CTLMSTGRID = pWindow.AddUnregOCX(hWndForm, %IDC_FORM1_CTLMSTGRID, $CLSID_MstGridgrdView, $IID__MstGridgrdView, Exe.Path$ & "MstGridOld.ocx", "", 0, 0, 500, 310, _
%WS_CHILD Or %WS_VISIBLE Or %WS_CLIPSIBLINGS Or %WS_CLIPCHILDREN)
What am I doing wrong ? what's the best practice ?
Thanks,
Jean-Pierre
I guess that you are putting the code in the Create message. You may need to move it to another place.
To be able to create controls in the Create message, it would be needed that FF will send the lParam parameter to FORM1_WM_CREATE (hWndForm, FLY_UserData). Then the pWindow pointer could be retrieved with pWindow = CWindow_GetObjectFromCreateStruct( lParam )
Yes Jose, I place my code at the end of the WM_CREATE of my main FORM.
Quote
To be able to create controls in the Create message, it would be needed that FF will send the lParam parameter to FORM1_WM_CREATE (hWndForm, FLY_UserData). Then the pWindow pointer could be retrieved with pWindow = CWindow_GetObjectFromCreateStruct( lParam )
In the meantime, what can I do ? Where else can I put the creation of OCX control ?
I haven't tested it, but could you get the pWindow pointer from:
pWindow = CWindow_GetObjectFromWindowHandle(hWndForm)
Yes Paul I have tested with this code in the WM_CREATE handler
pWindow = CWindow_GetObjectFromWindowHandle(hWndForm)
But it didn't work ...
I test the pWindow value after this method with the function ISNOTHING(pWindows) which returns TRUE each time.
Paul,
Do you think my suggestion in the first post of this thread could be an option for the near future ?
Thanks
Jean-Pierre
As I said, the only way to get a pointer to the window class in the Create message is to use the the function CWindow_GetObjectFromCreateStruct, but it needs that FF will pass the lParam as a parameter to it, i.e. FORM1_WM_CREATE (hWndForm, FLY_UserData, lParam).
This is because the CreateWindow method of the CWindow class can't store the pointer to the class using SetClassLong until the call to CreateWindowEx returns the window handle, and this does not happen until the WM_CREATE message has been fully processed. In the method, I use the trick of passing the pointer to the CWindow class in the lParam member of CreateWindowEx.
I will take a look to see if there is anything that I can do.
:)
There was no easy fix using the existing way that FireFly generated the code. The lParam passed to WM_CREATE that points to the CREATESTRUCT structure is not accessible to the programmer during their WM_CREATE for the Form. I have modified the code generation to save the lParam into an internal FireFly structure that you can retrieve.
This is a bit of a hack, but it does seem to work.
Use this code to retrieve the pWindow:
Function FORM1_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ ' optional user defined Long value
) As Long
Local pWindow As IWindow
Local pFLY As FLY_DATA Ptr
pFLY = GetProp( hWndForm, "FLY_PTR" )
pWindow = CWindow_GetObjectFromCreateStruct( @pFLY.lParamCreateStruct )
If IsNothing(pWindow) Then
? "Failed to retrieve valid pWindow"
Else
? "pWindow retrieved"
End If
End Function
You also need to use the new FireFly exe that is attached to this message.
Please let me know if this works for you.
Paul, if you wonder why I'm passing in lParam a pointer to an structure that, currently, has only a member, pWindow, instead of directly the value of the pointer, it is to allow to be extended with other members if needed.
Hi Paul,
Thanks for this quick fix; I have just tested and it works as expected.
In the future to simplify even more the life of programmer like me, do you think you will plan to add to the list of controls a new one that could be called "Unregistered OCX/ActiveX" ?
Thanks for your support.
Jean-Pierre