Source code of Windows XP (NT5)
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.

170 lines
4.5 KiB

  1. /****************************************************************************/
  2. /* */
  3. /* WFPRINT.C - */
  4. /* */
  5. /* Windows Print Routines */
  6. /* */
  7. /****************************************************************************/
  8. #include "winfile.h"
  9. #include "winexp.h"
  10. /*--------------------------------------------------------------------------*/
  11. /* */
  12. /* PrintFile() - */
  13. /* */
  14. /*--------------------------------------------------------------------------*/
  15. WORD
  16. PrintFile(
  17. HWND hwnd,
  18. LPSTR szFile
  19. )
  20. {
  21. WORD ret;
  22. INT iCurCount;
  23. INT i;
  24. HCURSOR hCursor;
  25. ret = 0;
  26. hCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
  27. iCurCount = ShowCursor(TRUE) - 1;
  28. /* open the object +++ ShellExecute() returns an hInstance?!?!?
  29. */
  30. ret = (WORD)RealShellExecute(hwnd, "print", szFile, "", NULL, NULL, NULL, NULL, SW_SHOWNORMAL, NULL);
  31. DosResetDTAAddress(); // undo any bad things COMMDLG did
  32. switch (ret) {
  33. case 0:
  34. case 8:
  35. ret = IDS_NOMEMORYMSG;
  36. break;
  37. case 2:
  38. ret = IDS_FILENOTFOUNDMSG;
  39. break;
  40. case 3:
  41. case 5: // access denied
  42. ret = IDS_BADPATHMSG;
  43. break;
  44. case 4:
  45. ret = IDS_MANYOPENFILESMSG;
  46. break;
  47. case 10:
  48. ret = IDS_NEWWINDOWSMSG;
  49. break;
  50. case 12:
  51. ret = IDS_OS2APPMSG;
  52. break;
  53. case 15:
  54. /* KERNEL has already put up a messagebox for this one. */
  55. ret = 0;
  56. break;
  57. case 16:
  58. ret = IDS_MULTIPLEDSMSG;
  59. break;
  60. case 18:
  61. ret = IDS_PMODEONLYMSG;
  62. break;
  63. case 19:
  64. ret = IDS_COMPRESSEDEXE;
  65. break;
  66. case 20:
  67. ret = IDS_INVALIDDLL;
  68. break;
  69. case SE_ERR_SHARE:
  70. ret = IDS_SHAREERROR;
  71. break;
  72. case SE_ERR_ASSOCINCOMPLETE:
  73. ret = IDS_ASSOCINCOMPLETE;
  74. break;
  75. case SE_ERR_DDETIMEOUT:
  76. case SE_ERR_DDEFAIL:
  77. case SE_ERR_DDEBUSY:
  78. ret = IDS_DDEFAIL;
  79. break;
  80. case SE_ERR_NOASSOC:
  81. ret = IDS_NOASSOCMSG;
  82. break;
  83. default:
  84. if (ret < 32)
  85. goto EPExit;
  86. ret = 0;
  87. }
  88. EPExit:
  89. i = ShowCursor(FALSE);
  90. /* Make sure that the cursor count is still balanced. */
  91. if (i != iCurCount)
  92. ShowCursor(TRUE);
  93. SetCursor(hCursor);
  94. return (ret);
  95. }
  96. /*--------------------------------------------------------------------------*/
  97. /* */
  98. /* WFPrint() - */
  99. /* */
  100. /*--------------------------------------------------------------------------*/
  101. WORD
  102. APIENTRY
  103. WFPrint(
  104. LPSTR pSel
  105. )
  106. {
  107. CHAR szFile[MAXPATHLEN];
  108. CHAR szTemp[20];
  109. WORD ret;
  110. /* Turn off the print button. */
  111. if (hdlgProgress)
  112. EnableWindow(GetDlgItem(hdlgProgress, IDOK), FALSE);
  113. bUserAbort = FALSE;
  114. if (!(pSel = GetNextFile(pSel, szFile, sizeof(szFile))))
  115. return TRUE;
  116. /* See if there is more than one file to print. Abort if so
  117. */
  118. if (pSel = GetNextFile(pSel, szTemp, sizeof(szTemp))) {
  119. MyMessageBox(hwndFrame, IDS_WINFILE, IDS_PRINTONLYONE, MB_OK | MB_ICONEXCLAMATION);
  120. return (FALSE);
  121. }
  122. if (hdlgProgress) {
  123. /* Display the name of the file being printed. */
  124. LoadString(hAppInstance, IDS_PRINTINGMSG, szTitle, 32);
  125. wsprintf(szMessage, szTitle, (LPSTR)szFile);
  126. SetDlgItemText(hdlgProgress, IDD_STATUS, szMessage);
  127. }
  128. ret = PrintFile(hdlgProgress ? hdlgProgress : hwndFrame, szFile);
  129. if (ret) {
  130. MyMessageBox(hwndFrame, IDS_EXECERRTITLE, ret, MB_OK | MB_ICONEXCLAMATION);
  131. return FALSE;
  132. }
  133. return TRUE;
  134. }