home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / audio / mciapp / app.h < prev    next >
C/C++ Source or Header  |  1997-10-05  |  12KB  |  488 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  4. //  ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
  5. //  TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR
  6. //  A PARTICULAR PURPOSE.
  7. //
  8. //  Copyright (C) 1993 - 1997 Microsoft Corporation. All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11. //
  12. //  app.h
  13. //
  14. //  Description:
  15. //      This is a sample application that demonstrates how to use the
  16. //      Media Control Interface (MCI) in Windows. This application is
  17. //      also useful as an MCI device tester.
  18. //
  19. //  History:
  20. //      11/ 8/92    created.
  21. //
  22. //==========================================================================;
  23.  
  24. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  25. //
  26. //  Application Version Information:
  27. //
  28. //
  29. //
  30. //
  31. //  NOTE! all string resources that will be used in app.rcv for the
  32. //  version resource information *MUST* have an explicit \0 terminator!
  33. //
  34. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  35.  
  36. #define APP_VERSION_MAJOR           4
  37. #define APP_VERSION_MINOR           0
  38. #define APP_VERSION_BUILD           0
  39. #ifdef UNICODE
  40. #define APP_VERSION_STRING_RC       "Version 4.00 (Unicode Enabled)\0"
  41. #else
  42. #define APP_VERSION_STRING_RC       "Version 4.00\0"
  43. #endif
  44.  
  45. #define APP_VERSION_NAME_RC         "mciapp.exe\0"
  46. #define APP_VERSION_BYLINE_RC       "\0"
  47. #define APP_VERSION_COMPANYNAME_RC  "Microsoft Corporation\0"
  48. #define APP_VERSION_COPYRIGHT_RC    "Copyright (C) 1985 - 1996 Microsoft Corp.\0"
  49.  
  50. #ifdef WIN32
  51. #if (defined(_X86_)) || (defined(i386))
  52. #define APP_VERSION_PRODUCTNAME_RC  "Microsoft Win32 (i386)\0"
  53. #endif
  54. #if (defined(_MIPS_)) || (defined(MIPS))
  55. #define APP_VERSION_PRODUCTNAME_RC  "Microsoft Windows NT (MIPS)\0"
  56. #endif
  57. #if (defined(_ALPHA_)) || (defined(ALPHA))
  58. #define APP_VERSION_PRODUCTNAME_RC  "Microsoft Windows NT (Alpha)\0"
  59. #endif
  60. #ifndef APP_VERSION_PRODUCTNAME_RC
  61. #define APP_VERSION_PRODUCTNAME_RC  "Microsoft Windows NT\0"
  62. #endif
  63. #else
  64. #define APP_VERSION_PRODUCTNAME_RC  "Microsoft Windows\0"
  65. #endif
  66.  
  67. #ifdef DEBUG
  68. #define APP_VERSION_DESCRIPTION_RC  "MCI Script Application (debug)\0"
  69. #else
  70. #define APP_VERSION_DESCRIPTION_RC  "MCI Script Application\0"
  71. #endif
  72.  
  73.  
  74. //
  75. //  Unicode versions (if UNICODE is defined)... the resource compiler
  76. //  cannot deal with the TEXT() macro.
  77. //
  78. #define APP_VERSION_STRING          TEXT(APP_VERSION_STRING_RC)
  79. #define APP_VERSION_NAME            TEXT(APP_VERSION_NAME_RC)
  80. #define APP_VERSION_BYLINE          TEXT(APP_VERSION_BYLINE_RC)
  81. #define APP_VERSION_COMPANYNAME     TEXT(APP_VERSION_COMPANYNAME_RC)
  82. #define APP_VERSION_COPYRIGHT       TEXT(APP_VERSION_COPYRIGHT_RC)
  83. #define APP_VERSION_PRODUCTNAME     TEXT(APP_VERSION_PRODUCTNAME_RC)
  84. #define APP_VERSION_DESCRIPTION     TEXT(APP_VERSION_DESCRIPTION_RC)
  85.  
  86.  
  87.  
  88.  
  89. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  90. //
  91. //  misc defines for misc sizes and things...
  92. //
  93. //
  94. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  95.  
  96. //
  97. //  bilingual. this allows the same identifier to be used in resource files
  98. //  and code without having to decorate the id in your code.
  99. //
  100. #ifdef RC_INVOKED
  101.     #define RCID(id)    id
  102. #else
  103.     #define RCID(id)    MAKEINTRESOURCE(id)
  104. #endif
  105.  
  106.  
  107. //
  108. //  misc. defines
  109. //
  110. #define APP_MAX_APP_NAME_CHARS      30
  111. #define APP_MAX_APP_NAME_BYTES      (APP_MAX_APP_NAME_CHARS * sizeof(TCHAR))
  112. #define APP_MAX_STRING_RC_CHARS     512
  113. #define APP_MAX_STRING_RC_BYTES     (APP_MAX_STRING_RC_CHARS * sizeof(TCHAR))
  114. #define APP_MAX_STRING_ERROR_CHARS  512
  115. #define APP_MAX_STRING_ERROR_BYTES  (APP_MAX_STRING_ERROR_CHARS * sizeof(TCHAR))
  116. #define APP_MAX_FILE_PATH_CHARS     144
  117. #define APP_MAX_FILE_PATH_BYTES     (APP_MAX_FILE_PATH_CHARS * sizeof(TCHAR))
  118. #define APP_MAX_FILE_TITLE_CHARS    16
  119. #define APP_MAX_FILE_TITLE_BYTES    (APP_MAX_FILE_TITLE_CHARS * sizeof(TCHAR))
  120.  
  121. #define APP_MAX_STRING_INT_CHARS    18
  122. #define APP_MAX_STRING_INT_BYTES    (APP_MAX_STRING_INT_CHARS * sizeof(TCHAR))
  123.  
  124. #define APP_MAX_EXT_DEFAULT_CHARS   4
  125. #define APP_MAX_EXT_DEFAULT_BYTES   (APP_MAX_EXT_DEFAULT_CHARS * sizeof(TCHAR))
  126. #define APP_MAX_EXT_FILTER_CHARS    256
  127. #define APP_MAX_EXT_FILTER_BYTES    (APP_MAX_EXT_FILTER_CHARS * sizeof(TCHAR))
  128.  
  129. #define APP_WINDOW_XOFFSET          CW_USEDEFAULT
  130. #define APP_WINDOW_YOFFSET          CW_USEDEFAULT
  131. #define APP_WINDOW_WIDTH            500 //CW_USEDEFAULT
  132. #define APP_WINDOW_HEIGHT           300 //CW_USEDEFAULT
  133.  
  134.  
  135. //
  136. //  resource defines...
  137. //
  138. #define ICON_APP                    RCID(10)
  139. #define ACCEL_APP                   RCID(15)
  140.  
  141.  
  142. //
  143. //  the application menu...
  144. //
  145. //  NOTE! for our Edit menu, we use the following defines from windows.h--
  146. //  so don't reuse these defines for menu items!
  147. //
  148. //      #define WM_CUT      0x0300
  149. //      #define WM_COPY     0x0301
  150. //      #define WM_PASTE    0x0302
  151. //      #define WM_CLEAR    0x0303
  152. //      #define WM_UNDO     0x0304
  153. //
  154. #define MENU_APP                    RCID(20)
  155. #define APP_MENU_ITEM_FILE          0
  156. #define IDM_FILE_NEW                1100
  157. #define IDM_FILE_OPEN               1101
  158. #define IDM_FILE_SAVE               1102
  159. #define IDM_FILE_SAVEAS             1103
  160. #define IDM_FILE_ABOUT              1109
  161. #define IDM_FILE_EXIT               1110
  162.  
  163. #define APP_MENU_ITEM_EDIT          1
  164. #define IDM_EDIT_SELECTALL          1200
  165.  
  166. #define APP_MENU_ITEM_DEVICE        2
  167. #define IDM_DEVICE_NONE             1300
  168. #define IDM_DEVICE_OPENLIST         1398
  169. #define IDM_DEVICE_CLOSEALL         1399
  170.  
  171. #define APP_MENU_ITEM_OPTIONS       3
  172. #define IDM_OPTIONS_EDITONLY        1400
  173. #define IDM_OPTIONS_DEBUGLOG        1401
  174. #define IDM_OPTIONS_YIELDEXEC       1402
  175. #define IDM_OPTIONS_FONT            1410
  176.  
  177.  
  178. #define IDD_ACCL_ABORT              666
  179.  
  180.  
  181.  
  182. //
  183. //  the main window control id's...
  184. //
  185. #define IDD_APP_BTN_STEP            100
  186. #define IDD_APP_BTN_STOP            IDD_APP_BTN_STEP
  187. #define IDD_APP_BTN_GO              101
  188. #define IDD_APP_BTN_RUN             102
  189. #define IDD_APP_EDIT_RUNCOUNT       103
  190. #define IDD_APP_TEXT_OUTPUT         110
  191. #define IDD_APP_EDIT_SCRIPT         150
  192. #define IDD_APP_TEXT_STATUS         175
  193. #define IDD_APP_BOX_SEPARATOR1      176
  194. #define IDD_APP_TEXT_NOTIFY         177
  195. #define IDD_APP_BOX_SEPARATOR2      178
  196. #define IDD_APP_TEXT_OPTIONS        179
  197.  
  198.  
  199. //
  200. //  misc dlg boxes...
  201. //
  202. #define DLG_ABOUT                   RCID(50)
  203. #define IDD_ABOUT_VERSION_OS        100
  204. #define IDD_ABOUT_VERSION_PLATFORM  101
  205.  
  206. #define DLG_MCIERR                  RCID(51)
  207.  
  208.  
  209. //
  210. //  current open mci devices list window...
  211. //
  212. #define DLG_MCIDEVS                 RCID(52)
  213. #define IDD_MCIDEVS_BTN_INFO        100
  214. #define IDD_MCIDEVS_LIST_OPEN       101
  215.  
  216.  
  217.  
  218. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  219. //
  220. //  string resources
  221. //
  222. //
  223. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  224.  
  225. #define IDS_APP_NAME                100
  226. #define IDS_FILE_UNTITLED           101
  227.  
  228. #define IDS_OFN_EXT_DEF             125
  229. #define IDS_OFN_EXT_FILTER          126
  230.  
  231. #define IDS_DROP_CONTINUE           150
  232.  
  233. #define IDS_EXEC_ABORT              175
  234.  
  235. #define IDS_MCI_SCRIPT_CREATED      200
  236. #define IDS_MCI_SCRIPT_OPENED       201
  237. #define IDS_MCI_SCRIPT_SAVED        202
  238. #define IDS_MCI_SCRIPT_CHANGED      203
  239.  
  240. #define IDS_MCI_NOTIFY_SUCCESSFUL   225
  241. #define IDS_MCI_NOTIFY_SUPERSEDED   226
  242. #define IDS_MCI_NOTIFY_ABORTED      227
  243. #define IDS_MCI_NOTIFY_FAILURE      228
  244. #define IDS_MCI_NOTIFY_UNKNOWN      229
  245.  
  246. #define IDS_WARN_OPEN_DEVICES       400
  247.  
  248. #define IDS_ERROR_OPEN_FAILED       500
  249.  
  250.  
  251.  
  252.  
  253.  
  254. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  255. //
  256. //  APPINIT.C -- Public helper functions
  257. //
  258. //
  259. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  260.  
  261. LRESULT FNGLOBAL AppCreate
  262. (
  263.     HWND            hwnd,
  264.     LPCREATESTRUCT  pcs
  265. );
  266.  
  267. LRESULT FNGLOBAL AppQueryEndSession
  268. (
  269.     HWND            hwnd
  270. );
  271.  
  272. LRESULT FNGLOBAL AppEndSession
  273. (
  274.     HWND            hwnd,
  275.     BOOL            fEndSession
  276. );
  277.  
  278. LRESULT FNGLOBAL AppClose
  279. (
  280.     HWND            hwnd
  281. );
  282.  
  283. HWND FNGLOBAL AppInit
  284. (
  285.     HINSTANCE       hinst,
  286.     HINSTANCE       hinstPrev,
  287.     LPTSTR          pszCmdLine,
  288.     int             nCmdShow
  289. );
  290.  
  291. int FNGLOBAL AppExit
  292. (
  293.     HINSTANCE       hinst,
  294.     int             nResult
  295. );
  296.  
  297.  
  298. LRESULT FNGLOBAL AppGetWindowsVersion
  299. (
  300.     PTSTR           pszEnvironment,
  301.     PTSTR           pszPlatform
  302. );
  303.  
  304. LRESULT FNGLOBAL AppWinIniChange
  305. (
  306.     HWND            hwnd,
  307.     LPCTSTR         pszSection
  308. );
  309.  
  310. HFONT FNGLOBAL AppChooseFont
  311. (
  312.     HWND            hwnd,
  313.     HFONT           hFont,
  314.     PLOGFONT        plf
  315. );
  316.  
  317.  
  318. #define APP_CFF_NORMAL          0x0000
  319. #define APP_CFF_ITALIC          0x0001
  320. #define APP_CFF_UNDERLINE       0x0002
  321. #define APP_CFF_STRIKEOUT       0x0004
  322. #define APP_CFF_BOLD            0x0008
  323.  
  324. BOOL FNEXPORT AboutDlgProc
  325. (
  326.     HWND            hwnd,
  327.     UINT            uMsg,
  328.     WPARAM          wParam,
  329.     LPARAM          lParam
  330. );
  331.  
  332.  
  333. BOOL FNGLOBAL AppProfileWriteBytes
  334. (
  335.     PCTSTR          pszKey,
  336.     LPBYTE          pbStruct,
  337.     UINT            cbStruct
  338. );
  339.  
  340. BOOL FNGLOBAL AppProfileReadBytes
  341. (
  342.     PCTSTR          pszKey,
  343.     LPBYTE          pbStruct,
  344.     UINT            cbStruct
  345. );
  346.  
  347.  
  348. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  349. //
  350. //  APP.C -- Public helper functions
  351. //
  352. //
  353. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  354.  
  355. int FNCGLOBAL AppMsgBox
  356. (
  357.     HWND            hwnd,
  358.     UINT            fuStyle,
  359.     PCTSTR          pszFormat,
  360.     ...
  361. );
  362.  
  363. int FNCGLOBAL AppMsgBoxId
  364. (
  365.     HWND            hwnd,
  366.     UINT            fuStyle,
  367.     UINT            uIdsFormat,
  368.     ...
  369. );
  370.  
  371. void FNGLOBAL AppHourGlass
  372. (
  373.     BOOL            fHourGlass
  374. );
  375.  
  376. BOOL FNGLOBAL AppYield
  377. (
  378.     HWND            hwnd,
  379.     BOOL            fIsDialog
  380. );
  381.  
  382. int FNGLOBAL AppDialogBox
  383. (
  384.     HWND            hwnd,
  385.     LPCTSTR         pszDlg,
  386.     DLGPROC         pfnDlg,
  387.     LPARAM          lParam
  388. );
  389.  
  390. BOOL FNGLOBAL AppTitle
  391. (
  392.     HWND            hwnd,
  393.     PCTSTR          pszFileTitle
  394. );
  395.  
  396. int FNCGLOBAL AppSetWindowText
  397. (
  398.     HWND            hwnd,
  399.     PCTSTR          pszFormat,
  400.     ...
  401. );
  402.  
  403. int FNCGLOBAL AppSetWindowTextId
  404. (
  405.     HWND            hwnd,
  406.     UINT            uIdsFormat,
  407.     ...
  408. );
  409.  
  410. BOOL FNGLOBAL AppGetFileTitle
  411. (
  412.     PCTSTR          pszFilePath,
  413.     PTSTR           pszFileTitle
  414. );
  415.  
  416. BOOL FNGLOBAL AppGetFileName
  417. (
  418.     HWND            hwnd,
  419.     PTSTR           pszFilePath,
  420.     PTSTR           pszFileTitle,
  421.     UINT            fuFlags
  422. );
  423.  
  424. BOOL FNGLOBAL AppFileNew
  425. (
  426.     HWND            hwnd,
  427.     PTSTR           pszFilePath,
  428.     PTSTR           pszFileTitle
  429. );
  430.  
  431.  
  432. //
  433. //  fuFlags for AppGetFileName()...
  434. //
  435. #define APP_GFNF_OPEN       0x0000
  436. #define APP_GFNF_SAVE       0x0001
  437.  
  438.  
  439. BOOL FNGLOBAL AppFileSave
  440. (
  441.     HWND            hwnd,
  442.     PTSTR           pszFilePath,
  443.     PTSTR           pszFileTitle,
  444.     BOOL            fSaveAs
  445. );
  446.  
  447.  
  448. LRESULT FNEXPORT AppWndProc
  449. (
  450.     HWND            hwnd,
  451.     UINT            uMsg,
  452.     WPARAM          wParam,
  453.     LPARAM          lParam
  454. );
  455.  
  456.  
  457. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  458. //
  459. //  global variables, etc.
  460. //
  461. //
  462. //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ;
  463.  
  464. //
  465. //  flags for gfuAppOptions
  466. //
  467. #define APP_OPTF_EDITONLY       0x0001
  468. #define APP_OPTF_YIELDEXEC      0x0002
  469. #define APP_OPTF_DEBUGLOG       0x0004
  470. #ifdef UNICODE
  471. #define APP_OPTF_UNICODE        0x0008
  472. #endif
  473.  
  474. #define APP_OPTF_DEVICELIST     0x8000
  475.  
  476.  
  477. extern HINSTANCE    ghinst;
  478. extern UINT         gfuAppOptions;
  479.  
  480. extern TCHAR        gszAppSection[];
  481. extern TCHAR        gszNull[];
  482.  
  483. extern TCHAR        gszAppName[APP_MAX_APP_NAME_CHARS];
  484. extern TCHAR        gszFileUntitled[APP_MAX_FILE_TITLE_CHARS];
  485. extern TCHAR        gszAppFileTitle[APP_MAX_FILE_TITLE_CHARS];
  486. extern TCHAR        gszAppFilePath[APP_MAX_FILE_PATH_CHARS];
  487.  
  488.