New Grid

Started by David Maruca, March 31, 2010, 12:12:55 AM

Previous topic - Next topic

David Maruca

Found a new ActiveX grid today called MstGrid.

http://www.mysofttool.com/

The activex version is free and has a nice look and lots of control to it. I managed to get it working in FF3 really easy. The only problem is that it's activex so the component has to be registered on the system. Could be a problem with admin rights issues. I wish you could use activex controls without registering them...

José Roca

Quote
I wish you could use activex controls without registering them...

You can. My OLE container allows it, even for licensed controls.

Quote
This container allows the creation of instances of unregistered OCXs passing a pointer to an instance of the OC_CREATEPARAMS structure in the lParam parameter of CreateWindowEx, e.g.


' Create a registration-free instance of the MSHFlexGrid control
LOCAL  cp AS OC_CREATEPARAMS
cp.clsid = $CLSID_MSFlexGrid
cp.riid = $IID_IMSFlexGrid
cp.szLicKey = $RTLKEY_MSFlexGrid
cp.szLibName = EXE.Path$ & "Msflxgrd.ocx"
hGrid = CreateWindowEx(0, $OC_CLASSNAME, "", _
   %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %WS_TABSTOP, _
   10, 10, 400, 300, hParent, %IDC_GRID, GetModuleHandle(BYVAL %NULL), cp)


Now, request to Paul to add a property to set the path of the ActiveX control...

Michael Stefanik

There's the general purpose solution of Reg-Free COM that uses manifests to store the COM registration information, but it sounds like the approach Jose has would be easier for most folks.
Mike Stefanik
sockettools.com

José Roca

By passing the needed information (CLSID, IID, path and, if needed, the license key), the container loads the ActiveX, retrieves the address of the IClassFactory (IClassFactory2 for licensed controls) and creates an instance of the control. And since it doesn't use manifests, it also works in Windows 2000 and Windows 98.

One of the main reasons for writing my own OLE container was to not to have to register the ActiveXs.

David Maruca

Wow thanks, Jose. I have already learned so much from your examples and I just keep on learning. Thank you very much for sharing your knowledge. I wonder, is it possible to work that into the FF3 IDE. Right now I am guessing that I could put that into the form's WM_CREATE or edit the generated code when I'm ready to deploy. Any thoughts? Thanks again.

David Maruca

Ok, I'm having trouble getting this to work. I did my declares in FF_AppStart

#Include Once "OLECON.INC"
Global IDC_FORM1_CTLMSTGRID As Long
Global HWND_FORM1_CTLMSTGRID As Dword


And put the control creation in the form's WM_CREATE routine.

Function FORM1_WM_CREATE ( _
                         hWndForm As Dword, _      ' handle of Form
                         Byval UserData As Long _  ' optional user defined Long value
                         ) As Long
      Local cp As OC_CREATEPARAMS
      cp.clsid = $CLSID_MstGridgrdView
      cp.riid = $IID__MstGridgrdView
      cp.szLibName = Exe.Path$ & "MstGrid.ocx"
     
      HWND_FORM1_CTLMSTGRID = Createwindowex(%WS_EX_LEFT Or %WS_EX_LTRREADING, _
                         $OC_CLASSNAME, _
                         "", _
                         %WS_CHILD Or %WS_VISIBLE Or %WS_CLIPSIBLINGS Or %WS_CLIPCHILDREN, _
                         0, _
                         0, _
                         500, _
                         310, _
                         HWND_FORM1, _
                         IDC_FORM1_CTLMSTGRID, _
                         App.hInstance, _
                         cp)
                         'App.hInstance = Getmodulehandle(Byval %Null)
End Function


I run it and nothing.

I did copy the files to the release directory. Here is what should be distributed from the help file.

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]\MstGrid\MstGrid.ocx, COMSelfReg
    [System]\msvbvm60.dll, COMSelfReg


I've attached a project for testing.

[attachment deleted by admin]

José Roca

 
You must call OC_WinInit, that registers the class of the OLE container, before creating a window that uses $OC_CLASSNAME, and also assign a value to IDC_FORM1_CTLMSTGRID.

David Maruca

Hah it works! Thanks, Jose!

Pat Dooley

David,, would you mind posting your revised Mstgrid sample project now that you have it working?
Thanks

David Maruca

Absolutely. I put the init call in FF_WinMain and changed IDC_FORM1_CTLMSTGRID to a constant with a value. That's all that was needed.