SplashDlg.cpp
上传用户:cding2008
上传日期:2007-01-03
资源大小:1812k
文件大小:6k
- /////////////////////////////////////////////////////////////////////////////
- // SplashDlg.cpp : implementation file
- //
- // ModelMagic 3D and 'glOOP' (OpenGL Object Oriented Programming library)
- // Copyright (c) Craig Fahrnbach 1997, 1999
- //
- // OpenGL is a registered trademark of Silicon Graphics
- //
- //
- // This program is provided for educational and personal use only and
- // is provided without guarantee or warrantee expressed or implied.
- //
- // Commercial use is strickly prohibited without written permission
- // from ImageWare Development.
- //
- /////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "ModelMagic3D.h"
- #include "SplashDlg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CSplashDlg local variables
- static CSplashDlg* c_pStartupDlg;
- /////////////////////////////////////////////////////////////////////////////
- // CSplashDlg dialog
- void CSplashDlg::ShowSplashDlg(CWnd* pParentWnd /*= NULL*/)
- {
- c_pStartupDlg = new CSplashDlg;
- if(c_pStartupDlg->Create(IDD_SPLASH_DIALOG, pParentWnd))
- {
- c_pStartupDlg->CenterWindow();
- c_pStartupDlg->ShowWindow(SW_SHOW);
- }
- }
- CSplashDlg::CSplashDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CSplashDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSplashDlg)
- m_szDaysToGo = _T("");
- m_szDaysGrace = _T("");
- //}}AFX_DATA_INIT
- }
- void CSplashDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSplashDlg)
- DDX_Text(pDX, IDC_DAYSTOGO, m_szDaysToGo);
- DDX_Text(pDX, IDC_DAYSGRACE, m_szDaysGrace);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSplashDlg, CDialog)
- //{{AFX_MSG_MAP(CSplashDlg)
- ON_BN_CLICKED(IDC_ORDER_FORM, OnOrderForm)
- ON_BN_CLICKED(IDC_ORDER_ONLINE, OnOrderOnline)
- ON_BN_CLICKED(IDC_CONTINUE, OnContinue)
- ON_WM_DESTROY()
- ON_WM_PAINT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSplashDlg message handlers
- BOOL CSplashDlg::OnInitDialog()
- {
- // Create the text windows
- CRect rect;
- GetDlgItem(IDC_DAYSTOGO)->GetWindowRect(&rect);
- ScreenToClient(&rect);
- if(!m_wndDaysToGo.Create(NULL, // lpszClassName
- NULL, // lpszWindowName
- WS_CHILD | WS_VISIBLE, // dwStyle
- rect, // rect
- this, // CWnd* pParentWnd
- IDC_DAYSTOGO, // UINT nID
- 0)) // pContext
- return (-1);
- // Create the grace period text window
- GetDlgItem(IDC_DAYSGRACE)->GetWindowRect(&rect);
- ScreenToClient(&rect);
- if(!m_wndDaysGrace.Create(NULL, // lpszClassName
- NULL, // lpszWindowName
- WS_CHILD | WS_VISIBLE, // dwStyle
- rect, // rect
- this, // CWnd* pParentWnd
- IDC_DAYSGRACE, // UINT nID
- 0)) // pContext
- return (-1);
- // Call the base class function
- CDialog::OnInitDialog();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CSplashDlg::OnContinue()
- {
- // Destroy the splash dialog
- DestroyWindow();
- // Get a pointer to the applicaiton class
- CMyglApp* pApp = (CMyglApp*)AfxGetApp();
- ASSERT(pApp);
- if(pApp->m_iDays > 60)
- {
- // Get a pointer to the MainFrame
- CMainFrame* pMainFrame = (CMainFrame*)pApp->m_pMainWnd;
- ASSERT(pMainFrame);
- pMainFrame->PostMessage(WM_CLOSE, 0, 0L);
- }
- }
- void CSplashDlg::OnDestroy()
- {
- CDialog::OnDestroy();
- // Cleanup
- if(c_pStartupDlg)
- delete c_pStartupDlg;
- }
- void CSplashDlg::OnOrderForm()
- {
- AfxGetApp()->WinHelp(0x10000 + ID_ORDER_FORM);
- }
- void CSplashDlg::OnOrderOnline()
- {
- ShellExecute( NULL, "open", "www.imagewaredev.com", 0,0,1);
- }
- void CSplashDlg::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- CMyglApp* pApp;
- CSize textSize;
- CRect rect;
- CDC* pDC;
- int x;
- // Get a pointer to our application class
- pApp = (CMyglApp*)AfxGetApp();
- ASSERT(pApp);
- // Get a pointer to our windows' device context
- pDC = m_wndDaysToGo.GetDC();
- if(pApp->m_iDays <=30)
- pDC->SetBkColor(0x0000FF00);
- else
- pDC->SetBkColor(0x000000CC);
- // Format the string
- m_szDaysToGo.Format("You are on day %d of your 30 day evaluation.", pApp->m_iDays);
- // Get the extents of the text string and window
- textSize = pDC->GetTextExtent(m_szDaysToGo);
- GetDlgItem(IDC_DAYSTOGO)->GetWindowRect(&rect);
- ScreenToClient(&rect);
- // Center align the text within the window
- x = ((rect.right-rect.left)-textSize.cx)/2;
- pDC->TextOut(x, 0, m_szDaysToGo, m_szDaysToGo.GetLength());
- if(pApp->m_iDays > 30)
- {
- pDC = m_wndDaysGrace.GetDC();
- // Get the extents of the Window
- GetDlgItem(IDC_DAYSGRACE)->GetWindowRect(&rect);
- ScreenToClient(&rect);
- if(pApp->m_iDays < 60)
- {
- pDC->SetBkColor(0x0000FF00); // Green background
- m_szDaysGrace.Format("You have a %d day grace period to order.", 60-pApp->m_iDays);
- // Get the extents of the text string and center align the
- // text within the window.
- textSize = pDC->GetTextExtent(m_szDaysGrace);
- x = ((rect.right-rect.left)-textSize.cx)/2;
- pDC->TextOut(x, 0, m_szDaysGrace, m_szDaysGrace.GetLength());
- }
- else
- {
- pDC->SetBkColor(0x000000CC); // Red background
- m_szDaysGrace.Format("Your grace period has expired.");
- // Get the extents of the text string and center align the
- // text within the window.
- textSize = pDC->GetTextExtent(m_szDaysGrace);
- x = ((rect.right-rect.left)-textSize.cx)/2;
-
- pDC->TextOut(x, 0, m_szDaysGrace, m_szDaysGrace.GetLength());
- }
- }
- // Do not call CDialog::OnPaint() for painting messages
- }