OCX

Started by John Messingham, July 11, 2010, 02:47:09 PM

Previous topic - Next topic

John Messingham

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.
Many Thanks
John Messingham
http://www.jmds.co.uk

José Roca

#1
When your attempt to connect events fail. Check the return code.

John Messingham

#2
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

Many Thanks
John Messingham
http://www.jmds.co.uk

José Roca

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.

John Messingham

#4
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?
Many Thanks
John Messingham
http://www.jmds.co.uk

José Roca

#5
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>.

John Messingham

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
Many Thanks
John Messingham
http://www.jmds.co.uk

John Messingham

#7
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.
Many Thanks
John Messingham
http://www.jmds.co.uk

José Roca

Extra files? Not. Check if the OCX is properly installed.

John Messingham

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.
Many Thanks
John Messingham
http://www.jmds.co.uk

José Roca

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?

John Messingham

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.
Many Thanks
John Messingham
http://www.jmds.co.uk

John Messingham

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.
Many Thanks
John Messingham
http://www.jmds.co.uk

Rolf Brandt

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.
Rolf Brandt
http://www.rbsoft.eu
http://www.taxifreeware.com
I cook with wine, sometimes I even add it to the food.
(W. C. Fields)

John Messingham

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.
Many Thanks
John Messingham
http://www.jmds.co.uk