This is probably something stupid that I am not doing. I am trying to use the Spread 7 OCX within a project because it is a decent report facility which will allow me to use multiple pre-formatted report templates.
I can load it fine into a form, and it appears both in the design mode and at run time. However, any attempt to communicate with it results in a %E_UNEXPECTED error. My goal is to use a single form with this control as a general purpose report writer and push data into a hidden sheet on the control which will populate a report template with data.
Here is what I have tried to do:
Dim vVar As Variant
Dim Filename As String
FRMREPORTVIEWER_SHOW (HWND_FORM1, 0) 'this has the control on it
FileName = UCODE$("C:\SNAPSITE\TEMPLATES\Mosaic_60_NoGroup.ss7") 'the template
Let vVar = FileName As String
Object Call DISPATCH_FRMREPORTVIEWER_OCXCONTROL1.LoadFromFile(vVar)
j=ObjResult
If j Then
MsgBox "object call returned " & Hex$(j) & " " & ObjResult$(ObjResult)
End If
The type information on the interface has the filename as a string, but that produces the same result. Am I simply missing something on initializing it? Everything seems fine -- it displays on the screen as a blank worksheet, but that's about it. LoadFromFile is a valid method.
Change
Quote
FileName = UCODE$("C:\SNAPSITE\TEMPLATES\Mosaic_60_NoGroup.ss7") 'the template
Let vVar = FileName As String
to
Quote
FileName = "C:\SNAPSITE\TEMPLATES\Mosaic_60_NoGroup.ss7" 'the template
Let vVar = FileName As String
With PB, when an string is assigned to a variant, it is automatically converted to unicode. Assigning an unicode string, you will get a double converted string, i.e. an unintelligible mess.
There are two versions of the OCX, one that uses unicode, the other that doesn't. I have tried this with and without the UCODE$() and with both versions to no avail.
It also has a DLL interface, but I have not yet managed to find a clear statement on how to use a custom control with a DLL that requires a handle to a window. It should be possible to use their call SSOpenFromFile(hWND,filename), but I have a feeling that the hWND is not simply the FF generated HWND for the custom control.
VB6 shielded me from this kind of stuff and allowed me to concentrate on the underlying statistical and geographic routines. Do you know of any good examples which would show me how to set up a form with a custom control then use it with a DLL that requires a handle?
Quote
There are two versions of the OCX, one that uses unicode, the other that doesn't.
Must be the first one! As far as I know, there is a version that uses ADO and another that uses DAO.
Quote
It also has a DLL interface, but I have not yet managed to find a clear statement on how to use a custom control with a DLL that requires a handle to a window.
Easy. Just passing an handle to a window.
Quote
It should be possible to use their call SSOpenFromFile(hWND,filename), but I have a feeling that the hWND is not simply the FF generated HWND for the custom control.
You're wrong. An HWND is an handle to a window, i.e. an alias for DWORD.
Quote
VB6 shielded me from this kind of stuff and allowed me to concentrate on the underlying statistical and geographic routines.
And you didn't learn anything about COM programming in the process.
Quote
Do you know of any good examples which would show me how to set up a form with a custom control then use it with a DLL that requires a handle?
Some companies, and if I'm not wrong FarPoint is one of them, forbid to post headers, examples, etc., to "protect" his products. Therefore, the only examples that you will get are the ones that come with it.
Thanks, will keep plugging away at it.
I'm using the Farpoint Spread DLL and find it works great. SSLoadFromFile wants the handle to the Spread control. From within a dialog callback, you could use:
hSpread = GetDlgItem( CB.HNDL, %IDC_SPREAD)
where %IDC_SPREAD is the control ID used when adding the control to the dialog. hSpread can then be used as the hWND parameter in the SSLoadFromFile (and other Spread DLL function) call(s).