SplashDlg.cpp
上传用户:cding2008
上传日期:2007-01-03
资源大小:1812k
文件大小:6k
源码类别:

OpenGL

开发平台:

Visual C++

  1. /////////////////////////////////////////////////////////////////////////////
  2. // SplashDlg.cpp : implementation file
  3. //
  4. // ModelMagic 3D and 'glOOP' (OpenGL Object Oriented Programming library)
  5. // Copyright (c) Craig Fahrnbach 1997, 1999
  6. //
  7. // OpenGL is a registered trademark of Silicon Graphics
  8. //
  9. //
  10. // This program is provided for educational and personal use only and
  11. // is provided without guarantee or warrantee expressed or implied.
  12. //
  13. // Commercial use is strickly prohibited without written permission
  14. // from ImageWare Development.
  15. //
  16. /////////////////////////////////////////////////////////////////////////////
  17. #include "stdafx.h"
  18. #include "ModelMagic3D.h"
  19. #include "SplashDlg.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CSplashDlg local variables
  27. static CSplashDlg* c_pStartupDlg;
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CSplashDlg dialog
  30. void CSplashDlg::ShowSplashDlg(CWnd* pParentWnd /*= NULL*/)
  31. {
  32. c_pStartupDlg = new CSplashDlg;
  33. if(c_pStartupDlg->Create(IDD_SPLASH_DIALOG, pParentWnd))
  34. {
  35. c_pStartupDlg->CenterWindow();
  36. c_pStartupDlg->ShowWindow(SW_SHOW);
  37. }
  38. }
  39. CSplashDlg::CSplashDlg(CWnd* pParent /*=NULL*/)
  40. : CDialog(CSplashDlg::IDD, pParent)
  41. {
  42. //{{AFX_DATA_INIT(CSplashDlg)
  43. m_szDaysToGo = _T("");
  44. m_szDaysGrace = _T("");
  45. //}}AFX_DATA_INIT
  46. }
  47. void CSplashDlg::DoDataExchange(CDataExchange* pDX)
  48. {
  49. CDialog::DoDataExchange(pDX);
  50. //{{AFX_DATA_MAP(CSplashDlg)
  51. DDX_Text(pDX, IDC_DAYSTOGO, m_szDaysToGo);
  52. DDX_Text(pDX, IDC_DAYSGRACE, m_szDaysGrace);
  53. //}}AFX_DATA_MAP
  54. }
  55. BEGIN_MESSAGE_MAP(CSplashDlg, CDialog)
  56. //{{AFX_MSG_MAP(CSplashDlg)
  57. ON_BN_CLICKED(IDC_ORDER_FORM, OnOrderForm)
  58. ON_BN_CLICKED(IDC_ORDER_ONLINE, OnOrderOnline)
  59. ON_BN_CLICKED(IDC_CONTINUE, OnContinue)
  60. ON_WM_DESTROY()
  61. ON_WM_PAINT()
  62. //}}AFX_MSG_MAP
  63. END_MESSAGE_MAP()
  64. /////////////////////////////////////////////////////////////////////////////
  65. // CSplashDlg message handlers
  66. BOOL CSplashDlg::OnInitDialog() 
  67. {
  68. // Create the text windows
  69. CRect rect;
  70. GetDlgItem(IDC_DAYSTOGO)->GetWindowRect(&rect);
  71. ScreenToClient(&rect);
  72. if(!m_wndDaysToGo.Create(NULL, // lpszClassName
  73.  NULL, // lpszWindowName
  74.  WS_CHILD | WS_VISIBLE, // dwStyle
  75.  rect, // rect
  76.  this, // CWnd* pParentWnd
  77.  IDC_DAYSTOGO, // UINT  nID
  78.  0)) // pContext
  79. return (-1);
  80. // Create the grace period text window
  81. GetDlgItem(IDC_DAYSGRACE)->GetWindowRect(&rect);
  82. ScreenToClient(&rect);
  83. if(!m_wndDaysGrace.Create(NULL, // lpszClassName
  84.  NULL, // lpszWindowName
  85.  WS_CHILD | WS_VISIBLE, // dwStyle
  86.  rect, // rect
  87.  this, // CWnd* pParentWnd
  88.  IDC_DAYSGRACE, // UINT  nID
  89.  0)) // pContext
  90. return (-1);
  91. // Call the base class function
  92. CDialog::OnInitDialog();
  93. return TRUE;  // return TRUE unless you set the focus to a control
  94.               // EXCEPTION: OCX Property Pages should return FALSE
  95. }
  96. void CSplashDlg::OnContinue() 
  97. {
  98. // Destroy the splash dialog
  99. DestroyWindow();
  100. // Get a pointer to the applicaiton class
  101. CMyglApp* pApp = (CMyglApp*)AfxGetApp();
  102. ASSERT(pApp);
  103. if(pApp->m_iDays > 60)
  104. {
  105. // Get a pointer to the MainFrame
  106. CMainFrame* pMainFrame = (CMainFrame*)pApp->m_pMainWnd;
  107. ASSERT(pMainFrame);
  108. pMainFrame->PostMessage(WM_CLOSE, 0, 0L);
  109. }
  110. }
  111. void CSplashDlg::OnDestroy() 
  112. {
  113. CDialog::OnDestroy();
  114. // Cleanup
  115. if(c_pStartupDlg)
  116. delete c_pStartupDlg;
  117. }
  118. void CSplashDlg::OnOrderForm() 
  119. {
  120. AfxGetApp()->WinHelp(0x10000 + ID_ORDER_FORM);
  121. }
  122. void CSplashDlg::OnOrderOnline() 
  123. {
  124. ShellExecute( NULL, "open", "www.imagewaredev.com", 0,0,1);
  125. }
  126. void CSplashDlg::OnPaint() 
  127. {
  128. CPaintDC dc(this); // device context for painting
  129. CMyglApp* pApp;
  130. CSize textSize;
  131. CRect rect;
  132. CDC* pDC;
  133. int x;
  134. // Get a pointer to our application class
  135. pApp = (CMyglApp*)AfxGetApp();
  136. ASSERT(pApp);
  137. // Get a pointer to our windows' device context
  138. pDC = m_wndDaysToGo.GetDC();
  139. if(pApp->m_iDays <=30)
  140. pDC->SetBkColor(0x0000FF00);
  141. else
  142. pDC->SetBkColor(0x000000CC);
  143. // Format the string
  144. m_szDaysToGo.Format("You are on day %d of your 30 day evaluation.", pApp->m_iDays);
  145. // Get the extents of the text string and window
  146. textSize = pDC->GetTextExtent(m_szDaysToGo);
  147. GetDlgItem(IDC_DAYSTOGO)->GetWindowRect(&rect);
  148. ScreenToClient(&rect);
  149. // Center align the text within the window
  150. x = ((rect.right-rect.left)-textSize.cx)/2;
  151. pDC->TextOut(x, 0, m_szDaysToGo, m_szDaysToGo.GetLength());
  152. if(pApp->m_iDays > 30)
  153. {
  154. pDC = m_wndDaysGrace.GetDC();
  155. // Get the extents of the Window
  156. GetDlgItem(IDC_DAYSGRACE)->GetWindowRect(&rect);
  157. ScreenToClient(&rect);
  158. if(pApp->m_iDays < 60)
  159. {
  160. pDC->SetBkColor(0x0000FF00); // Green background
  161. m_szDaysGrace.Format("You have a %d day grace period to order.", 60-pApp->m_iDays);
  162. // Get the extents of the text string and center align the 
  163. // text within the window.
  164. textSize = pDC->GetTextExtent(m_szDaysGrace);
  165. x = ((rect.right-rect.left)-textSize.cx)/2;
  166. pDC->TextOut(x, 0, m_szDaysGrace, m_szDaysGrace.GetLength());
  167. }
  168. else
  169. {
  170. pDC->SetBkColor(0x000000CC); // Red background
  171. m_szDaysGrace.Format("Your grace period has expired.");
  172. // Get the extents of the text string and center align the 
  173. // text within the window.
  174. textSize = pDC->GetTextExtent(m_szDaysGrace);
  175. x = ((rect.right-rect.left)-textSize.cx)/2;
  176. pDC->TextOut(x, 0, m_szDaysGrace, m_szDaysGrace.GetLength());
  177. }
  178. }
  179. // Do not call CDialog::OnPaint() for painting messages
  180. }