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.

794 lines
25 KiB

  1. /*****************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 2000
  4. *
  5. * TITLE: seltemp.cpp
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: RickTu
  10. *
  11. * DATE: 10/18/00
  12. *
  13. * DESCRIPTION: Implements code for the template selection page of the
  14. * print photos wizard...
  15. *
  16. *****************************************************************************/
  17. #include <precomp.h>
  18. #pragma hdrstop
  19. #define TILE_TITLE 0
  20. #define TILE_DESCRIPTION 1
  21. #define TILE_MAX 1
  22. #define LVS_EX_FLAGS (LVS_EX_DOUBLEBUFFER|LVS_EX_FULLROWSELECT)
  23. const UINT c_auTileColumns[] = {TILE_TITLE, TILE_DESCRIPTION};
  24. const UINT c_auTileSubItems[] = {TILE_DESCRIPTION};
  25. /*****************************************************************************
  26. CSelectTemplatePage -- constructor/desctructor
  27. <Notes>
  28. *****************************************************************************/
  29. CSelectTemplatePage::CSelectTemplatePage( CWizardInfoBlob * pBlob )
  30. : _hDlg(NULL),
  31. _pPreview(NULL),
  32. _hPrevWnd(NULL),
  33. _iFirstItemInListViewIndex(-1),
  34. _bAlreadySetSelection(FALSE),
  35. _bListviewIsDirty(TRUE)
  36. {
  37. WIA_PUSH_FUNCTION_MASK((TRACE_PAGE_SEL_TEMPLATE, TEXT("CSelectTemplatePage::CSelectTemplatePage()")));
  38. _pWizInfo = pBlob;
  39. _pWizInfo->AddRef();
  40. }
  41. CSelectTemplatePage::~CSelectTemplatePage()
  42. {
  43. WIA_PUSH_FUNCTION_MASK((TRACE_PAGE_SEL_TEMPLATE, TEXT("CSelectTemplatePage::~CSelectTemplatePage()")));
  44. if (_pPreview)
  45. {
  46. delete _pPreview;
  47. _pPreview = NULL;
  48. }
  49. if (_pWizInfo)
  50. {
  51. _pWizInfo->Release();
  52. _pWizInfo = NULL;
  53. }
  54. }
  55. /*****************************************************************************
  56. CSelectTemplatePage::_PopulateTemplateListView()
  57. Populates list of templates w/template info...
  58. *****************************************************************************/
  59. VOID CSelectTemplatePage::_PopulateTemplateListView()
  60. {
  61. WIA_PUSH_FUNCTION_MASK((TRACE_PAGE_SEL_TEMPLATE, TEXT("CSelectTemplatePage::_PopulateTemplateListView()")));
  62. if (!_pWizInfo)
  63. {
  64. WIA_ERROR((TEXT("_PopulateTemplateListView: FATAL: _pWizInfo is NULL, exiting early")));
  65. return;
  66. }
  67. HWND hwndList = GetDlgItem( _hDlg, IDC_TEMPLATES );
  68. if (hwndList)
  69. {
  70. HIMAGELIST hImageList = ListView_GetImageList(hwndList, LVSIL_NORMAL);
  71. if (hImageList)
  72. {
  73. //
  74. // Loop through templates and create list view items for each one...
  75. //
  76. SIZE size = { 48,62 };
  77. INT nImageListIndex = -1;
  78. INT iCount = _pWizInfo->CountOfTemplates();
  79. CTemplateInfo * pTemplateInfo;
  80. LONGLONG liTemplateWidth = 0;
  81. LONGLONG liTemplateHeight = 0;
  82. LONGLONG liPrintAreaWidth = 0;
  83. LONGLONG liPrintAreaHeight = 0;
  84. LONGLONG liTemplateArea = 0;
  85. LONGLONG liPrintArea = 0;
  86. CSimpleString strTitle, strDesc;
  87. for (INT i = 0; i < iCount; i++)
  88. {
  89. pTemplateInfo = NULL;
  90. if (SUCCEEDED(_pWizInfo->GetTemplateByIndex(i,&pTemplateInfo)) && pTemplateInfo)
  91. {
  92. HBITMAP hBmp = NULL;
  93. if (SUCCEEDED(_pWizInfo->TemplateGetPreviewBitmap(i, size, &hBmp)) && hBmp)
  94. {
  95. //
  96. // If the template is > 10% larger than printable
  97. // area of printer, then don't add it to the listview
  98. // as a choice as it won't print out very good anyway...
  99. //
  100. RENDER_DIMENSIONS dim = {0};
  101. RECT rc = {0};
  102. _pWizInfo->_SetupDimensionsForPrinting( NULL, pTemplateInfo, &dim );
  103. if (SUCCEEDED(pTemplateInfo->GetNominalRectForImageableArea( &rc )))
  104. {
  105. if ( (rc.left != -1) &&
  106. (rc.top != -1) &&
  107. (rc.right != -1) &&
  108. (rc.bottom != -1)
  109. )
  110. {
  111. liTemplateWidth = (LONGLONG)(rc.right - rc.left);
  112. liTemplateHeight = (LONGLONG)(rc.bottom - rc.top);
  113. liPrintAreaWidth = (LONGLONG)dim.NominalDevicePrintArea.cx;
  114. liPrintAreaHeight = (LONGLONG)dim.NominalDevicePrintArea.cy;
  115. liTemplateArea = liTemplateWidth * liTemplateHeight;
  116. liPrintArea = liPrintAreaWidth * liPrintAreaHeight;
  117. WIA_TRACE((TEXT("_PopulateTemplateListView: Template %d area is (%ld x %ld) = %ld"),i,liTemplateWidth,liTemplateHeight,liTemplateArea));
  118. WIA_TRACE((TEXT("_PopulateTemplateListView: Print area is (%ld x %ld) = %ld"),liPrintAreaWidth,liPrintAreaHeight,liPrintArea));
  119. if (liTemplateArea)
  120. {
  121. LONGLONG liRatio = (liPrintArea * 100) / liTemplateArea;
  122. if (liRatio < 85)
  123. {
  124. WIA_TRACE((TEXT("_PopulateTemplateListView: skipping template %d"),i));
  125. continue;
  126. }
  127. }
  128. }
  129. }
  130. WIA_TRACE((TEXT("_PopulateTemplateListView: adding template %d"),i));
  131. //
  132. // If we're adding this template, then get the title
  133. // and description...
  134. //
  135. if (SUCCEEDED(pTemplateInfo->GetTitle(&strTitle)) &&
  136. SUCCEEDED(pTemplateInfo->GetDescription(&strDesc)))
  137. {
  138. nImageListIndex = ImageList_Add(hImageList, hBmp, NULL);
  139. LV_ITEM lvi = { 0 };
  140. lvi.mask = LVIF_TEXT|LVIF_PARAM;
  141. lvi.lParam = (LPARAM)i;
  142. lvi.iItem = ListView_GetItemCount(hwndList); // append
  143. if (nImageListIndex >= 0)
  144. {
  145. lvi.mask |= LVIF_IMAGE;
  146. lvi.iImage = nImageListIndex;
  147. }
  148. #ifdef TEMPLATE_GROUPING
  149. CSimpleString strGroupName;
  150. if (SUCCEEDED(pTemplateInfo->GetGroup(&strGroupName)))
  151. {
  152. //
  153. // Get the group ID for this group name...
  154. //
  155. INT iGroupId = _GroupList.GetGroupId( strGroupName, hwndList );
  156. WIA_TRACE((TEXT("_PopulateTemplateListView: _GroupList.GetGroupId( %s ) returned %d"),strGroupName.String(),iGroupId));
  157. //
  158. // Set the item to be in the group...
  159. //
  160. if (-1 != iGroupId)
  161. {
  162. lvi.mask |= LVIF_GROUPID;
  163. lvi.iGroupId = iGroupId;
  164. }
  165. }
  166. #endif
  167. lvi.pszText = const_cast<LPTSTR>(static_cast<LPCTSTR>(strTitle));
  168. lvi.iItem = ListView_InsertItem(hwndList, &lvi);
  169. if (_iFirstItemInListViewIndex == -1)
  170. {
  171. _iFirstItemInListViewIndex = lvi.iItem;
  172. }
  173. lvi.iSubItem = 1;
  174. lvi.mask = LVIF_TEXT;
  175. lvi.pszText = const_cast<LPTSTR>(static_cast<LPCTSTR>(strDesc));
  176. ListView_SetItem(hwndList, &lvi);
  177. if (lvi.iItem != -1)
  178. {
  179. LVTILEINFO lvti;
  180. lvti.cbSize = sizeof(LVTILEINFO);
  181. lvti.iItem = lvi.iItem;
  182. lvti.cColumns = ARRAYSIZE(c_auTileSubItems);
  183. lvti.puColumns = (UINT*)c_auTileSubItems;
  184. ListView_SetTileInfo(hwndList, &lvti);
  185. }
  186. }
  187. DeleteObject( (HGDIOBJ)hBmp );
  188. }
  189. }
  190. }
  191. }
  192. _bListviewIsDirty = FALSE;
  193. }
  194. }
  195. /*****************************************************************************
  196. CSelectTemplatePage::_OnInitDialog
  197. Handles WM_INITDIALOG chores for this page...
  198. *****************************************************************************/
  199. LRESULT CSelectTemplatePage::_OnInitDialog()
  200. {
  201. WIA_PUSH_FUNCTION_MASK((TRACE_PAGE_SEL_TEMPLATE, TEXT("CSelectTemplatePage::_OnInitDialog()")));
  202. if (!_pWizInfo)
  203. {
  204. WIA_ERROR((TEXT("FATAL: _pWizInfo is NULL, exiting early")));
  205. return FALSE;
  206. }
  207. //
  208. // Set the text size of the edit control to only be 2 characters
  209. //
  210. SendDlgItemMessage( _hDlg, IDC_NUM_PICS, EM_LIMITTEXT, 2, 0 );
  211. //
  212. // Limit outselves to number only...and inform the user if they
  213. // press something other than numbers...
  214. //
  215. LIMITINPUT li = {0};
  216. li.cbSize = sizeof(li);
  217. li.dwMask = LIM_FLAGS | LIM_FILTER | LIM_MESSAGE | LIM_HINST;
  218. li.dwFlags = LIF_HIDETIPONVALID | LIF_CATEGORYFILTER;
  219. li.hinst = g_hInst;
  220. li.pszMessage = MAKEINTRESOURCE(IDS_ONLY_NUMBERS_TOOLTIP);
  221. li.pszFilter = (LPWSTR)(LICF_DIGIT | LICF_CNTRL | LICF_SPACE);
  222. SHLimitInputEditWithFlags( GetDlgItem( _hDlg, IDC_NUM_PICS ), &li );
  223. //
  224. // Set the base for the up/down control to base 10
  225. //
  226. SendDlgItemMessage( _hDlg, IDC_SPIN_PICS, UDM_SETBASE, (WPARAM)10, 0 );
  227. //
  228. // Set the range to be 1 - 99
  229. //
  230. SendDlgItemMessage( _hDlg, IDC_SPIN_PICS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(MAX_NUMBER_OF_COPIES_ALLOWED,1) );
  231. //
  232. // Set the number to 1 to begin with...
  233. //
  234. SendDlgItemMessage( _hDlg, IDC_SPIN_PICS, UDM_SETPOS, 0, (LPARAM)MAKELONG(1,0) );
  235. //
  236. // Create preview window...
  237. //
  238. RECT rcWnd = {0};
  239. HWND hwnd = GetDlgItem( _hDlg, IDC_TEMPLATE_PREVIEW );
  240. if (hwnd)
  241. {
  242. GetClientRect( hwnd, &rcWnd );
  243. MapWindowPoints( hwnd, _hDlg, (LPPOINT)&rcWnd, 2 );
  244. }
  245. CPreviewWindow::s_RegisterClass(g_hInst);
  246. _pPreview = new CPreviewWindow( _pWizInfo );
  247. _pWizInfo->SetPreviewWindowClass( _pPreview );
  248. WIA_TRACE((TEXT("g_cPreviewClassWnd = 0x%x"),g_cPreviewClassWnd));
  249. WIA_TRACE((TEXT("Calling CreateWindowEx( x=%d, y=%d, w=%d, h=%d, hWndParent=0x%x, hInstance=0x%x"),rcWnd.left,rcWnd.top,rcWnd.right-rcWnd.left,rcWnd.bottom-rcWnd.top,_hDlg,g_hInst));
  250. _hPrevWnd = CreateWindowEx( WS_EX_NOPARENTNOTIFY,
  251. (LPCTSTR)g_cPreviewClassWnd,
  252. TEXT("PhotoPrintPreviewWindow"),
  253. WS_CHILD | WS_VISIBLE,
  254. rcWnd.left,
  255. rcWnd.top,
  256. rcWnd.right - rcWnd.left,
  257. rcWnd.bottom - rcWnd.top,
  258. _hDlg,
  259. (HMENU)IDC_PREVIEW_WINDOW,
  260. g_hInst,
  261. (LPVOID)_pPreview
  262. );
  263. if (_hPrevWnd)
  264. {
  265. WIA_TRACE((TEXT("Preview window created, hwnd = 0x%x"),_hPrevWnd));
  266. _pWizInfo->SetPreviewWnd( _hPrevWnd );
  267. }
  268. else
  269. {
  270. WIA_ERROR((TEXT("Couldn't create the preview window! (GLE = %d)"),GetLastError()));
  271. }
  272. //
  273. // Initialize Template Listview control
  274. //
  275. HWND hwndList = GetDlgItem(_hDlg, IDC_TEMPLATES);
  276. if (hwndList)
  277. {
  278. //
  279. // Hide the labels and use border selection
  280. //
  281. ListView_SetExtendedListViewStyleEx( hwndList,LVS_EX_FLAGS, LVS_EX_FLAGS);
  282. for (int i=0; i<ARRAYSIZE(c_auTileColumns); i++)
  283. {
  284. LV_COLUMN col;
  285. col.mask = LVCF_SUBITEM;
  286. col.iSubItem = c_auTileColumns[i];
  287. ListView_InsertColumn(hwndList, i, &col);
  288. }
  289. //
  290. // Set up tile view for this list view..
  291. //
  292. LVTILEVIEWINFO tvi = {0};
  293. tvi.cbSize = sizeof(tvi);
  294. tvi.dwMask = LVTVIM_TILESIZE | LVTVIM_COLUMNS;
  295. tvi.dwFlags = LVTVIF_AUTOSIZE;
  296. tvi.cLines = TILE_MAX;
  297. ListView_SetTileViewInfo(hwndList, &tvi);
  298. //
  299. // Switch to tile view
  300. //
  301. ListView_SetView(hwndList, LV_VIEW_TILE);
  302. #ifdef TEMPLATE_GROUPING
  303. ListView_EnableGroupView(hwndList, TRUE);
  304. #endif
  305. //
  306. // Turn on groups
  307. //
  308. //
  309. // Get the number of templates
  310. //
  311. LONG nItemCount = _pWizInfo->CountOfTemplates();
  312. WIA_TRACE((TEXT("There are %d templates to add to the listview"),nItemCount));
  313. //
  314. // Set the item count, to minimize recomputing the list size
  315. //
  316. ListView_SetItemCount( hwndList, nItemCount );
  317. //
  318. // Create the image list for the listview...
  319. //
  320. HIMAGELIST hImageList = ImageList_Create( _pWizInfo->_sizeTemplatePreview.cx, _pWizInfo->_sizeTemplatePreview.cy, ILC_COLOR24|ILC_MIRROR, nItemCount, 50 );
  321. if (hImageList)
  322. {
  323. //
  324. // Set the image list
  325. //
  326. ListView_SetImageList( hwndList, hImageList, LVSIL_NORMAL );
  327. }
  328. else
  329. {
  330. WIA_ERROR((TEXT("FATAL: Creation of the imagelist failed!")));
  331. return FALSE;
  332. }
  333. #ifdef TEMPLATE_GROUPING
  334. //
  335. // Add only the groups which have more than one item in them...
  336. //
  337. INT iCount = _pWizInfo->CountOfTemplates();
  338. CSimpleString strGroupName;
  339. CTemplateInfo * pTemplateInfo;
  340. for (INT i=0; i < iCount; i++)
  341. {
  342. pTemplateInfo = NULL;
  343. if (SUCCEEDED(_pWizInfo->GetTemplateByIndex( i, &pTemplateInfo )) && pTemplateInfo)
  344. {
  345. if (SUCCEEDED(pTemplateInfo->GetGroup( &strGroupName )))
  346. {
  347. INT iRes;
  348. iRes = _GroupList.GetGroupId( strGroupName, hwndList );
  349. WIA_TRACE((TEXT("_GroupList.GetGroupId( %s ) return %d"),strGroupName.String(),iRes));
  350. if (-1 == iRes)
  351. {
  352. WIA_TRACE((TEXT("Adding '%s' via _GroupList.Add"),strGroupName.String()));
  353. _GroupList.Add( hwndList, strGroupName );
  354. }
  355. }
  356. }
  357. }
  358. #endif
  359. }
  360. else
  361. {
  362. WIA_ERROR((TEXT("FATAL: Couldn't get listview")));
  363. }
  364. return TRUE;
  365. }
  366. /*****************************************************************************
  367. CSelectTemplatePage::_OnDestroy
  368. Handle WM_DESTROY for this wizard page...
  369. *****************************************************************************/
  370. LRESULT CSelectTemplatePage::_OnDestroy()
  371. {
  372. WIA_PUSH_FUNCTION_MASK((TRACE_PAGE_SEL_TEMPLATE, TEXT("CSelectTemplatePage::_OnDestroy()")));
  373. //
  374. // Nuke the imagelist
  375. //
  376. HIMAGELIST hImageList = ListView_SetImageList( GetDlgItem( _hDlg, IDC_TEMPLATES ), NULL, LVSIL_NORMAL );
  377. if (hImageList)
  378. {
  379. ImageList_Destroy(hImageList);
  380. }
  381. return 0;
  382. }
  383. /*****************************************************************************
  384. SelectTemplateTimerProc
  385. Called when the timer expires for typing in the edit box
  386. *****************************************************************************/
  387. VOID CALLBACK SelectTemplateTimerProc( HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime )
  388. {
  389. WIA_PUSH_FUNCTION_MASK((TRACE_PAGE_SEL_TEMPLATE, TEXT("SelectTemplateTimerProc()")));
  390. if (idEvent == STP_TIMER_ID)
  391. {
  392. //
  393. // Kill the timer, and post a message to have the copies made and
  394. // the template previews updated...
  395. //
  396. KillTimer( hwnd, STP_TIMER_ID );
  397. PostMessage( hwnd, STP_MSG_DO_READ_NUM_PICS, 0, 0 );
  398. }
  399. }
  400. /*****************************************************************************
  401. CSelectTemplatePage::_OnCommand
  402. Handle WM_COMMAND messages sent to this page...
  403. *****************************************************************************/
  404. LRESULT CSelectTemplatePage::_OnCommand( WPARAM wParam, LPARAM lParam )
  405. {
  406. WIA_PUSH_FUNCTION_MASK((TRACE_PAGE_SEL_TEMPLATE, TEXT("CSelectTemplatePage::_OnCommand()")));
  407. if ((wParam !=0) && (wParam !=1))
  408. {
  409. WORD wCode = HIWORD(wParam);
  410. WORD wId = LOWORD(wParam);
  411. switch (wId)
  412. {
  413. case IDC_NUM_PICS:
  414. if (wCode == EN_CHANGE)
  415. {
  416. //
  417. // User changed the number of times to print each
  418. // photo. But let's start (or reset) a timer so that
  419. // we can catch multiple keystrokes and not regenerate
  420. // on each one...
  421. //
  422. SetTimer( _hDlg, STP_TIMER_ID, COPIES_TIMER_TIMEOUT_VALUE, SelectTemplateTimerProc );
  423. }
  424. break;
  425. }
  426. }
  427. return 0;
  428. }
  429. /*****************************************************************************
  430. CSelectTemplatePage::_OnNotify
  431. Handles WM_NOTIFY for this page...
  432. *****************************************************************************/
  433. LRESULT CSelectTemplatePage::_OnNotify( WPARAM wParam, LPARAM lParam )
  434. {
  435. WIA_PUSH_FUNCTION_MASK((TRACE_DLGPROC, TEXT("CSelectTemplatePage::_OnNotify()")));
  436. LONG_PTR lpRes = 0;
  437. LPNMHDR pnmh = (LPNMHDR)lParam;
  438. switch (pnmh->code)
  439. {
  440. case LVN_ITEMCHANGED:
  441. {
  442. WIA_TRACE((TEXT("CSelectTemplatePage: got LVN_ITEMCHANGED")));
  443. LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
  444. if( !(pnmv->uOldState & LVIS_SELECTED) && (pnmv->uNewState & LVIS_SELECTED) )
  445. {
  446. // update the preview picture
  447. HWND hwndList = GetDlgItem(_hDlg, IDC_TEMPLATES);
  448. if( hwndList && pnmv && 0 == pnmv->iSubItem )
  449. {
  450. _pWizInfo->SetCurrentTemplateIndex( (INT)pnmv->lParam );
  451. if (_hPrevWnd)
  452. {
  453. PostMessage( _hPrevWnd, PW_SETNEWTEMPLATE, (WPARAM)pnmv->lParam, 0 );
  454. }
  455. }
  456. }
  457. break;
  458. }
  459. case PSN_SETACTIVE:
  460. {
  461. WIA_TRACE((TEXT("CSelectTemplatePage: got PSN_SETACTIVE")));
  462. PropSheet_SetWizButtons( GetParent(_hDlg), PSWIZB_BACK | PSWIZB_NEXT );
  463. //
  464. // If the listview is dirty, then remove all entries and re-populate...
  465. //
  466. if (_bListviewIsDirty)
  467. {
  468. ListView_DeleteAllItems( GetDlgItem( _hDlg, IDC_TEMPLATES ) );
  469. _iFirstItemInListViewIndex = -1;
  470. _bAlreadySetSelection = FALSE;
  471. _PopulateTemplateListView();
  472. }
  473. RENDER_DIMENSIONS Dim;
  474. CTemplateInfo * pTemplateInfo = NULL;
  475. //
  476. // Just use first template in the list, doesn't matter for this...
  477. //
  478. if (SUCCEEDED(_pWizInfo->GetTemplateByIndex( 0, &pTemplateInfo )) && pTemplateInfo)
  479. {
  480. //
  481. // size the preview window according to the printer layout...
  482. //
  483. _pWizInfo->_SetupDimensionsForScreen( pTemplateInfo, _hPrevWnd, &Dim );
  484. }
  485. //
  486. // Invalidate the previews...
  487. //
  488. if (_pWizInfo)
  489. {
  490. if (_pWizInfo->GetPreviewsAreDirty())
  491. {
  492. _pWizInfo->InvalidateAllPreviews();
  493. _pWizInfo->SetPreviewsAreDirty(FALSE);
  494. }
  495. }
  496. //
  497. // Now that we've set up the window, generate the "still working" bitmap...
  498. //
  499. _pWizInfo->GenerateStillWorkingBitmap();
  500. //
  501. // pick the template to view...
  502. //
  503. PostMessage( _hDlg, STP_MSG_DO_SET_ACTIVE, 0, 0 );
  504. }
  505. lpRes = 0;
  506. break;
  507. case PSN_WIZNEXT:
  508. WIA_TRACE((TEXT("CSelectTemplatePage: got PSN_WIZNEXT")));
  509. //
  510. // Read and fix the number of copies if needed. We do
  511. // a sendmessage here to make sure that this completes
  512. // before we switch pages...
  513. //
  514. SendMessage(_hDlg,STP_MSG_DO_READ_NUM_PICS,0,0);
  515. lpRes = IDD_PRINT_PROGRESS;
  516. break;
  517. case PSN_WIZBACK:
  518. WIA_TRACE((TEXT("CSelectTemplatePage: got PSN_WIZBACK")));
  519. lpRes = IDD_PRINTING_OPTIONS;
  520. _bListviewIsDirty = TRUE;
  521. break;
  522. case PSN_QUERYCANCEL:
  523. WIA_TRACE((TEXT("CSelectTemplatePage: got PSN_QUERYCANCEL")));
  524. if (_pWizInfo)
  525. {
  526. lpRes = _pWizInfo->UserPressedCancel();
  527. }
  528. break;
  529. }
  530. SetWindowLongPtr( _hDlg, DWLP_MSGRESULT, lpRes );
  531. return TRUE;
  532. }
  533. /*****************************************************************************
  534. CSelectTemplatePage::DoHandleMessage
  535. Hanlder for messages sent to this page...
  536. *****************************************************************************/
  537. INT_PTR CSelectTemplatePage::DoHandleMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  538. {
  539. WIA_PUSH_FUNCTION_MASK((TRACE_DLGPROC, TEXT("CSelectTemplatePage::DoHandleMessage( uMsg = 0x%x, wParam = 0x%x, lParam = 0x%x )"),uMsg,wParam,lParam));
  540. switch ( uMsg )
  541. {
  542. case WM_INITDIALOG:
  543. _hDlg = hDlg;
  544. return _OnInitDialog();
  545. case WM_DESTROY:
  546. return _OnDestroy();
  547. case WM_COMMAND:
  548. return _OnCommand( wParam, lParam );
  549. case WM_NOTIFY:
  550. return _OnNotify( wParam, lParam );
  551. case WM_SYSCOLORCHANGE:
  552. case WM_SETTINGCHANGE:
  553. //
  554. // Forward these messages to the listview
  555. //
  556. SendDlgItemMessage( _hDlg, IDC_TEMPLATES, uMsg, wParam, lParam );
  557. break;
  558. case STP_MSG_DO_SET_ACTIVE:
  559. //
  560. // If selection has never been set, set it to the first item...
  561. //
  562. if ((_iFirstItemInListViewIndex != -1) && (!_bAlreadySetSelection))
  563. {
  564. ListView_SetItemState( GetDlgItem(_hDlg,IDC_TEMPLATES),
  565. _iFirstItemInListViewIndex,
  566. LVIS_SELECTED, LVIS_SELECTED
  567. );
  568. _bAlreadySetSelection = TRUE;
  569. }
  570. break;
  571. case STP_MSG_DO_READ_NUM_PICS:
  572. {
  573. //
  574. // Read the number of copies...
  575. //
  576. BOOL bSuccess = FALSE;
  577. BOOL bUpdate = FALSE;
  578. UINT uCopies = GetDlgItemInt( _hDlg, IDC_NUM_PICS, &bSuccess, FALSE );
  579. if (!bSuccess)
  580. {
  581. uCopies = 1;
  582. bUpdate = TRUE;
  583. }
  584. if (uCopies == 0)
  585. {
  586. uCopies = 1;
  587. bUpdate = TRUE;
  588. }
  589. if (uCopies > MAX_NUMBER_OF_COPIES_ALLOWED)
  590. {
  591. uCopies = MAX_NUMBER_OF_COPIES_ALLOWED;
  592. bUpdate = TRUE;
  593. }
  594. if (bUpdate)
  595. {
  596. SendDlgItemMessage( _hDlg, IDC_NUM_PICS, WM_CHAR, (WPARAM)TEXT("a"), 0 );
  597. SetDlgItemInt( _hDlg, IDC_NUM_PICS, uCopies, FALSE );
  598. }
  599. if (_pWizInfo)
  600. {
  601. _pWizInfo->SetNumberOfCopies( uCopies );
  602. }
  603. }
  604. break;
  605. }
  606. return FALSE;
  607. }