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.

476 lines
11 KiB

  1. /*++
  2. 1998 Seagate Software, Inc. All rights reserved.
  3. Module Name:
  4. PropPage.cpp
  5. Abstract:
  6. Node representing our Media Set (Media Pool) within NTMS.
  7. Author:
  8. Rohde Wakefield [rohde] 04-Aug-1997
  9. Revision History:
  10. --*/
  11. #include "stdafx.h"
  12. #include "PropPage.h"
  13. #include "wizsht.h"
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CRsDialog property page
  16. CRsDialog::CRsDialog( UINT nIDTemplate, CWnd* pParent ) : CDialog( nIDTemplate, pParent )
  17. {
  18. //{{AFX_DATA_INIT(CRsDialog)
  19. // NOTE: the ClassWizard will add member initialization here
  20. //}}AFX_DATA_INIT
  21. m_pHelpIds = 0;
  22. }
  23. CRsDialog::~CRsDialog()
  24. {
  25. }
  26. BEGIN_MESSAGE_MAP(CRsDialog, CDialog)
  27. //{{AFX_MSG_MAP(CRsDialog)
  28. ON_WM_HELPINFO()
  29. ON_WM_CONTEXTMENU()
  30. //}}AFX_MSG_MAP
  31. END_MESSAGE_MAP()
  32. BOOL CRsDialog::OnHelpInfo(HELPINFO* pHelpInfo)
  33. {
  34. if( ( HELPINFO_WINDOW == pHelpInfo->iContextType ) && m_pHelpIds ) {
  35. AFX_MANAGE_STATE( AfxGetStaticModuleState( ) );
  36. //
  37. // Look through list to see if we have help for this control
  38. // If not, we want to avoid the "No Help Available" box
  39. //
  40. const DWORD * pTmp = m_pHelpIds;
  41. DWORD helpId = 0;
  42. DWORD tmpHelpId = 0;
  43. DWORD tmpCtrlId = 0;
  44. while( pTmp && *pTmp ) {
  45. //
  46. // Array is a pairing of control ID and help ID
  47. //
  48. tmpCtrlId = pTmp[0];
  49. tmpHelpId = pTmp[1];
  50. pTmp += 2;
  51. if( tmpCtrlId == (DWORD)pHelpInfo->iCtrlId ) {
  52. helpId = tmpHelpId;
  53. break;
  54. }
  55. }
  56. if( helpId != 0 ) {
  57. ::WinHelp( m_hWnd, AfxGetApp( )->m_pszHelpFilePath, HELP_CONTEXTPOPUP, helpId );
  58. }
  59. }
  60. return CDialog::OnHelpInfo(pHelpInfo);
  61. }
  62. void CRsDialog::OnContextMenu(CWnd* pWnd, CPoint point)
  63. {
  64. if( m_pHelpIds ) {
  65. AFX_MANAGE_STATE( AfxGetStaticModuleState( ) );
  66. ::WinHelp( m_hWnd, AfxGetApp( )->m_pszHelpFilePath, HELP_CONTEXTMENU, (UINT_PTR)m_pHelpIds );
  67. }
  68. }
  69. /////////////////////////////////////////////////////////////////////////////
  70. // CRsPropertyPage property page
  71. CRsPropertyPage::CRsPropertyPage( UINT nIDTemplate, UINT nIDCaption ) : CPropertyPage( nIDTemplate, nIDCaption )
  72. {
  73. //{{AFX_DATA_INIT(CRsPropertyPage)
  74. // NOTE: the ClassWizard will add member initialization here
  75. //}}AFX_DATA_INIT
  76. m_pHelpIds = 0;
  77. //
  78. // Get and save the MFC callback function.
  79. // This is so we can delete the class the dialog never gets created.
  80. //
  81. m_pMfcCallback = m_psp.pfnCallback;
  82. //
  83. // Set the call back to our callback
  84. //
  85. m_psp.pfnCallback = PropPageCallback;
  86. }
  87. CRsPropertyPage::~CRsPropertyPage()
  88. {
  89. }
  90. void CRsPropertyPage::DoDataExchange(CDataExchange* pDX)
  91. {
  92. CPropertyPage::DoDataExchange(pDX);
  93. //{{AFX_DATA_MAP(CRsPropertyPage)
  94. // NOTE: the ClassWizard will add DDX and DDV calls here
  95. //}}AFX_DATA_MAP
  96. }
  97. BEGIN_MESSAGE_MAP(CRsPropertyPage, CPropertyPage)
  98. //{{AFX_MSG_MAP(CRsPropertyPage)
  99. ON_WM_HELPINFO()
  100. ON_WM_CONTEXTMENU()
  101. //}}AFX_MSG_MAP
  102. END_MESSAGE_MAP()
  103. UINT CALLBACK
  104. CRsPropertyPage::PropPageCallback(
  105. HWND hWnd,
  106. UINT uMessage,
  107. LPPROPSHEETPAGE ppsp )
  108. {
  109. UINT rVal = 0;
  110. if( ( ppsp ) && ( ppsp->lParam ) ) {
  111. //
  112. // Get the page object from lParam
  113. //
  114. CRsPropertyPage* pPage = (CRsPropertyPage*)ppsp->lParam;
  115. if( pPage->m_pMfcCallback ) {
  116. rVal = ( pPage->m_pMfcCallback )( hWnd, uMessage, ppsp );
  117. }
  118. switch( uMessage ) {
  119. case PSPCB_CREATE:
  120. pPage->OnPageCreate( );
  121. break;
  122. case PSPCB_RELEASE:
  123. pPage->OnPageRelease( );
  124. break;
  125. }
  126. }
  127. return( rVal );
  128. }
  129. /////////////////////////////////////////////////////////////////////////////
  130. // CRsPropertyPage Font Accessor Functions
  131. #define RSPROPPAGE_FONT_IMPL( name ) \
  132. CFont CRsPropertyPage::m_##name##Font; \
  133. CFont* \
  134. CRsPropertyPage::Get##name##Font( \
  135. void \
  136. ) \
  137. { \
  138. if( 0 == (HFONT)m_##name##Font ) { \
  139. Init##name##Font( ); \
  140. } \
  141. return( &m_##name##Font ); \
  142. }
  143. RSPROPPAGE_FONT_IMPL( Shell )
  144. RSPROPPAGE_FONT_IMPL( BoldShell )
  145. RSPROPPAGE_FONT_IMPL( WingDing )
  146. RSPROPPAGE_FONT_IMPL( LargeTitle )
  147. RSPROPPAGE_FONT_IMPL( SmallTitle )
  148. void
  149. CRsPropertyPage::InitShellFont(
  150. void
  151. )
  152. {
  153. LOGFONT logfont;
  154. CFont* tempFont = GetFont( );
  155. tempFont->GetLogFont( &logfont );
  156. m_ShellFont.CreateFontIndirect( &logfont );
  157. }
  158. void
  159. CRsPropertyPage::InitBoldShellFont(
  160. void
  161. )
  162. {
  163. LOGFONT logfont;
  164. CFont* tempFont = GetFont( );
  165. tempFont->GetLogFont( &logfont );
  166. logfont.lfWeight = FW_BOLD;
  167. m_BoldShellFont.CreateFontIndirect( &logfont );
  168. }
  169. void
  170. CRsPropertyPage::InitWingDingFont(
  171. void
  172. )
  173. {
  174. CString faceName = GetWingDingFontName( );
  175. CString faceSize;
  176. faceSize.LoadString( IDS_WIZ_WINGDING_FONTSIZE );
  177. LONG height;
  178. height = _wtol( faceSize );
  179. LOGFONT logFont;
  180. memset( &logFont, 0, sizeof(LOGFONT) );
  181. logFont.lfCharSet = SYMBOL_CHARSET;
  182. logFont.lfHeight = height;
  183. lstrcpyn( logFont.lfFaceName, faceName, LF_FACESIZE );
  184. m_WingDingFont.CreatePointFontIndirect( &logFont );
  185. }
  186. void
  187. CRsPropertyPage::InitLargeTitleFont(
  188. void
  189. )
  190. {
  191. CString fontname;
  192. fontname.LoadString( IDS_WIZ_TITLE1_FONTNAME );
  193. CString faceSize;
  194. faceSize.LoadString( IDS_WIZ_TITLE1_FONTSIZE );
  195. LONG height;
  196. height = _wtol( faceSize );
  197. LOGFONT logFont;
  198. memset( &logFont, 0, sizeof(LOGFONT) );
  199. logFont.lfCharSet = DEFAULT_CHARSET;
  200. logFont.lfHeight = height;
  201. logFont.lfWeight = FW_BOLD;
  202. lstrcpyn( logFont.lfFaceName, fontname, LF_FACESIZE );
  203. m_LargeTitleFont.CreatePointFontIndirect( &logFont );
  204. }
  205. void
  206. CRsPropertyPage::InitSmallTitleFont(
  207. void
  208. )
  209. {
  210. CString fontname;
  211. fontname.LoadString( IDS_WIZ_TITLE1_FONTNAME );
  212. LOGFONT logFont;
  213. memset( &logFont, 0, sizeof(LOGFONT) );
  214. logFont.lfCharSet = DEFAULT_CHARSET;
  215. logFont.lfHeight = 80;
  216. logFont.lfWeight = FW_BOLD;
  217. lstrcpyn( logFont.lfFaceName, fontname, LF_FACESIZE );
  218. m_SmallTitleFont.CreatePointFontIndirect( &logFont );
  219. }
  220. /////////////////////////////////////////////////////////////////////////////
  221. // CRsPropertyPage message handlers
  222. //////////////////////////////////////////////////////////////////////
  223. // CRsWizardPage Class
  224. //////////////////////////////////////////////////////////////////////
  225. //////////////////////////////////////////////////////////////////////
  226. // Construction/Destruction
  227. //////////////////////////////////////////////////////////////////////
  228. CRsWizardPage::CRsWizardPage( UINT nIDTemplate, BOOL bExterior, UINT nIDTitle, UINT nIDSubtitle )
  229. : CRsPropertyPage( nIDTemplate, 0 ),
  230. m_TitleId( nIDTitle ),
  231. m_SubtitleId( nIDSubtitle ),
  232. m_ExteriorPage( bExterior )
  233. {
  234. //{{AFX_DATA_INIT(CRsWizardPage)
  235. // NOTE: the ClassWizard will add member initialization here
  236. //}}AFX_DATA_INIT
  237. }
  238. CRsWizardPage::~CRsWizardPage()
  239. {
  240. }
  241. void CRsWizardPage::DoDataExchange(CDataExchange* pDX)
  242. {
  243. CRsPropertyPage::DoDataExchange(pDX);
  244. //{{AFX_DATA_MAP(CRsWizardPage)
  245. // NOTE: the ClassWizard will add DDX and DDV calls here
  246. //}}AFX_DATA_MAP
  247. }
  248. BEGIN_MESSAGE_MAP(CRsWizardPage, CRsPropertyPage)
  249. //{{AFX_MSG_MAP(CRsWizardPage)
  250. ON_WM_CTLCOLOR( )
  251. //}}AFX_MSG_MAP
  252. END_MESSAGE_MAP()
  253. BOOL CRsWizardPage::OnInitDialog()
  254. {
  255. CRsPropertyPage::OnInitDialog();
  256. if( m_ExteriorPage ) {
  257. CWnd* pMainTitle = GetDlgItem( IDC_WIZ_TITLE );
  258. //
  259. // Set fonts
  260. //
  261. if( pMainTitle ) pMainTitle->SetFont( GetLargeTitleFont( ) );
  262. }
  263. return TRUE;
  264. }
  265. void CRsWizardPage::SetCaption( CString& strCaption )
  266. {
  267. CPropertyPage::m_strCaption = strCaption;
  268. CPropertyPage::m_psp.pszTitle = strCaption;
  269. CPropertyPage::m_psp.dwFlags |= PSP_USETITLE;
  270. }
  271. BOOL CRsPropertyPage::OnHelpInfo(HELPINFO* pHelpInfo)
  272. {
  273. if( ( HELPINFO_WINDOW == pHelpInfo->iContextType ) && m_pHelpIds ) {
  274. AFX_MANAGE_STATE( AfxGetStaticModuleState( ) );
  275. //
  276. // Look through list to see if we have help for this control
  277. // If not, we want to avoid the "No Help Available" box
  278. //
  279. const DWORD * pTmp = m_pHelpIds;
  280. DWORD helpId = 0;
  281. DWORD tmpHelpId = 0;
  282. DWORD tmpCtrlId = 0;
  283. while( pTmp && *pTmp ) {
  284. //
  285. // Array is a pairing of control ID and help ID
  286. //
  287. tmpCtrlId = pTmp[0];
  288. tmpHelpId = pTmp[1];
  289. pTmp += 2;
  290. if( tmpCtrlId == (DWORD)pHelpInfo->iCtrlId ) {
  291. helpId = tmpHelpId;
  292. break;
  293. }
  294. }
  295. if( helpId != 0 ) {
  296. ::WinHelp( m_hWnd, AfxGetApp( )->m_pszHelpFilePath, HELP_CONTEXTPOPUP, helpId );
  297. }
  298. }
  299. return CPropertyPage::OnHelpInfo(pHelpInfo);
  300. }
  301. void CRsPropertyPage::OnContextMenu(CWnd* pWnd, CPoint point)
  302. {
  303. if( m_pHelpIds ) {
  304. AFX_MANAGE_STATE( AfxGetStaticModuleState( ) );
  305. ::WinHelp( m_hWnd, AfxGetApp( )->m_pszHelpFilePath, HELP_CONTEXTMENU, (UINT_PTR)m_pHelpIds );
  306. }
  307. }
  308. HPROPSHEETPAGE CRsWizardPage::CreatePropertyPage( )
  309. {
  310. HPROPSHEETPAGE hRet = 0;
  311. //
  312. // Copy over values of m_psp into m_psp97
  313. //
  314. m_psp97.dwFlags = m_psp.dwFlags;
  315. m_psp97.hInstance = m_psp.hInstance;
  316. m_psp97.pszTemplate = m_psp.pszTemplate;
  317. m_psp97.pszIcon = m_psp.pszIcon;
  318. m_psp97.pszTitle = m_psp.pszTitle;
  319. m_psp97.pfnDlgProc = m_psp.pfnDlgProc;
  320. m_psp97.lParam = m_psp.lParam;
  321. m_psp97.pfnCallback = m_psp.pfnCallback;
  322. m_psp97.pcRefParent = m_psp.pcRefParent;
  323. //
  324. // And fill in the other values needed
  325. //
  326. m_psp97.dwSize = sizeof( m_psp97 );
  327. if( m_ExteriorPage ) {
  328. m_psp97.dwFlags |= PSP_HIDEHEADER;
  329. } else {
  330. m_Title.LoadString( m_TitleId );
  331. m_SubTitle.LoadString( m_SubtitleId );
  332. m_psp97.dwFlags |= PSP_USEHEADERTITLE | PSP_USEHEADERSUBTITLE;
  333. }
  334. m_psp97.pszHeaderTitle = m_Title;
  335. m_psp97.pszHeaderSubTitle = m_SubTitle;
  336. //
  337. // And do the create
  338. //
  339. hRet = ::CreatePropertySheetPage( (PROPSHEETPAGE*) &m_psp97 );
  340. return( hRet );
  341. }
  342. HBRUSH CRsWizardPage::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  343. {
  344. int controlId = pWnd->GetDlgCtrlID( );
  345. HBRUSH hbr = CRsPropertyPage::OnCtlColor( pDC, pWnd, nCtlColor );
  346. if( IDC_WIZ_FINAL_TEXT == controlId ) {
  347. pDC->SetBkMode( OPAQUE );
  348. hbr = (HBRUSH)::GetStockObject( WHITE_BRUSH );
  349. }
  350. return( hbr );
  351. }