home *** CD-ROM | disk | FTP | other *** search
/ Troubleshooting Netware Systems / CSTRIAL0196.BIN / attach / msj / v10n12 / plgnplay.exe / SCHOOLUI.C < prev    next >
C/C++ Source or Header  |  1995-12-01  |  4KB  |  106 lines

  1. /*****************************************************************************/
  2. /*                                                                             */
  3. /*      SCHOOLUI.C -- User interface for School Bus sample program               */
  4. /*                                                                             */
  5. /*                                                                             */
  6. /*****************************************************************************/
  7.  
  8. #include <windows.h>
  9. #include <commctrl.h>
  10. #include <setupx.h>
  11.  
  12. #define EXPORT __export
  13.  
  14. #define Not_VxD      // to get ring-3 dcls
  15. #include <vmm.h>
  16. #define MIDL_PASS  // suppress 32-bit only #pragma pack(push)
  17. #include <configmg.h>
  18.  
  19. #include "resource.h"
  20.  
  21. BOOL WINAPI EXPORT StatusDlgProc(HWND, UINT, WPARAM, LPARAM);
  22.  
  23. ///////////////////////////////////////////////////////////////////////////////
  24. // EnumPropPages is the external interface to the Windows Device Installer.
  25. // This is used for reporting the properties of a Telepath device
  26.  
  27. BOOL WINAPI EXPORT EnumPropPages(LPDEVICE_INFO pdi,
  28.     LPFNADDPROPSHEETPAGE AddPage, LPARAM lParam)
  29.     {     // EnumPropPages
  30.     PROPSHEETPAGE status; // status property page
  31.     HPROPSHEETPAGE hstatus;
  32.  
  33.     // Create a property sheet page. The address of the structure gets
  34.     // passed as the lParam in the WM_INITDIALOG message. That's how
  35.     // we communicate the address of the DEVNODE whose properties we're
  36.     // reporting.
  37.  
  38.     status.dwSize = sizeof(PROPSHEETPAGE);
  39.     status.dwFlags = PSP_USETITLE;
  40.     _asm mov status.hInstance, ds
  41.     status.pszTemplate = MAKEINTRESOURCE(IDD_STATUS);
  42.     status.hIcon = NULL;
  43.     status.pszTitle = "Status";
  44.     status.pfnDlgProc = StatusDlgProc;
  45.     status.lParam = (LPARAM) pdi->dnDevnode;
  46.     status.pfnCallback = NULL;
  47.  
  48.     hstatus = CreatePropertySheetPage(&status);
  49.     if (!hstatus)
  50.     return TRUE;                // display property sheet even if we fail
  51.  
  52.     // Call the Device Manager back to add our page to the property sheet
  53.  
  54.     if (!AddPage(hstatus, lParam))
  55.          DestroyPropertySheetPage(hstatus);
  56.     return TRUE;
  57.     }                            // EnumPropPages
  58.  
  59. ///////////////////////////////////////////////////////////////////////////////
  60. // StatusDlgProc is the dialog procedure for our property page. Its only
  61. // function in this example is to examine the allocated configuration of
  62. // the device and display the assigned Telepathic I/O Channel number
  63.  
  64. BOOL WINAPI EXPORT StatusDlgProc(HWND hdlg, UINT msg, WPARAM wParam,
  65.     LPARAM lParam)
  66.     {                            // StatusDlgProc
  67.     switch (msg)
  68.         {                        // process message
  69.  
  70.     case WM_INITDIALOG:
  71.         {                        // WM_INITDIALOG
  72.     
  73.         // These declarations would normally be in a header file that
  74.         // you share between this property page provider and the VxD:
  75.         
  76.         #define ResType_Telepath ((0x10 << 5) | 5)
  77.         
  78.         typedef struct
  79.             {                    // telepath resource description
  80.             int allocated;        // allocated channel number
  81.             ULONG requested;    // mask for requested channels
  82.             } TELEPATH_RESOURCE;// telepath resource description
  83.             
  84.         LOG_CONF logconf;
  85.         RES_DES hres;
  86.         DEVNODE devnode = (DEVNODE) ((LPPROPSHEETPAGE) lParam)->lParam;
  87.             
  88.         //Determine which channel got assigned to this device and
  89.         // report it on our property page
  90.             
  91.         if (CM_Get_First_Log_Conf(&logconf, devnode, ALLOC_LOG_CONF) == CR_SUCCESS
  92.             && CM_Get_Next_Res_Des(&hres, (RES_DES) logconf, ResType_Telepath, NULL, 0) == CR_SUCCESS)
  93.             {                    // has telepath channel
  94.             TELEPATH_RESOURCE res;
  95.                 
  96.             CM_Get_Res_Des_Data(hres, &res, sizeof(res), 0);
  97.             if (res.allocated >= 0)
  98.                 SetDlgItemInt(hdlg, IDC_CHANNEL, res.allocated, FALSE);
  99.             }                    // has telepath channel
  100.         }                        // WM_INITDIALOG
  101.         
  102.         }                        // process message
  103.     return FALSE;
  104.     }                            // StatusDlgProc
  105.  
  106.