home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / directx / dxview / dxview.h < prev    next >
C/C++ Source or Header  |  1997-07-14  |  8KB  |  230 lines

  1. /****************************************************************************
  2.  
  3.     Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
  4.  
  5.     DirectX Device Viewer - Common header file
  6.  
  7. ****************************************************************************/
  8.  
  9. #include <windows.h>
  10. #ifndef RC_INVOKED
  11. #include <windowsx.h>
  12. #include <mmsystem.h>
  13. #include <commctrl.h>
  14. #include <tchar.h>
  15.  
  16. #include <ddraw.h>
  17. //#include <mmreg.h>
  18. #include <dsound.h>
  19. #include <dplay.h>
  20. #include <dplobby.h>
  21. #include <d3d.h>
  22. #include <dinput.h>
  23. #endif
  24.  
  25. //================================================================
  26. // Defines
  27. //================================================================
  28.  
  29. // Window Width and Height
  30. #define DXView_WIDTH       700
  31. #define DXView_HEIGHT      400
  32.  
  33. #define DEF_TAB_SIZE        3
  34.  
  35. // Child controls
  36. #define IDC_LV          0x2000
  37. #define IDC_TV          0x2003
  38.  
  39. // Imagelist first and last icons
  40. #define IDI_FIRSTIMAGE  IDI_DIRECTX
  41. #define IDI_LASTIMAGE   IDI_CAPSOPEN
  42.  
  43. #define IDC_SPLIT                       100
  44.  
  45. #define IDD_ABORTPRINTDLG               1001
  46.  
  47. #define IDM_EXIT                        40001
  48. #define IDM_ABOUT                       40002
  49. #define IDM_VIEWAVAIL                   40003
  50. #define IDM_VIEWALL                     40004
  51. #define IDM_PRINT                       40005
  52. #define IDM_PRINTALL                    40006
  53. #define IDM_PRINTTOFILE                 40007
  54.  
  55. #define IDI_DIRECTX                     100
  56. #define IDI_CAPS                        101
  57. #define IDI_CAPSOPEN                    102
  58.  
  59. #define IDS_PRINT_WARNING               1
  60. #define IDS_PRINT_NEEDSELECT            2
  61. #define IDS_PRINT_NOROOT                3
  62.  
  63. #define TIMER_PERIOD                    500
  64. //================================================================
  65. // Typedefs
  66. //================================================================
  67.  
  68. typedef struct 
  69. {
  70.     HDC         hdcPrint;       // In:      Printer DC
  71.     HWND        hTreeWnd;       // In:      tree window
  72.     HTREEITEM   hCurrTree;      // In:      current tree item handle
  73.     DWORD       dwCharWidth;    // In:      average char width
  74.     DWORD       dwLineHeight;   // In:      max line height
  75.     DWORD       dwCurrLine;     // In/Out:  curr line position on page
  76.     DWORD       dwCharsPerLine; // In:      maximum chars per line (based on avg. char width)
  77.     DWORD       dwLinesPerPage; // In:      maximum lines per page
  78.     DWORD       dwCurrIndent;   // In:      Current tab setting
  79.     BOOL        fStartPage;     // In/Out:  need to a start new page ?!?
  80. } PRINTCBINFO;
  81.  
  82. typedef void (*SELCALLBACK)(LPARAM lParam1, LPARAM lParam2);
  83. typedef BOOL (*PRINTCALLBACK)(LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  84.  
  85. typedef struct
  86. {
  87.     SELCALLBACK     Callback;
  88.     LPARAM          lParam1;
  89.     LPARAM          lParam2;
  90.     PRINTCALLBACK   printCallback;
  91. } NODEINFO;
  92.  
  93. typedef struct
  94. {
  95.     char *  szName;         // name of cap
  96.     DWORD   dwOffset;       // offset to cap
  97.     DWORD   dwFlag;         // bit flag for cal
  98. } CAPDEF;
  99.  
  100. typedef struct
  101. {
  102.     char *szName;         // name of cap
  103.     SELCALLBACK     Callback;
  104.     LPARAM          lParam2;
  105.     PRINTCALLBACK   printCallback;
  106. } CAPDEFS;
  107.  
  108. typedef struct
  109. {
  110.     D3DDEVICEDESC d3dDeviceDesc;
  111.     GUID* device;       // DirectDraw device (can be NULL)
  112.     GUID  driver;       // Direct3D driver
  113. } CAP3DDEVICEDESC;
  114.  
  115. typedef struct
  116. {
  117.     GUID    guidInstance;
  118.     DWORD    dwRefresh;
  119. } LV_INSTANCEGUIDSTRUCT, * LPLV_INSTANCEGUIDSTRUCT;
  120.  
  121. typedef struct LOCALAPP
  122. {
  123.     struct LOCALAPP *    lpNext;
  124.     GUID                guidApplication;
  125.     char                szAppNameA[1];
  126. } LOCALAPP, *LPLOCALAPP;
  127.  
  128. typedef struct
  129. {
  130.     HWND            hwndLV;
  131.     LPLOCALAPP     *    lp;
  132. } ENUMLOCALAPPSTRUCT, *LPENUMLOCALAPPSTRUCT;
  133.  
  134.  
  135. //================================================================
  136. // Function prototypes
  137. //================================================================
  138.  
  139. LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
  140. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  141.  
  142. BOOL InitInstance(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow, int iWidth, int iHeight);
  143.  
  144. //================================================================
  145. // DXView treeview/listview helper functions
  146. //================================================================
  147.  
  148. BOOL DXView_OnCreate(HWND hwnd);
  149. void DXView_OnCommand(HWND hwnd, WPARAM wParam);
  150. void DXView_OnSize(HWND hwnd);
  151. void DXView_OnTreeSelect(HWND hwndTV, NM_TREEVIEW *ptv);
  152. void DXView_OnListViewDblClick(HWND hwndLV, NM_LISTVIEW *plv);
  153. void DXView_Cleanup(void);
  154. void DXView_FillTree(HWND hwndTV);
  155. BOOL DXView_InitImageList(void);
  156. BOOL DXView_OnPrint (HWND hWindow, HWND hTreeView, BOOL fPrintAll);
  157. BOOL DXView_OnFile (HWND hWindow, HWND hTreeWnd,BOOL fPrintAll);
  158. void LVAddColumn(HWND hwndLV, int i, char *name, int width);
  159. int  LVAddText(HWND hwndLV, int col, const char *sz, ...);
  160. void LVDeleteAllItems(HWND hwndLV);
  161. HTREEITEM TVAddNode(HTREEITEM hParent, char *szText, 
  162.                     BOOL fKids, int iImage, 
  163.                     SELCALLBACK Callback, 
  164.                     LPARAM lParam1, LPARAM lParam2,
  165.                     PRINTCALLBACK printCallback);
  166. void AddCapsToTV(HTREEITEM hParent, CAPDEFS *pcds, LPARAM lParam1);
  167. void AddColsToLV(void);
  168. void AddCapsToLV(CAPDEF *pcd, LPVOID pv);
  169. void AddMoreCapsToLV(CAPDEF *pcd, LPVOID pv);
  170. BOOL PrintCapsToDC(CAPDEF *pcd, LPVOID pv, PRINTCBINFO * lpInfo);
  171.  
  172. // Caps add to ListView callbacks
  173. void DDAddCaps(LPARAM lParam1, LPARAM lParam2);
  174. void DSAddCaps(LPARAM lParam1, LPARAM lParam2);
  175. void DSCAddCaps(LPARAM lParam1, LPARAM lParam2);
  176. void DPAddCaps(LPARAM lParam1, LPARAM lParam2);
  177. void DPAddLocalApps(LPARAM lParam1, LPARAM lParam2);
  178. void D3AddCaps(LPARAM lParam1, LPARAM lParam2);
  179. void D3AddLineCaps(LPARAM lParam1, LPARAM lParam2);
  180. void D3AddTexF(LPARAM lParam1, LPARAM lParam2);
  181. void DDAddVideoModes(LPARAM lParam1, LPARAM lParam2);
  182. void DPAddSessions(LPARAM lParam1, LPARAM lParam2);
  183. void DDFourCCFormat(LPARAM lParam1, LPARAM lParam2);
  184.  
  185. // Caps Print Callbacks
  186. BOOL DDPrintCaps (LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  187. BOOL DSPrintCaps(LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  188. BOOL DSCPrintCaps(LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  189. BOOL DPPrintCaps(LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  190. BOOL DPPrintLocalApps(LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  191. BOOL D3PrintCaps(LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  192. BOOL DDPrintVideoModes(LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  193. BOOL DPPrintSessions(LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  194. BOOL DDPrintFourCCFormat(LPARAM lParam1, LPARAM lParam2, PRINTCBINFO * lpInfo);
  195.  
  196. // Printer Helper functions
  197. BOOL PrintStartPage (PRINTCBINFO * pci);
  198. BOOL PrintEndPage (PRINTCBINFO * pci);
  199. BOOL PrintLine (int x, int y, LPCTSTR lpszBuff, DWORD cchBuff, PRINTCBINFO * pci);
  200. BOOL PrintNextLine (PRINTCBINFO * pci);
  201.  
  202. //DirectPlay helper functions
  203. HRESULT EnumSessions( LPDIRECTPLAY3A lpDP3A );
  204. void RemoveStaleSessions();
  205. void ResetListViewRefresh( HWND hwndLV );
  206.  
  207. // DirectInput helper functions
  208. void DI_FillTree(void);
  209.  
  210. void FreeLocalAppList();
  211. void GetAppName(LPSTR szNameBuffer, LPCGUID lpguidApplication, DWORD dwBufferSize);
  212.  
  213. #ifdef DX_3D
  214. HRESULT CALLBACK D3EnumCallback(
  215.             LPGUID pid,
  216.             LPSTR lpDriverDesc,
  217.             LPSTR lpDriverName, 
  218.             LPD3DDEVICEDESC lpD3DDeviceDesc1, 
  219.             LPD3DDEVICEDESC lpD3DDeviceDesc2, 
  220.             LPVOID lpContext);
  221. #endif
  222.  
  223. //================================================================
  224. // DXView external variables
  225. //================================================================
  226.  
  227. extern HINSTANCE    g_hInstance;
  228. extern HWND         g_hwndLV;        // List view
  229. extern HWND         g_hwndTV;        // Tree view
  230.