home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / mslang / ttips2 / tooltest.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-07  |  4.5 KB  |  162 lines

  1. // tooltest.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "tooltest.h"
  6.  
  7. #include "mainfrm.h"
  8. #include "tooltdoc.h"
  9. #include "tooltvw.h"
  10.  
  11. #ifdef _DEBUG
  12. #undef THIS_FILE
  13. static char BASED_CODE THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CTooltestApp
  18.  
  19. BEGIN_MESSAGE_MAP(CTooltestApp, CWinApp)
  20.     //{{AFX_MSG_MAP(CTooltestApp)
  21.     ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  22.         // NOTE - the ClassWizard will add and remove mapping macros here.
  23.         //    DO NOT EDIT what you see in these blocks of generated code!
  24.     //}}AFX_MSG_MAP
  25.     // Standard file based document commands
  26.     ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  27.     ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  28.     // Standard print setup command
  29.     ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  30. END_MESSAGE_MAP()
  31.  
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CTooltestApp construction
  34.  
  35. CTooltestApp::CTooltestApp()
  36. {
  37.     // TODO: add construction code here,
  38.     // Place all significant initialization in InitInstance
  39. }
  40.  
  41. /////////////////////////////////////////////////////////////////////////////
  42. // The one and only CTooltestApp object
  43.  
  44. CTooltestApp NEAR theApp;
  45.  
  46. /////////////////////////////////////////////////////////////////////////////
  47. // CTooltestApp initialization
  48.  
  49. BOOL CTooltestApp::InitInstance()
  50. {
  51.     // Standard initialization
  52.     // If you are not using these features and wish to reduce the size
  53.     //  of your final executable, you should remove from the following
  54.     //  the specific initialization routines you do not need.
  55.  
  56.     SetDialogBkColor();        // Set dialog background color to gray
  57.     LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  58.  
  59.     // Register the application's document templates.  Document templates
  60.     //  serve as the connection between documents, frame windows and views.
  61.  
  62.     CMultiDocTemplate* pDocTemplate;
  63.     pDocTemplate = new CMultiDocTemplate(
  64.         IDR_TOOLTETYPE,
  65.         RUNTIME_CLASS(CTooltestDoc),
  66.         RUNTIME_CLASS(CMDIChildWnd),        // standard MDI child frame
  67.         RUNTIME_CLASS(CTooltestView));
  68.     AddDocTemplate(pDocTemplate);
  69.  
  70.     // setup main window
  71.     // Added line to make the initial frame be full screen
  72.     m_nCmdShow = SW_SHOWMAXIMIZED;
  73.     
  74.     // create main MDI Frame window
  75.     CMainFrame* pMainFrame = new CMainFrame;
  76.     if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
  77.         return FALSE;
  78.     m_pMainWnd = pMainFrame;
  79.  
  80.     // create a new (empty) document
  81.     OnFileNew();
  82.  
  83.     if (m_lpCmdLine[0] != '\0')
  84.     {
  85.         // TODO: add command line processing here
  86.     }
  87. // Added these lines to do the splash screen stuff
  88. // *********************************    
  89.     else if (m_splash.Create(m_pMainWnd)) {
  90.         m_splash.ShowWindow(SW_SHOW);
  91.         m_splash.UpdateWindow();
  92.     }
  93.     m_dwSplashTime = ::GetCurrentTime();
  94. // *********************************    
  95.     
  96. // The main window has been initialized, so show and update it.
  97.     pMainFrame->ShowWindow(m_nCmdShow);
  98.     pMainFrame->UpdateWindow();
  99.  
  100.     return TRUE;
  101. }
  102.  
  103. // Added these lines to do the splash screen stuff
  104. // *********************************    
  105. //
  106. // This function is for the splash window at program startup
  107. //
  108. BOOL CTooltestApp::OnIdle(LONG lCount)
  109. {
  110.     // call base class idle first
  111.     BOOL bResult = CWinApp::OnIdle(lCount);
  112.  
  113.     // then do our work
  114.     if (m_splash.m_hWnd != NULL) {
  115.         if (::GetCurrentTime() - m_dwSplashTime > 2000) {
  116.             // timeout expired, destroy the splash window
  117.             m_splash.DestroyWindow();
  118.             m_pMainWnd->UpdateWindow();
  119.  
  120.             // NOTE: don't set bResult to FALSE,
  121.             //  CWinApp::OnIdle may have returned TRUE
  122.         }
  123.         else {
  124.             // check again later...
  125.             bResult = TRUE;
  126.         }
  127.     }
  128.  
  129.     return bResult;
  130. }
  131.  
  132. BOOL CTooltestApp::PreTranslateMessage(MSG* pMsg)
  133. {
  134.     BOOL bResult = CWinApp::PreTranslateMessage(pMsg);
  135.  
  136.     if (m_splash.m_hWnd != NULL &&
  137.         (pMsg->message == WM_KEYDOWN ||
  138.          pMsg->message == WM_SYSKEYDOWN ||
  139.          pMsg->message == WM_LBUTTONDOWN ||
  140.          pMsg->message == WM_RBUTTONDOWN ||
  141.          pMsg->message == WM_MBUTTONDOWN ||
  142.          pMsg->message == WM_NCLBUTTONDOWN ||
  143.          pMsg->message == WM_NCRBUTTONDOWN ||
  144.          pMsg->message == WM_NCMBUTTONDOWN)) {
  145.         m_splash.DestroyWindow();
  146.         m_pMainWnd->UpdateWindow();
  147.     }
  148.  
  149.     return bResult;
  150. }
  151. // *********************************    
  152.  
  153. /////////////////////////////////////////////////////////////////////////////
  154. // CTooltestApp commands
  155. // App command to run the dialog
  156. void CTooltestApp::OnAppAbout()
  157. {
  158.     CAboutDlg aboutDlg;
  159.     aboutDlg.DoModal();
  160. }
  161.  
  162.