How can I create an extension Dll that uses Objective Grid?

If you want to create an extension Dll that uses Objective Grid, following steps are necessary:

When compiling your extension Dll, the symbol "_GXEXT" must be defined.

In the Initialization routine of your Dll, you have to call GXInit();

The following steps shows you how to modify the DLLHUSK sample so that you can call Objective Grid methods from the sample extension DLL.

With Project|Open, load dllhusk\dllhusk.mdp as project workspace

Click on "TestDll1 files" in workspace window

With right mouse click select "Settings…"

Select "TestDll1 – Win32 Debug" and "TestDll1 – Win32 Release" (or you can try x64 build)

Click on C/C++ Settings and add _GXEXT

Click OK.

Open testdll1.cpp

Insert

#include "gxall.h"

directly after #include "stdafx.h"

Change the following function. The bold text indicates what needs to be changed:

extern "C" extern void WINAPI InitTestDLL1()
{
   GXInit();
   // create a new CDynLinkLibrary for this app
   new CDynLinkLibrary(extensionDLL);
   // Register the doc templates we provide to the app
   CWinApp* pApp = AfxGetApp();
   ASSERT(pApp != NULL);
   pApp->AddDocTemplate(new CMultiDocTemplate(IDR_TEXTTYPE,
         RUNTIME_CLASS(CTextDoc),
         RUNTIME_CLASS(CMDIChildWnd),
         RUNTIME_CLASS(CGXGridView)));
   pApp->AddDocTemplate(new CMultiDocTemplate(IDR_HELLOTYPE,
         RUNTIME_CLASS(CDummyDoc),
         RUNTIME_CLASS(CMDIChildWnd),
         RUNTIME_CLASS(CHelloView)));
   // add other initialization here
}

Rebuild All. This will build all Dlls and the application.

Now you can run dllhusk.

NOTE 1: If you want to access OG functions also from your application (dllhusk) in the above sample, you also have to specify _GXDLL for the C/C++ settings of the application (dllhusk).

NOTE 2: The macros *_DECLARE_REGISTER and *_IMPLEMENT_REGISTER (see files C:\Program Files\Perforce\Stingray Studio <version>\Include\Grid\GridExportDefs.h, C:\Program Files\Perforce\Stingray Studio <version>\\Include\CustExtNonApiDefs.h) register the class for the application by default, NOT the extension DLL. This causes a problem when trying to use the derived grid class in a dialog (of the extension Dll). The dialog will fail to load because the derived grid class is registered to the application and not the extension DLL.

To avoid this problem be sure that you pass an instance handle of your extension Dll in the call to Register(). This will then register the window in your extension Dll instead of your application.

For example CGXTabBeam and CGXGridWnd are registered with these macros, but instead of calling the default Register version, OG is calling

   CGXTabBeam::RegisterClass(hInstance);
   CGXTabWnd::RegisterClass(hInstance);