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.

214 lines
6.7 KiB

  1. /*****************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 2000
  4. *
  5. * TITLE: seltemp.h
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: RickTu
  10. *
  11. * DATE: 10/18/00
  12. *
  13. * DESCRIPTION: Definition of class which handles dlg proc duties
  14. * for the select templates wizard page
  15. *
  16. *****************************************************************************/
  17. #ifndef _PRINT_PHOTOS_WIZARD_SELECT_TEMPLATE_DLG_PROC_
  18. #define _PRINT_PHOTOS_WIZARD_SELECT_TEMPLATE_DLG_PROC_
  19. #define STP_MSG_DO_SET_ACTIVE (WM_USER+350) // post back to ourselves to handle PSN_SETACTIVE
  20. #define STP_MSG_DO_READ_NUM_PICS (WM_USER+351) // post back to ourselves to read the number of time to use each picture
  21. #define STP_TIMER_ID 100
  22. #define MAX_NUMBER_OF_COPIES_ALLOWED 15
  23. #define COPIES_TIMER_TIMEOUT_VALUE 2000
  24. #define TEMPLATE_GROUPING 1
  25. class CSelectTemplatePage
  26. {
  27. public:
  28. CSelectTemplatePage( CWizardInfoBlob * pBlob );
  29. ~CSelectTemplatePage();
  30. INT_PTR DoHandleMessage( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  31. private:
  32. VOID _PopulateTemplateListView();
  33. // window message handlers
  34. LRESULT _OnInitDialog();
  35. LRESULT _OnDestroy();
  36. LRESULT _OnCommand( WPARAM wParam, LPARAM lParam );
  37. LRESULT _OnNotify( WPARAM wParam, LPARAM lParam );
  38. #ifdef TEMPLATE_GROUPING
  39. //
  40. // Used for icon grouping
  41. //
  42. class CListviewGroupInfo
  43. {
  44. private:
  45. CSimpleStringWide m_strGroupName;
  46. int m_nGroupId;
  47. public:
  48. CListviewGroupInfo(void)
  49. : m_strGroupName(TEXT("")),
  50. m_nGroupId(-1)
  51. {
  52. }
  53. CListviewGroupInfo( const CListviewGroupInfo &other )
  54. : m_strGroupName(other.GroupName()),
  55. m_nGroupId(other.GroupId())
  56. {
  57. }
  58. CListviewGroupInfo( const CSimpleStringWide &strGroupName, int nGroupId=-1 )
  59. : m_strGroupName(strGroupName),
  60. m_nGroupId(nGroupId)
  61. {
  62. }
  63. ~CListviewGroupInfo(void)
  64. {
  65. }
  66. CListviewGroupInfo &operator=( const CListviewGroupInfo &other )
  67. {
  68. if (this != &other)
  69. {
  70. m_strGroupName = other.GroupName();
  71. m_nGroupId = other.GroupId();
  72. }
  73. return *this;
  74. }
  75. bool operator==( const CListviewGroupInfo &other )
  76. {
  77. return (other.GroupName() == m_strGroupName);
  78. }
  79. bool operator==( const CSimpleStringWide &strGroupName )
  80. {
  81. return (strGroupName == m_strGroupName);
  82. }
  83. CSimpleStringWide GroupName(void) const
  84. {
  85. return m_strGroupName;
  86. }
  87. int GroupId(void) const
  88. {
  89. return m_nGroupId;
  90. }
  91. };
  92. class CGroupList : public CSimpleDynamicArray<CListviewGroupInfo>
  93. {
  94. private:
  95. CGroupList( const CGroupList & );
  96. CGroupList& operator=( const CGroupList & );
  97. public:
  98. CGroupList(void)
  99. {
  100. }
  101. ~CGroupList(void)
  102. {
  103. }
  104. int Add( HWND hwndList, const CSimpleString &strGroupName )
  105. {
  106. int nResult = -1;
  107. if (strGroupName.Length())
  108. {
  109. LVGROUP LvGroup = {0};
  110. LvGroup.cbSize = sizeof(LvGroup);
  111. LvGroup.pszHeader = const_cast<LPTSTR>(strGroupName.String());
  112. LvGroup.mask = LVGF_HEADER | LVGF_ALIGN | LVGF_GROUPID | LVGF_STATE;
  113. LvGroup.uAlign = LVGA_HEADER_LEFT;
  114. LvGroup.iGroupId = Size();
  115. LvGroup.state = LVGS_NORMAL;
  116. nResult = static_cast<int>(ListView_InsertGroup( hwndList, Size(), &LvGroup ));
  117. WIA_TRACE((TEXT("ListView_InsertGroup on %s returned %d"), strGroupName.String(), nResult ));
  118. if (nResult >= 0)
  119. {
  120. Append( CListviewGroupInfo( strGroupName, nResult ) );
  121. }
  122. }
  123. return nResult;
  124. }
  125. int GetGroupId( const CSimpleString &strGroupName, HWND hwndList )
  126. {
  127. WIA_PUSH_FUNCTION((TEXT("GetGroupId(%s)"),strGroupName.String()));
  128. int nResult = -1;
  129. if (Size())
  130. {
  131. nResult = (*this)[0].GroupId();
  132. if (strGroupName.Length())
  133. {
  134. int nIndex = Find(strGroupName);
  135. if (nIndex < 0)
  136. {
  137. LVGROUP LvGroup = {0};
  138. LvGroup.cbSize = sizeof(LvGroup);
  139. LvGroup.pszHeader = const_cast<LPTSTR>(strGroupName.String());
  140. LvGroup.mask = LVGF_HEADER | LVGF_ALIGN | LVGF_GROUPID | LVGF_STATE;
  141. LvGroup.uAlign = LVGA_HEADER_LEFT;
  142. LvGroup.iGroupId = Size();
  143. LvGroup.state = LVGS_NORMAL;
  144. nResult = static_cast<int>(ListView_InsertGroup( hwndList, Size(), &LvGroup ));
  145. WIA_TRACE((TEXT("ListView_InsertGroup on %s returned %d"), strGroupName.String(), nResult ));
  146. if (nResult >= 0)
  147. {
  148. Append( CListviewGroupInfo( strGroupName, nResult ) );
  149. }
  150. }
  151. else
  152. {
  153. nResult = (*this)[nIndex].GroupId();
  154. }
  155. }
  156. }
  157. return nResult;
  158. }
  159. int FindGroupId( const CSimpleString &strGroupName, HWND hwndList )
  160. {
  161. WIA_PUSH_FUNCTION((TEXT("FindGroupId(%s)"),strGroupName.String()));
  162. int nResult = -1;
  163. if (Size())
  164. {
  165. nResult = (*this)[0].GroupId();
  166. if (strGroupName.Length())
  167. {
  168. int nIndex = Find(strGroupName);
  169. if (nIndex >= 0)
  170. {
  171. nResult = (*this)[nIndex].GroupId();
  172. }
  173. }
  174. }
  175. return nResult;
  176. }
  177. };
  178. CGroupList _GroupList;
  179. #endif
  180. private:
  181. CWizardInfoBlob * _pWizInfo;
  182. CPreviewWindow * _pPreview;
  183. HWND _hPrevWnd;
  184. HWND _hDlg;
  185. INT _iFirstItemInListViewIndex;
  186. BOOL _bAlreadySetSelection;
  187. BOOL _bListviewIsDirty;
  188. };
  189. #endif