home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pentlk11.zip / IMAGES / PENTLKT2.IMG / unc.dsk / OEM.C < prev    next >
C/C++ Source or Header  |  1994-01-13  |  9KB  |  230 lines

  1. /******************************************************************************
  2. *                                                                             *
  3. *  File Name   : OEM.C                                                        *
  4. *                                                                             *
  5. *  Description : Sample sublcass                                              *
  6. *                                                                             *
  7. *  Function:  This is a sample of a subclass of PenLocatorPen                 *
  8. *                                                                             *
  9. *  Copyright (C) 1993 IBM Corporation                                         *
  10. *                                                                             *
  11. *      DISCLAIMER OF WARRANTIES.  The following [enclosed] code is            *
  12. *      sample code created by IBM Corporation. This sample code is not        *
  13. *      part of any standard or IBM product and is provided to you solely      *
  14. *      for  the purpose of assisting you in the development of your           *
  15. *      applications.  The code is provided "AS IS", without                   *
  16. *      warranty of any kind.  IBM shall not be liable for any damages         *
  17. *      arising out of your use of the sample code, even if they have been     *
  18. *      advised of the possibility of such damages.                            *
  19. *                                                                             *
  20. *******************************************************************************/
  21.  
  22. /*
  23.  * This file was generated by the SOM Compiler
  24.  * and them updated. Please note the SOMInitModule and _DLL_InitTerm.
  25.  * FileName: oem.c.
  26.  * Generated using:
  27.  *     SOM Precompiler spc: 1.22
  28.  *     SOM Emitter emitc: 1.24
  29.  */
  30.  
  31. #define oem_Class_Source
  32. #include "oem.ih"
  33.  
  34. /* Define a global variable for the dll hmodule */
  35. HMODULE  MyModHandle = NULLHANDLE;
  36.  
  37. unsigned long  _System _DLL_InitTerm(unsigned long modhandle,
  38.                                      unsigned long flag)
  39. {
  40.    if ( flag == 0 ) /* init */
  41.    {
  42.        MyModHandle = modhandle;
  43.    }
  44.    return 1;
  45. }
  46.  
  47. VOID EXPENTRY OemSetup( HWND hwndOwner,          /* These parameters need     */
  48.                         PSZ  pszSourcePath,      /* to be specified, because  */
  49.                         PSZ  pszDestination,     /* INSTALL expects to call   */
  50.                         PSZ  pszSSDllInput,      /* the entry point as such   */
  51.                         HWND hwndObject,         /* In this example, only     */
  52.                         PSZ  achResponse)        /* pszDestination is used    */
  53. {
  54.   CHAR     szResourceDll[255];
  55.   CHAR     ErrorBuffer[100];
  56.   HMODULE  hMod;
  57.   APIRET   apiret;
  58.   ULONG    ulDrive;
  59.   ULONG    ulRet;
  60.  
  61.   /************************************************************************
  62.   * Set the default drive to where OEM is installed                       *
  63.   ************************************************************************/
  64.   szResourceDll[0] = '\0';
  65.   strcpy(szResourceDll, pszDestination);
  66.   ulDrive = (ULONG)( (szResourceDll[0] - 'A')+ 1);
  67.   apiret = DosSetDefaultDisk (ulDrive);
  68.  
  69.   /************************************************************************
  70.   * Change the directory to where OEM is installed                        *
  71.   ************************************************************************/
  72.   apiret = DosSetCurrentDir ((PSZ)strchr(szResourceDll, '\\'));
  73.  
  74.   /************************************************************************
  75.   * Noe, we need to do a DosLoadModule on this module, because            *
  76.   * WinRegisterObjectClass will not be able to find the module as         *
  77.   * loaded by INSTALL (by path). By changing directory to the directory   *
  78.   * where OEM.DLL resides, and doing a DosLoadModule, WinRegisterClass    *
  79.   * will be able to find the DLL.  The result is that during install,     *
  80.   * there are 2 copies of OEM.DLL loaded.  This will be cleaned up when   *
  81.   * the user reboots the machine after installation is complete           *
  82.   *                                                                       *
  83.   ************************************************************************/
  84.   ulRet = DosLoadModule( (PSZ) ErrorBuffer,
  85.                          sizeof(ErrorBuffer),
  86.                          "OEM",
  87.                          &hMod
  88.                       );
  89.   if ( ulRet == NO_ERROR )
  90.   {
  91.      /************************************************************************
  92.      * Create the Devices Folder, only if it does not already exist          *
  93.      ************************************************************************/
  94.      WinCreateObject("WPFolder",
  95.                      "Devices",
  96.                      "OBJECTID=<DEVICES_FOLDER>;HELPPANEL=40067;HELPLIBRARY=PSETUP.HLP",
  97.                      "<PPM_FOLDER>",
  98.                      CO_FAILIFEXISTS);
  99.  
  100.      /************************************************************************
  101.      * Register the class                                                    *
  102.      ************************************************************************/
  103.      WinRegisterObjectClass("oem", "OEM");
  104.  
  105.      /************************************************************************
  106.      *  Create the object in the Devices Folder                              *
  107.      ************************************************************************/
  108.      WinCreateObject("oem",
  109.                      "OEM Pen",
  110.                      "OBJECTID=<OEM_PEN>;CALPROG=CAL.EXE;CALPARMS=TRUE;PEN_DRIVER=Digitizer Mod 3;PEN_DEVICE=Pen",
  111.                      "<DEVICES_FOLDER>",
  112.                      CO_REPLACEIFEXISTS);
  113.   }
  114. }
  115.  
  116. VOID SOMLINK SOMInitModule()
  117. {
  118.    oemNewClass ( oem_MajorVersion,
  119.                  oem_MinorVersion);
  120. }
  121.  
  122. /*
  123.  *
  124.  *   overrides
  125.  */
  126.  
  127. #undef SOM_CurrentClass
  128. #define SOM_CurrentClass SOMInstance
  129. SOM_Scope ULONG   SOMLINK AddUserTypePage(oem *somSelf,
  130.     HWND hwndOem)
  131. {
  132.     PAGEINFO pageinfo;
  133.     APIRET   rc;
  134.  
  135.     /* oemData  *somThis = oemGetData(somSelf); */
  136.     oemMethodDebug("oem","AddUserTypePage");
  137.  
  138.    /*************************************************************************/
  139.    /* Setup the page information structure and then insert the page into    */
  140.    /*  the settings notebook for this object.                               */
  141.    /*************************************************************************/
  142.    memset((PCH) &pageinfo, 0, sizeof(PAGEINFO));
  143.  
  144.    if ( MyModHandle )
  145.    {
  146.       pageinfo.cb                 = sizeof(PAGEINFO);
  147.       pageinfo.hwndPage           = NULLHANDLE;
  148.       pageinfo.usPageStyleFlags   = BKA_MAJOR;
  149.       pageinfo.usPageInsertFlags  = BKA_FIRST;
  150.       pageinfo.pfnwp              = (PFNWP) OemDialogProc;
  151.       pageinfo.resid              = MyModHandle;
  152.       pageinfo.dlgid              = OEM_DIALOG;
  153.       pageinfo.pszName            = "OEM";
  154.       pageinfo.pCreateParams      = (PVOID) NULL;
  155.       pageinfo.idDefaultHelpPanel = 0;
  156.       pageinfo.pHelpSubtable      = 0L;
  157.       pageinfo.pszHelpLibraryName = NULL;
  158.       return _wpInsertSettingsPage( somSelf, hwndOem, &pageinfo );
  159.    }
  160. }
  161.  
  162. SOM_Scope BOOL   SOMLINK wpAddSettingsPages(oem *somSelf,
  163.                                             HWND hwndNotebook)
  164. {
  165.     /* oemData *somThis = oemGetData(somSelf); */
  166.     oemMethodDebug("oem","wpAddSettingsPages");
  167.  
  168.     if (parent_wpAddSettingsPages(somSelf, hwndNotebook) &&
  169.         _AddUserTypePage(somSelf, hwndNotebook))
  170.        return(TRUE);
  171.     else
  172.        return(FALSE);
  173. }
  174.  
  175. #undef SOM_CurrentClass
  176. #define SOM_CurrentClass SOMMeta
  177. SOM_Scope ULONG SOMLINK oemM_wpclsQueryIconData(M_oem *somSelf,
  178.                                                 PICONINFO pIconInfo)
  179. {
  180.  
  181.     /* M_oemData *somThis = M_oemGetData(somSelf); */
  182.     M_oemMethodDebug("M_oem","oemM_wpclsQueryIcon");
  183.  
  184.     if (pIconInfo)
  185.     {
  186.        pIconInfo->fFormat = ICON_RESOURCE;
  187.        pIconInfo->hmod    = MyModHandle;
  188.        pIconInfo->resid   = ID_OBJECTICON;
  189.     }
  190.  
  191.     return (sizeof(ICONINFO));
  192. }
  193.  
  194. SOM_Scope PSZ   SOMLINK oemM_wpclsQueryTitle(M_oem *somSelf)
  195. {
  196.     /* M_oemData *somThis = M_oemGetData(somSelf); */
  197.     M_oemMethodDebug("M_oem","oemM_wpclsQueryTitle");
  198.  
  199.     return ((PSZ) "OEM Pen");
  200. }
  201.  
  202. MRESULT EXPENTRY OemDialogProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2)
  203.  
  204. {
  205.     static BOOL bDuringInit;
  206.     ULONG       ulSliderSetting;
  207.     APIRET      rc;
  208.  
  209.   switch (msg)
  210.   {
  211.      case WM_INITDLG:
  212.         /*****************************************************************
  213.         *   Perform initialization here                                  *
  214.         *****************************************************************/
  215.         return (MRESULT) FALSE;
  216.  
  217.      case WM_DESTROY:
  218.         /*****************************************************************
  219.         *   Perform clean up here                                        *
  220.         *****************************************************************/
  221.         break;
  222.  
  223.      case WM_COMMAND:
  224.      case WM_CONTROL:
  225.         return (MRESULT) FALSE;
  226.   }  /* of switch(msg)                         */
  227.  
  228.   return (WinDefDlgProc(hwndDlg, msg, mp1, mp2) );
  229. }
  230.