SCHOOLUI.C
Upload User: linklycbj
Upload Date: 2009-11-12
Package Size: 447k
Code Size: 3k
Category:

Windows Develop

Development Platform:

WINDOWS

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