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.

238 lines
7.3 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. dlgprint.c
  5. Abstract:
  6. This file implements the dialog proc for the routing
  7. print page.
  8. Environment:
  9. WIN32 User Mode
  10. Author:
  11. Wesley Witt (wesw) 17-Feb-1996
  12. --*/
  13. #include "wizard.h"
  14. #pragma hdrstop
  15. LRESULT
  16. RoutePrintDlgProc(
  17. HWND hwnd,
  18. UINT msg,
  19. WPARAM wParam,
  20. LPARAM lParam
  21. )
  22. {
  23. static DWORD CountPrinters = 0;
  24. static TCHAR DefaultPrinter[128];
  25. switch( msg ) {
  26. case WM_INITDIALOG:
  27. {
  28. PPRINTER_INFO_4 PrinterInfo;
  29. DWORD i;
  30. DWORD Cnt = 0;
  31. PrinterInfo = MyEnumPrinters( NULL, 4, &CountPrinters, 0);
  32. if (!PrinterInfo) {
  33. return FALSE;
  34. }
  35. SendDlgItemMessage(
  36. hwnd,
  37. IDC_DEST_PRINTERLIST,
  38. CB_RESETCONTENT,
  39. 0,
  40. 0
  41. );
  42. //
  43. // check the default printer
  44. //
  45. GetProfileString(
  46. TEXT("windows"),
  47. TEXT("device"),
  48. NULL,
  49. DefaultPrinter,
  50. sizeof(DefaultPrinter)
  51. );
  52. if (DefaultPrinter[0]) {
  53. SendDlgItemMessage(
  54. hwnd,
  55. IDC_DEST_PRINTERLIST,
  56. CB_ADDSTRING,
  57. 0,
  58. (LPARAM) GetString( IDS_DEFAULT_PRINTER )
  59. );
  60. }
  61. EnableWindow( GetDlgItem( hwnd, IDC_DEST_PRINTERLIST ), TRUE );
  62. CheckDlgButton( hwnd, IDC_ANS_YES, BST_CHECKED );
  63. CheckDlgButton( hwnd, IDC_ANS_NO, BST_UNCHECKED );
  64. //
  65. // add the printer names to the combobox
  66. //
  67. for (i=0; i<CountPrinters; i++) {
  68. SendDlgItemMessage(
  69. hwnd,
  70. IDC_DEST_PRINTERLIST,
  71. CB_ADDSTRING,
  72. 0,
  73. (LPARAM) PrinterInfo[i].pPrinterName
  74. );
  75. }
  76. SendDlgItemMessage(
  77. hwnd,
  78. IDC_DEST_PRINTERLIST,
  79. CB_SETCURSEL,
  80. 0,
  81. 0
  82. );
  83. SetFocus( GetDlgItem( hwnd, IDC_DEST_PRINTERLIST ));
  84. MemFree( PrinterInfo );
  85. }
  86. break;
  87. case WM_COMMAND:
  88. if (HIWORD(wParam) == BN_CLICKED) {
  89. switch (LOWORD(wParam)) {
  90. case IDC_ANS_YES:
  91. EnableWindow( GetDlgItem( hwnd, IDC_DEST_PRINTERLIST ),TRUE );
  92. SetFocus( GetDlgItem( hwnd, IDC_DEST_PRINTERLIST ));
  93. break;
  94. case IDC_ANS_NO:
  95. EnableWindow( GetDlgItem( hwnd, IDC_DEST_PRINTERLIST ), FALSE );
  96. }
  97. }
  98. break;
  99. case WM_NOTIFY:
  100. switch( ((LPNMHDR)lParam)->code ) {
  101. case PSN_SETACTIVE:
  102. if (Unattended) {
  103. UnAttendGetAnswer(
  104. UAA_ROUTE_PRINT,
  105. (LPBYTE) &WizData.RoutePrint,
  106. sizeof(WizData.RoutePrint)
  107. );
  108. if (WizData.RoutePrint) {
  109. UnAttendGetAnswer(
  110. UAA_DEST_PRINTERLIST,
  111. (LPBYTE) WizData.RoutePrinterName,
  112. sizeof(WizData.RoutePrinterName)/sizeof(WCHAR)
  113. );
  114. if (_wcsicmp( WizData.RoutePrinterName, L"<default>" ) == 0) {
  115. LPTSTR p;
  116. GetProfileString(
  117. TEXT("windows"),
  118. TEXT("device"),
  119. NULL,
  120. WizData.RoutePrinterName,
  121. sizeof(WizData.RoutePrinterName)
  122. );
  123. p = _tcschr( WizData.RoutePrinterName, TEXT(',') );
  124. if (p) {
  125. *p = 0;
  126. }
  127. }
  128. }
  129. SetWindowLong( hwnd, DWL_MSGRESULT, -1 );
  130. return TRUE;
  131. }
  132. if (InstallMode != INSTALL_NEW) {
  133. SetWindowLong( hwnd, DWL_MSGRESULT, -1 );
  134. return TRUE;
  135. }
  136. if (!CountPrinters) {
  137. //
  138. // this system does not have any printers configured
  139. // skip this wizard page
  140. //
  141. SetWindowLong( hwnd, DWL_MSGRESULT, -1 );
  142. return TRUE;
  143. }
  144. break;
  145. case PSN_WIZNEXT:
  146. WizData.RoutePrint = IsDlgButtonChecked( hwnd, IDC_ANS_YES );
  147. if (WizData.RoutePrint) {
  148. int Index = SendDlgItemMessage(
  149. hwnd,
  150. IDC_DEST_PRINTERLIST,
  151. CB_GETCURSEL,
  152. 0,
  153. 0
  154. );
  155. WizData.UseDefaultPrinter = DefaultPrinter[0] && !Index;
  156. if (WizData.UseDefaultPrinter) {
  157. LPTSTR p;
  158. GetProfileString(
  159. TEXT("windows"),
  160. TEXT("device"),
  161. NULL,
  162. WizData.RoutePrinterName,
  163. sizeof(WizData.RoutePrinterName)
  164. );
  165. p = _tcschr( WizData.RoutePrinterName, TEXT(',') );
  166. if (p) {
  167. *p = 0;
  168. }
  169. } else {
  170. SendDlgItemMessage(
  171. hwnd,
  172. IDC_DEST_PRINTERLIST,
  173. CB_GETLBTEXT,
  174. Index,
  175. (LPARAM) WizData.RoutePrinterName
  176. );
  177. }
  178. if (IsPrinterFaxPrinter( WizData.RoutePrinterName )) {
  179. PopUpMsg( hwnd, IDS_CANT_USE_FAX_PRINTER, TRUE, 0 );
  180. //
  181. // Set Focus to the combo box.
  182. //
  183. SetFocus( GetDlgItem( hwnd, IDC_DEST_PRINTERLIST ));
  184. SetWindowLong( hwnd, DWL_MSGRESULT, -1 );
  185. return TRUE;
  186. }
  187. }
  188. break;
  189. }
  190. break;
  191. }
  192. return FALSE;
  193. }