Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1035 lines
34 KiB

  1. /***********************************************************************
  2. MODULE : DLGPROC.C
  3. FUNCTIONS : WMFRecDlgProc
  4. EnumRangeDlgProc
  5. PlayFromListDlgProc
  6. HeaderDlgProc
  7. PlaceableHeaderDlgProc
  8. ClpHeaderDlgProc
  9. ListDlgProc
  10. About
  11. COMMENTS :
  12. HISTORY : 1/16/91 - created - drc
  13. ************************************************************************/
  14. #include "windows.h"
  15. #include "mfdcod32.h"
  16. #define GDIP_WMF_RECORD_BASE 0x00010000
  17. #define GDIP_WMF_RECORD_TO_EMFPLUS(n) ((INT)((n) | GDIP_WMF_RECORD_BASE))
  18. /***********************************************************************
  19. FUNCTION : WMFRecDlgProc
  20. PARAMETERS : HWND hDlg
  21. unsigned message
  22. WORD wParam
  23. LONG lParam
  24. PURPOSE : dialog procedure to handle the user input from the
  25. dialog box that displays the contents of the metafile
  26. record.
  27. CALLS : WINDOWS
  28. lstrcpy
  29. GlobalLock
  30. GlobalUnlock
  31. wsprintf
  32. SendDlgItemMessage
  33. EndDialog
  34. APP
  35. WaitCursor
  36. MESSAGES : WM_INITDIALOG
  37. WM_COMMAND
  38. RETURNS : BOOL
  39. COMMENTS :
  40. HISTORY : 1/16/91 - created - drc
  41. 6/30/93 - modified to work with EMF under Win32 - denniscr
  42. ************************************************************************/
  43. INT_PTR CALLBACK WMFRecDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  44. {
  45. int i;
  46. char szMetaFunction[50];
  47. HFONT hFont;
  48. static int iButton = IDB_HEX ;
  49. static RECT rcWnd = { 0, 0, 0, 0 };
  50. switch (message)
  51. {
  52. case WM_INITDIALOG:
  53. //
  54. //font for the parameters listbox
  55. //
  56. hFont = GetStockObject(ANSI_FIXED_FONT);
  57. if( rcWnd.bottom != rcWnd.top && rcWnd.right != rcWnd.left)
  58. SetWindowPos(hDlg, HWND_NOTOPMOST, rcWnd.left, rcWnd.top, rcWnd.right - rcWnd.left, rcWnd.bottom - rcWnd.top, 0 ) ;
  59. //
  60. //select that font into the parameter listbox
  61. //
  62. SendDlgItemMessage(hDlg, IDL_PARAMETERS, WM_SETFONT, (WPARAM) hFont, (LPARAM)FALSE);
  63. //
  64. //initialize the controls of the dialog box to reflect the
  65. //contents of the current metafile record
  66. //
  67. //but first, lookup the metafile function
  68. //
  69. if (bEnhMeta)
  70. {
  71. for (i = NUMMETAFUNCTIONS; i < NUMENHMETARECORDS; i++)
  72. {
  73. if (emfMetaRec.iType == emfMetaRecords[i].iType)
  74. break;
  75. }
  76. //
  77. //if not found then it is an unknown record
  78. //
  79. if (emfMetaRec.iType != emfMetaRecords[i].iType)
  80. lstrcpy((LPSTR)szMetaFunction, (LPSTR)"Unknown");
  81. else
  82. lstrcpy((LPSTR)szMetaFunction,(LPSTR)emfMetaRecords[i].szRecordName);
  83. //
  84. //init the size control
  85. //
  86. SetDlgItemInt(hDlg, IDE_RECSIZE, (UINT)emfMetaRec.nSize, FALSE);
  87. //
  88. //load the parameter listbox with the parameters displayed in hex bytes
  89. //
  90. LoadParameterLB(hDlg, (emfMetaRec.nSize - sizeof(emfMetaRec.nSize) -
  91. sizeof(emfMetaRec.iType))/sizeof(DWORD), iButton);
  92. }
  93. else
  94. {
  95. for (i = 0; i < NUMMETAFUNCTIONS; i++)
  96. {
  97. if (GDIP_WMF_RECORD_TO_EMFPLUS(MetaRec.rdFunction) == (INT)emfMetaRecords[i].iType)
  98. break;
  99. }
  100. //
  101. //if not found then it is an unknown record
  102. //
  103. if (GDIP_WMF_RECORD_TO_EMFPLUS(MetaRec.rdFunction) != (INT)emfMetaRecords[i].iType)
  104. lstrcpy((LPSTR)szMetaFunction, (LPSTR)"Unknown");
  105. else
  106. lstrcpy((LPSTR)szMetaFunction,(LPSTR)emfMetaRecords[i].szRecordName);
  107. //
  108. //init the size control
  109. //
  110. SetDlgItemInt(hDlg, IDE_RECSIZE, (DWORD)MetaRec.rdSize, FALSE);
  111. //
  112. //load the parameter listbox with the parameters displayed in hex bytes
  113. //
  114. LoadParameterLB(hDlg, MetaRec.rdSize - 3, iButton);
  115. }
  116. //
  117. //init the record number
  118. ///
  119. SetDlgItemInt(hDlg, IDE_RECNUM, iRecNum, FALSE);
  120. //
  121. //init the function name control
  122. //
  123. SetDlgItemText(hDlg, IDE_FUNCTION, (LPSTR)szMetaFunction);
  124. //
  125. //check the Hex radio button
  126. //
  127. SendDlgItemMessage(hDlg, iButton, BM_SETCHECK, TRUE, 0L);
  128. //
  129. //load the parameter listbox with the parameters displayed in hex bytes
  130. //
  131. return(TRUE);
  132. break;
  133. case WM_COMMAND:
  134. switch(LOWORD(wParam))
  135. {
  136. /* this will handle the checking and unchecking of the three buttons */
  137. case IDB_HEX:
  138. case IDB_DEC:
  139. case IDB_CHAR:
  140. case IDB_WORD:
  141. CheckRadioButton(hDlg, IDB_HEX, IDB_CHAR, LOWORD(wParam));
  142. if (bEnhMeta)
  143. LoadParameterLB(hDlg, (emfMetaRec.nSize - sizeof(emfMetaRec.nSize) -
  144. sizeof(emfMetaRec.iType))/sizeof(DWORD), LOWORD(wParam));
  145. else
  146. LoadParameterLB(hDlg, MetaRec.rdSize - 3, LOWORD(wParam));
  147. iButton = LOWORD(wParam);
  148. break;
  149. case IDGO:
  150. /* display the hourglass cursor while metafile is playing */
  151. WaitCursor(TRUE);
  152. bPlayItAll = TRUE;
  153. bEnumRange = FALSE;
  154. /* fall through with appropriate flags set */
  155. case IDOK:
  156. GetWindowRect( hDlg, &rcWnd ) ;
  157. bPlayRec = TRUE;
  158. /* fall through with appropriate flags set */
  159. case IDCANCEL:
  160. EndDialog(hDlg, TRUE);
  161. return(TRUE);
  162. break;
  163. case IDQUITENUM:
  164. /* quit the enumeration. Setup Dialogbox to return
  165. FALSE as this return value is checked in a test
  166. to end the enumeration */
  167. EndDialog(hDlg, FALSE);
  168. return(TRUE);
  169. break;
  170. default:
  171. return (FALSE);
  172. }
  173. break;
  174. default:
  175. return(FALSE);
  176. break;
  177. }
  178. return (TRUE);
  179. }
  180. /***********************************************************************
  181. FUNCTION : EnumRangeDlgProc
  182. PARAMETERS : HWND hDlg
  183. unsigned message
  184. WORD wParam
  185. LONG lParam
  186. PURPOSE : This dialog box lets the user specify whether all records
  187. or a range are to be played.
  188. CALLS : WINDOWS
  189. SendDlgItemMessage
  190. GetDlgItemInt
  191. HIWORD
  192. MessageBox
  193. SetFocus
  194. InvalidateClientRect
  195. EndDialog
  196. MESSAGES : WM_INITDIALOG
  197. WM_COMMAND
  198. RETURNS : BOOL
  199. COMMENTS :
  200. HISTORY : 1/16/91 - created - Dennis Crain
  201. ************************************************************************/
  202. INT_PTR CALLBACK EnumRangeDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  203. {
  204. BOOL lpTranslated;
  205. RECT rect;
  206. switch (message) {
  207. case WM_INITDIALOG:
  208. /* play all of the mf records is the default */
  209. SendDlgItemMessage(hDlg, IDCB_ALL, BM_SETCHECK, 1, 0L);
  210. return (TRUE);
  211. case WM_COMMAND:
  212. switch (LOWORD(wParam))
  213. {
  214. case IDE_FROM:
  215. /* if the user elects to play a range of record then
  216. turn the play all check off */
  217. if (HIWORD(wParam) == EN_CHANGE)
  218. SendDlgItemMessage(hDlg, IDCB_ALL, BM_SETCHECK, 0, 0L);
  219. break;
  220. case IDE_TO:
  221. if (HIWORD(wParam) == EN_CHANGE)
  222. SendDlgItemMessage(hDlg, IDCB_ALL, BM_SETCHECK, 0, 0L);
  223. break;
  224. case IDOK:
  225. /* if a range of records is to be played */
  226. if ( !IsDlgButtonChecked(hDlg, IDCB_ALL) ) {
  227. /* set the enumerate range flag */
  228. bEnumRange = TRUE;
  229. /* initialize the play record flag */
  230. bPlayRec = FALSE;
  231. /* get the range */
  232. iStartRange = GetDlgItemInt(hDlg, IDE_FROM, (BOOL FAR *)&lpTranslated, FALSE);
  233. /* trap the error where the start value has not been entered */
  234. if (!iStartRange) {
  235. MessageBox(hWndMain, "Invalid FROM value",
  236. NULL, MB_OK | MB_ICONEXCLAMATION);
  237. SetFocus(GetDlgItem(hDlg, IDE_FROM));
  238. break;
  239. }
  240. iEndRange = GetDlgItemInt(hDlg, IDE_TO, (BOOL FAR *)&lpTranslated, FALSE);
  241. if (!iEndRange) {
  242. MessageBox(hWndMain, "Invalid TO value",
  243. NULL, MB_OK | MB_ICONEXCLAMATION);
  244. SetFocus(GetDlgItem(hDlg, IDE_TO));
  245. break;
  246. }
  247. }
  248. /* all records are to be played */
  249. else {
  250. /* set the enumerate range to false */
  251. bEnumRange = FALSE;
  252. /* initialize the play it all flag - yes this should
  253. be false! */
  254. bPlayItAll = FALSE;
  255. /* init the play record flag */
  256. bPlayRec = TRUE;
  257. }
  258. /* force paint of the client area */
  259. GetClientRect(hWndMain, (LPRECT)&rect);
  260. InvalidateRect(hWndMain, (LPRECT)&rect, TRUE);
  261. EndDialog(hDlg, TRUE);
  262. return (TRUE);
  263. break;
  264. case IDCANCEL:
  265. /* user didn't really want to play the metafile */
  266. bEnumRange = FALSE;
  267. bPlayItAll = TRUE;
  268. bPlayRec = FALSE;
  269. EndDialog(hDlg, IDCANCEL);
  270. return (TRUE);
  271. break;
  272. default:
  273. return (FALSE);
  274. }
  275. break;
  276. }
  277. return (FALSE); /* Didn't process a message */
  278. }
  279. /***********************************************************************
  280. FUNCTION : PlayFromListDlgProc
  281. PARAMETERS : HWND hDlg
  282. unsigned message
  283. WORD wParam
  284. LONG lParam
  285. PURPOSE : a means to indicate whether the selected or unselected
  286. records among the list of metafile records are to be
  287. played.
  288. CALLS : WINDOWS
  289. SendDlgItemMessage
  290. IsDlgButtonChecked
  291. HIWORD
  292. MESSAGES : WM_INITDIALOG
  293. WM_COMMAND
  294. RETURNS : BOOL
  295. COMMENTS :
  296. HISTORY : 1/16/91 - created - Dennis Crain
  297. ************************************************************************/
  298. INT_PTR CALLBACK PlayFromListDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  299. {
  300. switch (message) {
  301. case WM_INITDIALOG:
  302. /* the default is to play the selected records */
  303. SendDlgItemMessage(hDlg, IDCB_SEL, BM_SETCHECK, 1, 0L);
  304. return (TRUE);
  305. case WM_COMMAND:
  306. switch (LOWORD(wParam))
  307. {
  308. case IDOK:
  309. /* was the play selected or play unselected button checked? */
  310. if ( IsDlgButtonChecked(hDlg, IDCB_SEL) )
  311. bPlaySelList = TRUE;
  312. else
  313. bPlaySelList = FALSE;
  314. EndDialog(hDlg, TRUE);
  315. return (TRUE);
  316. case IDCB_SEL:
  317. /* show the button click */
  318. if (HIWORD(wParam) == BN_CLICKED)
  319. SendDlgItemMessage(hDlg, IDCB_UNSEL, BM_SETCHECK, 0, 0L);
  320. break;
  321. case IDCB_UNSEL:
  322. /* show the button click */
  323. if (HIWORD(wParam) == BN_CLICKED)
  324. SendDlgItemMessage(hDlg, IDCB_SEL, BM_SETCHECK, 0, 0L);
  325. break;
  326. default:
  327. return (FALSE);
  328. }
  329. break;
  330. }
  331. return (FALSE);
  332. }
  333. /***********************************************************************
  334. FUNCTION : EnhMetaHeaderDlgProc
  335. PARAMETERS : HWND hDlg
  336. unsigned message
  337. WORD wParam
  338. LONG lParam
  339. PURPOSE : show the "standard" metafile header as described in the
  340. Windows SDK section 9.5.1 of the SDK Reference volume 2
  341. CALLS : WINDOWS
  342. wsprintf
  343. SetDlgItemText
  344. EndDialog
  345. MESSAGES : WM_INITDIALOG
  346. WM_COMMAND
  347. RETURNS : BOOL
  348. COMMENTS : Enhanced Metafile header format
  349. DWORD iType; // Record type EMR_HEADER
  350. DWORD nSize; // Record size in bytes. This may be greater
  351. // than the sizeof(ENHMETAHEADER).
  352. RECTL rclBounds; // Inclusive-inclusive bounds in device units
  353. RECTL rclFrame; // Inclusive-inclusive Picture Frame of metafile in .01 mm units
  354. DWORD dSignature; // Signature. Must be ENHMETA_SIGNATURE.
  355. DWORD nVersion; // Version number
  356. DWORD nBytes; // Size of the metafile in bytes
  357. DWORD nRecords; // Number of records in the metafile
  358. WORD nHandles; // Number of handles in the handle table
  359. // Handle index zero is reserved.
  360. WORD sReserved; // Reserved. Must be zero.
  361. DWORD nDescription; // Number of chars in the unicode description string
  362. // This is 0 if there is no description string
  363. DWORD offDescription; // Offset to the metafile description record.
  364. // This is 0 if there is no description string
  365. DWORD nPalEntries; // Number of entries in the metafile palette.
  366. SIZEL szlDevice; // Size of the reference device in pels
  367. SIZEL szlMillimeters; // Size of the reference device in millimeters
  368. HISTORY : 6/29/93 - created - Dennis Crain
  369. ************************************************************************/
  370. INT_PTR CALLBACK EnhMetaHeaderDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  371. {
  372. char szBuf[30];
  373. switch (message) {
  374. case WM_INITDIALOG:
  375. //
  376. //format the record type
  377. //
  378. wsprintf((LPSTR)szBuf, "%x", EmfPtr.lpEMFHdr->iType);
  379. SetDlgItemText(hDlg, IDC_ITYPE, (LPSTR)szBuf);
  380. //
  381. //format the size of the header
  382. //
  383. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->nSize);
  384. SetDlgItemText(hDlg, IDC_NSIZE, (LPSTR)szBuf);
  385. //
  386. //format the signature
  387. //
  388. wsprintf((LPSTR)szBuf, "%x", EmfPtr.lpEMFHdr->dSignature);
  389. SetDlgItemText(hDlg, IDC_DSIGNATURE, (LPSTR)szBuf);
  390. //
  391. //format the version
  392. //
  393. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->nVersion);
  394. SetDlgItemText(hDlg, IDC_NVERSION, (LPSTR)szBuf);
  395. //
  396. //format the size of metafile in bytes
  397. //
  398. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->nBytes);
  399. SetDlgItemText(hDlg, IDC_NBYTES, (LPSTR)szBuf);
  400. //
  401. //format the number of records
  402. //
  403. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->nRecords);
  404. SetDlgItemText(hDlg, IDC_NRECORDS, (LPSTR)szBuf);
  405. //
  406. //format the number of handles
  407. //
  408. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->nHandles);
  409. SetDlgItemText(hDlg, IDC_NHANDLES, (LPSTR)szBuf);
  410. //
  411. //format the number of chars in the description string
  412. //
  413. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->nDescription);
  414. SetDlgItemText(hDlg, IDC_NDESCRIPTION, (LPSTR)szBuf);
  415. //
  416. //format the offset to the description
  417. //
  418. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->offDescription);
  419. SetDlgItemText(hDlg, IDC_OFFDESCRIPTION, (LPSTR)szBuf);
  420. //
  421. //if a description string exists then write it to static control
  422. //
  423. if (EmfPtr.lpDescStr)
  424. SetDlgItemText(hDlg, IDC_DESCSTRING, EmfPtr.lpDescStr);
  425. //
  426. //format the number of palette entries
  427. //
  428. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->nPalEntries);
  429. SetDlgItemText(hDlg, IDC_NPALENTRIES, (LPSTR)szBuf);
  430. //
  431. //format szlDevice values
  432. //
  433. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->szlDevice.cx);
  434. SetDlgItemText(hDlg, IDC_DEVCX, (LPSTR)szBuf);
  435. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->szlDevice.cy);
  436. SetDlgItemText(hDlg, IDC_DEVCY, (LPSTR)szBuf);
  437. //
  438. //format szlMillimeters values
  439. //
  440. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->szlMillimeters.cx);
  441. SetDlgItemText(hDlg, IDC_MILLCX, (LPSTR)szBuf);
  442. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->szlMillimeters.cy);
  443. SetDlgItemText(hDlg, IDC_MILLCY, (LPSTR)szBuf);
  444. //
  445. //format rclBounds values
  446. //
  447. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->rclBounds.left);
  448. SetDlgItemText(hDlg, IDC_BOUNDSL, (LPSTR)szBuf);
  449. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->rclBounds.top);
  450. SetDlgItemText(hDlg, IDC_BOUNDST, (LPSTR)szBuf);
  451. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->rclBounds.right);
  452. SetDlgItemText(hDlg, IDC_BOUNDSR, (LPSTR)szBuf);
  453. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->rclBounds.bottom);
  454. SetDlgItemText(hDlg, IDC_BOUNDSB, (LPSTR)szBuf);
  455. //
  456. //format rclFrame values
  457. //
  458. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->rclFrame.left);
  459. SetDlgItemText(hDlg, IDC_FRAMEL, (LPSTR)szBuf);
  460. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->rclFrame.top);
  461. SetDlgItemText(hDlg, IDC_FRAMET, (LPSTR)szBuf);
  462. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->rclFrame.right);
  463. SetDlgItemText(hDlg, IDC_FRAMER, (LPSTR)szBuf);
  464. wsprintf((LPSTR)szBuf, "%d", EmfPtr.lpEMFHdr->rclFrame.bottom);
  465. SetDlgItemText(hDlg, IDC_FRAMEB, (LPSTR)szBuf);
  466. return (TRUE);
  467. case WM_COMMAND:
  468. if (LOWORD(wParam) == IDOK) {
  469. EndDialog(hDlg, TRUE);
  470. return (TRUE);
  471. }
  472. break;
  473. }
  474. return (FALSE);
  475. }
  476. /***********************************************************************
  477. FUNCTION : HeaderDlgProc
  478. PARAMETERS : HWND hDlg
  479. unsigned message
  480. WORD wParam
  481. LONG lParam
  482. PURPOSE : show the "standard" metafile header as described in the
  483. Windows SDK section 9.5.1 of the SDK Reference volume 2
  484. CALLS : WINDOWS
  485. wsprintf
  486. SetDlgItemText
  487. EndDialog
  488. MESSAGES : WM_INITDIALOG
  489. WM_COMMAND
  490. RETURNS : BOOL
  491. COMMENTS : Metafile header format
  492. WORD mtType;
  493. WORD mtHeaderSize;
  494. WORD mtVersion;
  495. DWORD mtSize;
  496. WORD mtNoObjects;
  497. DWORD mtMaxRecord;
  498. These fields have the following meanings:
  499. Field Definition
  500. mtType specifies whether the metafile is in
  501. memory or recorded in a disk file.
  502. 1 == memory 2 == disk
  503. mtHeaderSize Specifies the size in words of the metafile
  504. header
  505. mtVersion Specifies the Windows version number.
  506. mtSize Specifies the size in words of the file
  507. mtNoObjects Specifies the maximum number of objects that
  508. exist in the metafile at the same time
  509. mtMaxRecord Specifies the size in words of the largest
  510. record in the metafile.
  511. mtNoParameters Is not used
  512. HISTORY : 1/16/91 - created - Dennis Crain
  513. ************************************************************************/
  514. INT_PTR CALLBACK HeaderDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  515. {
  516. char szBuf[30];
  517. switch (message) {
  518. case WM_INITDIALOG:
  519. /* format the Windows version number */
  520. wsprintf((LPSTR)szBuf, "%x", mfHeader.mtVersion);
  521. SetDlgItemText(hDlg, IDS_VER, (LPSTR)szBuf);
  522. /* format the size of the metafile */
  523. wsprintf((LPSTR)szBuf, "%lu", mfHeader.mtSize * 2L);
  524. SetDlgItemText(hDlg, IDS_SIZE, (LPSTR)szBuf);
  525. /* format the maximum numbers of objects that exist
  526. in the metafile at the same time */
  527. wsprintf((LPSTR)szBuf, "%d", mfHeader.mtNoObjects);
  528. SetDlgItemText(hDlg, IDS_OBJECTS, (LPSTR)szBuf);
  529. /* format the size of the largest record in the metafile */
  530. wsprintf((LPSTR)szBuf, "%lu", mfHeader.mtMaxRecord);
  531. SetDlgItemText(hDlg, IDS_MAXREC, (LPSTR)szBuf);
  532. return (TRUE);
  533. case WM_COMMAND:
  534. if (LOWORD(wParam) == IDOK) {
  535. EndDialog(hDlg, TRUE);
  536. return (TRUE);
  537. }
  538. break;
  539. }
  540. return (FALSE);
  541. }
  542. /***********************************************************************
  543. FUNCTION : PlaceableHeaderDlgProc
  544. PARAMETERS : HWND hDlg
  545. unsigned message
  546. WORD wParam
  547. LONG lParam
  548. PURPOSE : show the "extended" header of Placeable Metafiles.
  549. CALLS : WINDOWS
  550. wsprintf
  551. SetDlgItemText
  552. EndDialog
  553. MESSAGES : WM_INITDIALOG
  554. WM_COMMAND
  555. RETURNS : BOOL
  556. COMMENTS : Placeable metafile format
  557. DWORD key;
  558. HANDLE hmf;
  559. RECT bbox;
  560. WORD inch;
  561. DWORD reserved;
  562. WORD checksum;
  563. char metafileData[];
  564. These fields have the following meanings:
  565. Field Definition
  566. key Binary key that uniquely identifies this
  567. file type. This must be 0x9AC6CDD7L.
  568. hmf Unused; must be zero.
  569. bbox The coordinates of a rectangle that tightly
  570. bounds the picture. These coordinates are in
  571. metafile units as defined below.
  572. inch The number of metafile units to the inch. To
  573. avoid numeric overflow in PageMaker, this value
  574. should be less than 1440.
  575. reserved A reserved double word. Must be zero.
  576. checksum A checksum of the 10 words that precede it,
  577. calculated by XORing zero with these 10 words
  578. and putting the result in the checksum field.
  579. metafileData The actual content of the Windows metafile
  580. retrieved by copying the data returned by
  581. GetMetafileBits to the file. The number of
  582. bytes should be equal to the MS-DOS file length
  583. minus 22. The content of a PageMaker placeable
  584. metafile cannot currently exceed 64K (this may
  585. have changed in 4.0).
  586. HISTORY : 1/16/91 - created - Dennis Crain
  587. ************************************************************************/
  588. INT_PTR CALLBACK PlaceableHeaderDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  589. {
  590. char szBuf[30];
  591. switch (message) {
  592. case WM_INITDIALOG:
  593. /* format the key */
  594. wsprintf((LPSTR)szBuf, "%lx", placeableWMFHeader.key);
  595. SetDlgItemText(hDlg, IDS_KEY, (LPSTR)szBuf);
  596. /* format the x origin of the bounding rectangle */
  597. wsprintf((LPSTR)szBuf, "%d", placeableWMFHeader.bbox.left);
  598. SetDlgItemText(hDlg, IDS_LEFT, (LPSTR)szBuf);
  599. /* format the x extent of the bounding rectangle */
  600. wsprintf((LPSTR)szBuf, "%d", placeableWMFHeader.bbox.right);
  601. SetDlgItemText(hDlg, IDS_RIGHT, (LPSTR)szBuf);
  602. /* format the y origin of the bounding rectangle */
  603. wsprintf((LPSTR)szBuf, "%d", placeableWMFHeader.bbox.top);
  604. SetDlgItemText(hDlg, IDS_TOP, (LPSTR)szBuf);
  605. /* format the y extent of the bounding rectangle */
  606. wsprintf((LPSTR)szBuf, "%d", placeableWMFHeader.bbox.bottom);
  607. SetDlgItemText(hDlg, IDS_BOT, (LPSTR)szBuf);
  608. /* format the number of metafile units per inch */
  609. wsprintf((LPSTR)szBuf, "%d", placeableWMFHeader.inch);
  610. SetDlgItemText(hDlg, IDS_INCH, (LPSTR)szBuf);
  611. /* format the checksum */
  612. wsprintf((LPSTR)szBuf, "%x", placeableWMFHeader.checksum);
  613. SetDlgItemText(hDlg, IDS_CHKSUM, (LPSTR)szBuf);
  614. return (TRUE);
  615. case WM_COMMAND: /* message: received a command */
  616. if (LOWORD(wParam) == IDOK) {
  617. EndDialog(hDlg, TRUE); /* Exits the dialog box */
  618. return (TRUE);
  619. }
  620. break;
  621. }
  622. return (FALSE); /* Didn't process a message */
  623. }
  624. /***********************************************************************
  625. FUNCTION : ClpHeaderDlgProc
  626. PARAMETERS : HWND hDlg
  627. unsigned message
  628. WORD wParam
  629. LONG lParam
  630. PURPOSE : show the METAFILEPICT associated with the clipboard
  631. metafile. This format is described on page 7-52 of
  632. the Windows SDK Reference Volume 2.
  633. CALLS : WINDOWS
  634. lstrcpy
  635. wsprintf
  636. SetDlgItemText
  637. EndDialog
  638. MESSAGES : WM_INITDIALOG
  639. WM_COMMAND
  640. RETURNS : BOOL
  641. COMMENTS : METAFILEPICT format
  642. int mm;
  643. int xExt;
  644. int yExt;
  645. HANDLE hMF;
  646. These fields have the following meanings:
  647. Field Definition
  648. mm specifies the mapping mode in which the picture
  649. is drawn.
  650. xExt specifies the size of the metafile picture for
  651. all modes except MM_ISOTROPIC and ANISOTROPIC
  652. modes. See SDK reference for more info.
  653. yExt as above...
  654. hMF Identifies a memory metafile.
  655. HISTORY : 1/16/91 - created - Dennis Crain
  656. 7/1/93 - modified for win32
  657. ************************************************************************/
  658. INT_PTR CALLBACK ClpHeaderDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  659. {
  660. char szBuf[30];
  661. long lmm = (lpOldMFP != NULL) ? lpOldMFP->mm : lpMFP->mm;
  662. long lxExt = (lpOldMFP != NULL) ? lpOldMFP->xExt : lpMFP->xExt;
  663. long lyExt = (lpOldMFP != NULL) ? lpOldMFP->yExt : lpMFP->yExt;
  664. switch (message) {
  665. case WM_INITDIALOG:
  666. /*format the mapping mode */
  667. lstrcpy((LPSTR)szBuf, (lmm == MM_TEXT) ? (LPSTR)"MM_TEXT" :
  668. (lmm == MM_LOMETRIC) ? (LPSTR)"MM_LOMETRIC" :
  669. (lmm == MM_HIMETRIC) ? (LPSTR)"MM_HIMETRIC" :
  670. (lmm == MM_LOENGLISH) ? (LPSTR)"MM_LOENGLISH":
  671. (lmm == MM_HIENGLISH) ? (LPSTR)"MM_HIENGLISH":
  672. (lmm == MM_TWIPS) ? (LPSTR)"MM_TWIPS" :
  673. (lmm == MM_ISOTROPIC) ? (LPSTR)"MM_ISOTROPIC":
  674. (lmm == MM_ANISOTROPIC) ? (LPSTR)"MM_ANISOTROPIC":
  675. (LPSTR)"UNKOWN");
  676. SetDlgItemText(hDlg, IDE_MM, (LPSTR)szBuf);
  677. /* format the xExt */
  678. wsprintf((LPSTR)szBuf, "%d", lxExt);
  679. SetDlgItemText(hDlg, IDE_XEXT, (LPSTR)szBuf);
  680. /* format the yExt */
  681. wsprintf((LPSTR)szBuf, "%d", lyExt);
  682. SetDlgItemText(hDlg, IDE_YEXT, (LPSTR)szBuf);
  683. return (TRUE);
  684. case WM_COMMAND:
  685. if (LOWORD(wParam) == IDOK) {
  686. EndDialog(hDlg, TRUE);
  687. return (TRUE);
  688. }
  689. break;
  690. }
  691. return (FALSE);
  692. }
  693. /***********************************************************************
  694. FUNCTION : ListDlgProc
  695. PARAMETERS : HWND hDlg
  696. unsigned message
  697. WORD wParam
  698. LONG lParam
  699. PURPOSE :
  700. CALLS : WINDOWS
  701. GetMetaFile
  702. GetDC
  703. EnumMetaFile
  704. MakeProcInstance
  705. FreeProcInstance
  706. ReleaseDC
  707. EndDialog
  708. DeleteMetaFile
  709. MessageBox
  710. SendDlgItemMessage
  711. GlobalAlloc
  712. GlobalLock
  713. DialogBox
  714. APP
  715. PlayIt
  716. MESSAGES : WM_INITDIALOG
  717. WM_COMMAND
  718. RETURNS : BOOL
  719. COMMENTS :
  720. HISTORY :
  721. ************************************************************************/
  722. void GetMetaFileAndEnum(
  723. HWND hwnd,
  724. HDC hDC,
  725. int iAction);
  726. INT_PTR CALLBACK ListDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  727. {
  728. HDC hDC;
  729. CurrenthDlg = hDlg;
  730. switch (message) {
  731. case WM_INITDIALOG:
  732. hDC = GetDC(hWndMain);
  733. //
  734. //initalize the current record number
  735. //
  736. iRecNum = 0;
  737. //
  738. //enumerate the records into the listbox
  739. //
  740. GetMetaFileAndEnum(hWndMain, hDC, ENUMMFLIST);
  741. ReleaseDC(hWndMain, hDC);
  742. return (TRUE);
  743. case WM_COMMAND:
  744. switch(LOWORD(wParam))
  745. {
  746. case IDOK:
  747. case IDCANCEL:
  748. EndDialog(hDlg, TRUE);
  749. return(TRUE);
  750. break;
  751. case IDL_PLAY:
  752. //get the number of selected items
  753. iNumSel = (DWORD) SendDlgItemMessage(hDlg,
  754. IDL_LBREC,
  755. LB_GETSELCOUNT,
  756. 0,
  757. 0L);
  758. //allocate a buffer large enough to save the indexes
  759. hSelMem = GlobalAlloc(GHND, iNumSel * sizeof(int));
  760. //lock it down and assign a long ptr to it
  761. if (hSelMem) {
  762. lpSelMem = (int FAR *)GlobalLock(hSelMem);
  763. if (!lpSelMem)
  764. return(FALSE);
  765. }
  766. else
  767. return(FALSE);
  768. //get the actual indexes and put in buffer
  769. iLBItemsInBuf = (DWORD) SendDlgItemMessage(hDlg,
  770. IDL_LBREC,
  771. LB_GETSELITEMS,
  772. (WORD)iNumSel,
  773. (LPARAM)lpSelMem);
  774. bEnumRange = FALSE;
  775. bPlayItAll = FALSE;
  776. bPlayList = TRUE;
  777. iCount = 0; //reset index into lpSelMem
  778. /*dialog to play selected or unselected records*/
  779. DialogBox(hInst,
  780. "PLAYWHAT",
  781. hDlg,
  782. PlayFromListDlgProc);
  783. /* end this dialog prematurely to get on with playing of recs */
  784. EndDialog(hDlg, TRUE);
  785. /* play the metafile to the appropriate destination */
  786. PlayMetaFileToDest(hWndMain, iDestDC);
  787. break;
  788. default:
  789. return (FALSE);
  790. }
  791. break;
  792. }
  793. return (FALSE);
  794. }
  795. /****************************************************************************
  796. FUNCTION: About(HWND, unsigned, WORD, LONG)
  797. PURPOSE: Processes messages for "About" dialog box
  798. MESSAGES:
  799. WM_INITDIALOG - initialize dialog box
  800. WM_COMMAND - Input received
  801. COMMENTS:
  802. No initialization is needed for this particular dialog box, but TRUE
  803. must be returned to Windows.
  804. Wait for user to click on "Ok" button, then close the dialog box.
  805. ****************************************************************************/
  806. INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  807. {
  808. switch (message) {
  809. case WM_INITDIALOG: /* message: initialize dialog box */
  810. return (TRUE);
  811. case WM_COMMAND: /* message: received a command */
  812. if (LOWORD(wParam) == IDOK /* "OK" box selected? */
  813. || LOWORD(wParam) == IDCANCEL) { /* System menu close command? */
  814. EndDialog(hDlg, TRUE); /* Exits the dialog box */
  815. return (TRUE);
  816. }
  817. break;
  818. }
  819. return (FALSE); /* Didn't process a message */
  820. }