home *** CD-ROM | disk | FTP | other *** search
/ distrib.akp.su/Programming/Vb-6+Rus/ / distrib.akp.su.tar / distrib.akp.su / Programming / Vb-6+Rus / COMMON / MSDEV98 / BIN / IDE / SPLASH.DLL / TEMPLATE / 138 < prev   
Text File  |  1998-06-18  |  3KB  |  142 lines

  1. // CG: This file was added by the Splash Screen component.
  2. // $$VAL:ImplemName$$ : implementation file
  3. //
  4.  
  5. #include "$$VAL:ProjHdrName$$"  // e. g. stdafx.h
  6. #include "$$VAL:ResHdrName$$"  // e.g. resource.h
  7.  
  8. #include "$$VAL:HeaderName$$"  // e.g. splash.h
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char BASED_CODE THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. //   Splash Screen class
  18.  
  19. BOOL $$VAL:SplClassName$$::c_bShowSplashWnd;
  20. $$VAL:SplClassName$$* $$VAL:SplClassName$$::c_pSplashWnd;
  21. $$VAL:SplClassName$$::$$VAL:SplClassName$$()
  22. {
  23. }
  24.  
  25. $$VAL:SplClassName$$::~$$VAL:SplClassName$$()
  26. {
  27.     // Clear the static window pointer.
  28.     ASSERT(c_pSplashWnd == this);
  29.     c_pSplashWnd = NULL;
  30. }
  31.  
  32. BEGIN_MESSAGE_MAP($$VAL:SplClassName$$, CWnd)
  33.     //{{AFX_MSG_MAP($$VAL:SplClassName$$)
  34.     ON_WM_CREATE()
  35.     ON_WM_PAINT()
  36.     ON_WM_TIMER()
  37.     //}}AFX_MSG_MAP
  38. END_MESSAGE_MAP()
  39.  
  40. void $$VAL:SplClassName$$::EnableSplashScreen(BOOL bEnable /*= TRUE*/)
  41. {
  42.     c_bShowSplashWnd = bEnable;
  43. }
  44.  
  45. void $$VAL:SplClassName$$::ShowSplashScreen(CWnd* pParentWnd /*= NULL*/)
  46. {
  47.     if (!c_bShowSplashWnd || c_pSplashWnd != NULL)
  48.         return;
  49.  
  50.     // Allocate a new splash screen, and create the window.
  51.     c_pSplashWnd = new $$VAL:SplClassName$$;
  52.     if (!c_pSplashWnd->Create(pParentWnd))
  53.         delete c_pSplashWnd;
  54.     else
  55.         c_pSplashWnd->UpdateWindow();
  56. }
  57.  
  58. BOOL $$VAL:SplClassName$$::PreTranslateAppMessage(MSG* pMsg)
  59. {
  60.     if (c_pSplashWnd == NULL)
  61.         return FALSE;
  62.  
  63.     // If we get a keyboard or mouse message, hide the splash screen.
  64.     if (pMsg->message == WM_KEYDOWN ||
  65.         pMsg->message == WM_SYSKEYDOWN ||
  66.         pMsg->message == WM_LBUTTONDOWN ||
  67.         pMsg->message == WM_RBUTTONDOWN ||
  68.         pMsg->message == WM_MBUTTONDOWN ||
  69.         pMsg->message == WM_NCLBUTTONDOWN ||
  70.         pMsg->message == WM_NCRBUTTONDOWN ||
  71.         pMsg->message == WM_NCMBUTTONDOWN)
  72.     {
  73.         c_pSplashWnd->HideSplashScreen();
  74.         return TRUE;    // message handled here
  75.     }
  76.  
  77.     return FALSE;    // message not handled
  78. }
  79.  
  80. BOOL $$VAL:SplClassName$$::Create(CWnd* pParentWnd /*= NULL*/)
  81. {
  82.     if (!m_bitmap.LoadBitmap($$VAL:BmpID16$$))
  83.         return FALSE;
  84.  
  85.     BITMAP bm;
  86.     m_bitmap.GetBitmap(&bm);
  87.  
  88.     return CreateEx(0,
  89.         AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
  90.         NULL, WS_POPUP | WS_VISIBLE, 0, 0, bm.bmWidth, bm.bmHeight, pParentWnd->GetSafeHwnd(), NULL);
  91. }
  92.  
  93. void $$VAL:SplClassName$$::HideSplashScreen()
  94. {
  95.     // Destroy the window, and update the mainframe.
  96.     DestroyWindow();
  97.     AfxGetMainWnd()->UpdateWindow();
  98. }
  99.  
  100. void $$VAL:SplClassName$$::PostNcDestroy()
  101. {
  102.     // Free the C++ class.
  103.     delete this;
  104. }
  105.  
  106. int $$VAL:SplClassName$$::OnCreate(LPCREATESTRUCT lpCreateStruct)
  107. {
  108.     if (CWnd::OnCreate(lpCreateStruct) == -1)
  109.         return -1;
  110.  
  111.     // Center the window.
  112.     CenterWindow();
  113.  
  114.     // Set a timer to destroy the splash screen.
  115.     SetTimer(1, 750, NULL);
  116.  
  117.     return 0;
  118. }
  119.  
  120. void $$VAL:SplClassName$$::OnPaint()
  121. {
  122.     CPaintDC dc(this);
  123.  
  124.     CDC dcImage;
  125.     if (!dcImage.CreateCompatibleDC(&dc))
  126.         return;
  127.  
  128.     BITMAP bm;
  129.     m_bitmap.GetBitmap(&bm);
  130.  
  131.     // Paint the image.
  132.     CBitmap* pOldBitmap = dcImage.SelectObject(&m_bitmap);
  133.     dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcImage, 0, 0, SRCCOPY);
  134.     dcImage.SelectObject(pOldBitmap);
  135. }
  136.  
  137. void $$VAL:SplClassName$$::OnTimer(UINT nIDEvent)
  138. {
  139.     // Destroy the splash screen window.
  140.     HideSplashScreen();
  141. }
  142.