PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: John Messingham on July 11, 2010, 02:47:09 PM

Title: OCX
Post by: John Messingham on July 11, 2010, 02:47:09 PM
Hi,

I am working on a new project and using the ocx version of http://www.grid2000.com. I am not sure if I am missing something but I cannot get the events to trigger. Does anyone know under what circumstances an OCX control would not trigger events.
Title: Re: OCX
Post by: José Roca on July 11, 2010, 05:09:40 PM
When your attempt to connect events fail. Check the return code.
Title: Re: OCX
Post by: John Messingham on July 11, 2010, 05:41:40 PM
Thank you Jose, I am moving along now.

The only thing I am stuck with at the moment is a memory problem message when the program exits. I have attached a screen shot of the message and wondered if I need to be unloading or destroying anything related to the following code because if I comment it all out I do not get the message.

   
    Local pGridEvents As GridImpl 
    Local pGrid As FlexCellGrid
    pGrid = OC_GetDispatch(HWND_FORM1_OCXCONTROL1)

    pGridEvents = Class "CGrid"
    OC_Advise HWND_FORM1_OCXCONTROL1, pGridEvents   
   
    If IsObject(pGridEvents) Then Events From pGrid Call pGridEvents

    pGridEvents = Nothing
    pGrid = Nothing

Title: Re: OCX
Post by: José Roca on July 11, 2010, 05:52:16 PM
Quote
If IsObject(pGridEvents) Then Events From pGrid Call pGridEvents

You are connecting events twice, first using OC_Advise and then using Events From. Use one or either, but not the two.
Title: Re: OCX
Post by: John Messingham on July 11, 2010, 06:00:47 PM
Hi,

If I remove:
If IsObject(pGridEvents) Then Events From pGrid Call pGridEvents
It removes the error message on exit but the events do not work.

If I remove:
OC_Advise HWND_FORM1_OCXCONTROL1, pGridEvents
The events work but I get the error message on exit.

Does that mean I am missing something else?
Title: Re: OCX
Post by: José Roca on July 11, 2010, 06:15:14 PM
If you use EVENTS FROM then don't set pGridEvents = Nothing until the programs ends, at which point you have to use EVENTS END pGridEvents followed by pGridEvents = NOTHING.

Alternatively, you can also try if OC_Advise works pasing the IID of the implemented events interface (not of the events class), i.e. OC_Advise HWND_FORM1_OCXCONTROL1, pGridEvents, <guid of the implemented events interface>.
Title: Re: OCX
Post by: John Messingham on July 11, 2010, 06:40:59 PM
Thank you very much once again.

This code appears to be the answer:
    Local pGridEvents As GridImpl 
 
    pGridEvents = Class "CGrid"
    OC_Advise HWND_FORM1_OCXCONTROL1, pGridEvents, Guid$("{45F22D4C-97EB-4E59-A691-16B803275AC6}")   
     
    pGridEvents = Nothing
Title: Re: OCX
Post by: John Messingham on July 21, 2010, 10:27:37 AM
I am now at the stage of trying to install this program on another machine now. The problem is that the grid does not show on the form. I do not get any errors it just does not show.

Are there any extra files I need to distribute with a PB/Firefly app that uses ocx's?

Edited to mention that the ocx is being used on the firesplitter control if that makes a difference.
Title: Re: OCX
Post by: José Roca on July 21, 2010, 11:09:26 AM
Extra files? Not. Check if the OCX is properly installed.
Title: Re: OCX
Post by: John Messingham on July 21, 2010, 11:46:39 AM
Hi Jose,
Checked that and all looks fine, I use the ocx in a couple of vb apps and the installation settings are all set the same as are the required support files.
Title: Re: OCX
Post by: José Roca on July 21, 2010, 01:18:39 PM
If it does work in your computer, does it?, and not in the other, something must be different. Does this control use a license key?
Title: Re: OCX
Post by: John Messingham on July 21, 2010, 01:48:35 PM
No license required on the target machine and yes all works fine on my development machine. I have a couple of vb6 apps that use the grid and they install and work fine. I have checked that all the required support files are included and registered as required but still no luck.

I tried changing the following line to use the same guid as the vb apps but although the program still worked on my development machine it still did not work on the target one.


   OC_Advise HWND_FRMGRID_OCXCONTROL1, pGridEvents, Guid$("{976422A2-3979-40ED-B01B-D2C4E24678A7}") 
'  OC_Advise HWND_FRMGRID_OCXCONTROL1, pGridEvents, Guid$("{45F22D4C-97EB-4E59-A691-16B803275AC6}")     


I really appreciate your help on this.
Title: Re: OCX
Post by: John Messingham on July 21, 2010, 01:56:18 PM
I have also contacted the grid supplier to see if there are any extra steps or files required if using the grid ooutside of VB6 etc.
Title: Re: OCX
Post by: Rolf Brandt on July 21, 2010, 06:02:52 PM
Hello John,

does the target machine have the VB6 runtimes installed? Attached is a jpg of Dependency Walker that shows that the Ocx needs the MSVBVM60.DLL, the Visusal Basic Virtual Machine. This dll is though on most systems.
Title: Re: OCX
Post by: John Messingham on July 21, 2010, 07:37:57 PM
Hi Rolf,

That file is one of the required support files and as such is in the installation. I even tried installing the vb runtime separately in case there was another dependency that was needed but no luck. The developers of the grid are not sure what is wrong either.

It will be something obvious once it is found.
Title: Re: OCX
Post by: José Roca on July 21, 2010, 08:45:17 PM
 
If it works in your computer and not in the other, probably the creation of an instance of the grid has failed for some reason.

Check if after pGrid = OC_GetDispatch(HWND_FORM1_OCXCONTROL1), pGrid is 0 or not.

Also, it will help if you show the lines of code used to create the control.
Title: Re: OCX
Post by: Peter House on July 22, 2010, 12:27:33 AM
Try looking at some of the tools from HTTP://www.sysinternals.com (HTTP://www.sysinternals.com)

Most of them can be run directly from the Address bar like this one:
http://live.sysinternals.com/procexp.exe (http://live.sysinternals.com/procexp.exe)

There are some very powerful system analysis tools here.
Title: Re: OCX
Post by: Cho Sing Kum on July 22, 2010, 12:31:43 AM
Hi John,

What is the OS on the target computers? Is it Vista?

Do your VB6 apps that use this OCX work on the target computers?

Edit: Please ignore my this post and questions.

I re-read the thread and found this:

Quote from: John Messingham on July 21, 2010, 01:48:35 PM
...
I have a couple of vb6 apps that use the grid and they install and work fine.
...
Title: Re: OCX
Post by: John Messingham on July 22, 2010, 05:10:12 AM
Here is the code:


Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         ByVal UserData As Long _  ' optional user defined Long value
                         ) As Long

   Local pGridEvents As GridImpl
   Local pGridDispatch As FlexCellGrid

   pGridEvents = Class "CGrid" 
   OC_Advise HWND_FORM1, pGridEvents, Guid$("{45F22D4C-97EB-4E59-A691-16B803275AC6}")     
   pGridEvents = Nothing

         
   pGridDispatch = OC_GetDispatch(HWND_FORM1_OCXCONTROL1)
   
   If IsObject(pGridDispatch) Then
   
      pGridDispatch.AutoRedraw = %False
      pGridDispatch.BackColorBkg = Rgb(90, 158, 214)
     
      pGridDispatch.Rows = 1
      pGridDispatch.Cols = 7
       
      setCellText(HWND_FORM1_OCXCONTROL1, 0, 0, "ID")
      setCellText(HWND_FORM1_OCXCONTROL1, 0, 1, "Priority")
      setCellText(HWND_FORM1_OCXCONTROL1, 0, 2, "Title")
      setCellText(HWND_FORM1_OCXCONTROL1, 0, 3, "Category")
      setCellText(HWND_FORM1_OCXCONTROL1, 0, 4, "Contact")
      setCellText(HWND_FORM1_OCXCONTROL1, 0, 5, "Project")
      setCellText(HWND_FORM1_OCXCONTROL1, 0, 6, "Assigned To")
     
      pGridDispatch.ReadOnly = %True
      pGridDispatch.SelectionMode = %SelectionModeContrants_cellSelectionByRow
      pGridDispatch.AutoRedraw = %True
      pGridDispatch.refresh
      pGridDispatch = Nothing
   
   Else
   
      MsgBox "No Grid Object Created"
     
   End If

End Function

Function setCellText(hWndControl As Long, cRow As Long, cCol As Long, cText As String) As Long

    Local pGridDispatch As FlexCellGrid
    Local pCell As FlexCellCell
   
    pGridDispatch = OC_GetDispatch(hWndControl)
   
    If IsObject(pGridDispatch) Then         
        pcell = pGridDispatch.Cell(cRow, cCol)
        pcell.Text = UCode$(cText)
        pGridDispatch = Nothing
    End If

End Function


On my development machine (Vista) it works but on the target machine (XP Pro) I get the "No Grid Object Created" message.

Thanks for the link Peter, I will have a look at the tools.
Title: Re: OCX
Post by: Cho Sing Kum on July 22, 2010, 05:11:03 AM
I don't have experience with OCX in FF/PB, only with VB6 which is quite straight forward.

However, if you have a simple FF/PB demo project with the Grid, I can test it on my computers. Just a simple one that show the Grid and maybe populate a cell.

I have downloaded the trial and noted the dependency on msvbvm60.dll and iobjsafe.tlb.
Title: Re: OCX
Post by: John Messingham on July 22, 2010, 05:15:25 AM
Hi Cho,

I have attached a little sample program for FF.
Title: Re: OCX
Post by: Rolf Brandt on July 22, 2010, 05:22:32 AM
John,

I just tried your example on my XP Pro SP3 machine. Works perfectly, the grid is created. So there must be something else in the bush.
Title: Re: OCX
Post by: John Messingham on July 22, 2010, 05:29:13 AM
Cheers Rolf,

These are always the worst ones arent they?
Title: Re: OCX
Post by: Rolf Brandt on July 22, 2010, 05:35:52 AM
They sure are. Can be extremely time consuming and nerving!
Title: Re: OCX
Post by: Cho Sing Kum on July 22, 2010, 06:02:19 AM
The sample works ok on my pc (WinXP Pro SP3).

I copied project1.exe and FlexCell.ocx onto a thumb drive. Went over to another pc that does not have the FlexCell trial installed. Regsvr32 the OCX and it runs okay (WinXP Pro SP3).

On both pc, when I unregistered FlexCell.ocx, I get the error "No Grid Object Created" when I run project1.exe.

Looks ok at my end.

Title: Re: OCX
Post by: John Messingham on July 22, 2010, 06:23:04 AM
Cheers Cho,

So it really looks like it is something to do with the machine here.

Thanks for all the repsonses.

Title: Re: OCX
Post by: John Messingham on July 22, 2010, 06:38:43 AM
Hi Cho,

Did you just copy the project1.exe and FlexCell.ocx files? what about the dependancie files? I only ask as if the extra files are not required for the little demo then at least I know it is not them.
Title: Re: OCX
Post by: Rolf Brandt on July 22, 2010, 07:16:34 AM
Just copy the project1.exe and FlexCell.ocx, register the ocx and Bingo! No need for other dependency files, they are part of the OS.
Title: Re: OCX
Post by: Cho Sing Kum on July 22, 2010, 07:18:43 AM
Hi John,

Yes, I just copied project1.exe and FlexCell.ocx only.

Although according to the help file:
Quote
What do I need to do when distributing my application?

When you create the application's installer, pack and register these files as follows:

[Program Files]\FlexCell\FlexCell.ocx, COMSelfReg
[System]\msvbvm60.dll, COMSelfReg
[System]\iobjsafe.tlb, COM
[System]\xls.dll, DoNotRegister, required for ExportToExcel method.
[System]\zlib.dll, DoNotRegister, required for ExportToPDF method.
[System]\msvcr71.dll, DoNotRegister, required for ExportToPDF method.

msvbvm60.dll is installed by WinXP
iobjsafe.tlb should be required on developer pc only???
xls.dll, zlib.dll and msvcr71.dll are required only if the stated functions are required.
Title: Re: OCX
Post by: John Messingham on July 22, 2010, 10:14:11 AM
I have got back onto the grid developers again because I have tried the tests using the demo version and it works fine but as soon as I replace the demo with the full grid version the problem occurs.
Title: Re: OCX
Post by: Cho Sing Kum on July 22, 2010, 10:27:30 AM
Oh yes, I missed out this point.

I have a 3rd party ActiveX DLL and another 3rd-party Win32 DLL that I must provide licensing info in my source code otherwise they remain in demo mode.

You probably need to do something similar.

In addition, I think your licensed ocx may be different from the demo ocx.
Title: Re: OCX
Post by: John Messingham on July 22, 2010, 10:56:28 AM
There used to be a requirement to pass the registration details to the grid but this was removed some time ago. If this was still the case it would be a non starter as I would need to create an instance of the grid in order to pass the details to it.
Title: Re: OCX
Post by: José Roca on July 22, 2010, 11:16:46 AM
No problem. Besides the ProgID, you will have also to pass the license key, e.g.

<ProgID>;RTLKEY:<license key>
Title: Re: OCX
Post by: Cho Sing Kum on July 22, 2010, 12:05:09 PM
There is another method of licensing OCX in VB6 with the use of a ".VBL" file that the OCX seller provide. This do away with putting license info in your source code.

This .VBL file will be used to write license info into the Registry of your development computer. When you compile your VB6 project, VB6 automatically include the license info into your compiled exe.

If FlexCell is using this method, then this may explain why your VB6 apps work on the target computer but not the FF/PB apps.
Title: Re: OCX
Post by: John Messingham on July 22, 2010, 12:29:51 PM
Cho,

This is where my thoughts have been. I am waiting to here back from the grid developers to see if this is what is happening. I would have expected a messasge from the grid but it is possible it simply does not work if the licence details are not present.
Title: Re: OCX
Post by: John Messingham on July 22, 2010, 03:01:34 PM
Big thank you to everyone for their input on this.

It turns out that a license code is needed in order to use the grid outside VB6 etc. I now have the code and the program works.
Title: Re: OCX FlexCell Grid
Post by: Jean-pierre Leroy on March 16, 2014, 10:27:19 AM
Hi John,

I tried today your sample FireFly project with the latest demo version of FlexCell.

I got a runtime error number '91' ?

Any idea ?

Thank,
Jean-Pierre