home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / mslang / splash / demo_cpp.cpp next >
C/C++ Source or Header  |  1994-06-14  |  6KB  |  195 lines

  1. //
  2. //  Copyright (C) 1994 by
  3. //  HITAM Software, St. Louis, MO, USA
  4. //  All Rights Reserved.
  5. //
  6. //  This software is furnished under a license and may be used and copied
  7. //  only in accordance of the terms of such license and with the
  8. //  inclusion of the above copyright notice. This software or any other
  9. //  copies thereof may not be provided or otherwise made available to any
  10. //  other person. No title to and ownership of the software is hereby
  11. //  transferred.
  12. //
  13. //  The information in this software is subject to change without notice
  14. //  and should not be construed as a commitment by HITAM Software
  15. //
  16. //  HITAM Software assumes no responsibility for
  17. //  the use or reliability of its software on equipment which is not
  18. //  supplied by HITAM Software
  19. //
  20. //  FACILITY: DEMO_CPP
  21. //
  22. //  ABSTRACT:
  23. //
  24. //     These files comprise the C++ demonstration program for showing the              
  25. //     capabilities of the SPLASH Libraries. Code is Microsoft C++ built               
  26. //     using the Microsoft Foundation Class Library V2.5 with Microsoft                
  27. //     Visual C++ V1.5. Code is compatible in 16 bit Windows and 32 bit                
  28. //     Windows.                                                                        
  29. //                                                                                     
  30. //     Dependancies:                                                                   
  31. //                   SPLASHxx.LIB   Import Library for Windows                         
  32. //                   SPLASHxx.DLL   Run-Time Library for Windows                       
  33. //                   SPLASH.H       SPLASH Libraries Header File                       
  34. //                   RESOURCE.H     Application Constants                              
  35. //                   DEMO_CPP.DEF   Module Definition File                             
  36. //
  37. //  AUTHOR(S): Todd Osborne (HITAM Software)
  38. //
  39. //  CREATED: 06/15/94
  40. //
  41. //  MODIFICATION HISTORY:
  42. //
  43. //  Version Date        By      Reason
  44. //
  45.  
  46. #include <afxwin.h>
  47. #include "resource.h"
  48. #include "demo_cpp.h"
  49. #include "splash.h"
  50.  
  51. CTheApp ThisApp;
  52.  
  53. BOOL CTheApp::InitInstance()
  54. {
  55.     // Create main dialog box window and show m_strAPPTITLE in caption bar
  56.     m_pMainWnd = new CMainDlgWindow();
  57.     
  58.     if ( m_pMainWnd != NULL )
  59.     {
  60.         #ifdef _WIN32
  61.             m_pMainWnd->SetWindowText("SPLASH32.DLL Demo for C/C++");
  62.         #else
  63.             m_pMainWnd->SetWindowText("SPLASH16.DLL Demo for C/C++");
  64.         #endif
  65.         
  66.         // Set application (window) icon
  67.         SetClassWord(m_pMainWnd->m_hWnd, GCW_HICON, (WORD)LoadIcon(IDI_APPLICATION));
  68.     
  69.         return TRUE;
  70.     }
  71.     else
  72.         return FALSE;
  73. }
  74.  
  75. CMainDlgWindow::CMainDlgWindow()
  76. {
  77.     //{{AFX_DATA_INIT(CMainDlgWindow)
  78.     
  79.     // We can use the help file path as a start for the default file
  80.     // Parse it to last backslash and add "SPLASH.BMP"
  81.     m_strSplashFileName = App.m_pszHelpFilePath;
  82.     m_strSplashFileName = m_strSplashFileName.Mid(0, m_strSplashFileName.ReverseFind('\\') + 1) + "SPLASH.BMP";
  83.     m_nHowLong = 1;
  84.     m_nWhichDLL = 0;
  85.     //}}AFX_DATA_INIT
  86.     
  87.     // Create the Main Dialog Window
  88.     Create(IDD_MAIN);
  89. }
  90.  
  91. // ***** MESSAGE HANDLERS ******
  92.  
  93. BOOL CMainDlgWindow::OnCommand(WPARAM wParam, LPARAM lParam)
  94. {
  95.     // Handle messages before message map
  96.     // This is where we trap buton clicks to call DLL
  97.     // The button ID's for the AccuSoft functions are between 100 - 110
  98.     // Button ID 111 is used to show splash using normal bitmap loading techniques (No AccuSoft DLL's are needed)
  99.     
  100.     if ( LOWORD(lParam) != 0 && HIWORD(lParam) == BN_CLICKED )
  101.     {
  102.         // Call DDX routine to get data from screen into member vars
  103.         UpdateData(TRUE);
  104.         
  105.         // The wParam is the control ID that sent the message
  106.         // Subtract 100 from the control ID and call ShowSplashAnyFormat for values 0-10
  107.         // Call ShowSplashFromFile for 11 and ShowSplashFromResource for 12
  108.         
  109.         int nButton = wParam - 100;
  110.         
  111.         char* psz = m_strSplashFileName.GetBuffer(m_strSplashFileName.GetLength());
  112.         
  113.         if ( nButton >= 0 && nButton <=10 )
  114.             // This will show the splash screen using AccuSoft DLL(s). These DLL's are capable
  115.             // of more than 16 color displays and can produce interesting visual effects.
  116.             // Contact AccuSoft for more information.
  117.             ShowSplashAnyFormat(psz, nButton, (m_nWhichDLL == 0 ) ? "ACCUSOFT.DLL" : "ACCU32IF.DLL", m_nHowLong);
  118.             
  119.         else if ( nButton == 11 )
  120.             // This will show the splash screen by passing the name of a Windows bitmap (BMP)
  121.             // file. This routine currently supports up to 16 colors. No additional DLL's are
  122.             // needed.
  123.             ShowSplashFromFile(psz, m_nHowLong);
  124.         
  125.         else if ( nButton == 12 )
  126.             // This will show the splash screen by passing the name of a resource embedded in
  127.             // the calling program. This routine currently supports up to 16 colors. No additional
  128.             // DLL's are needed. This is not available to languages and applications that do not
  129.             // store their resources within their EXE or DLL. Sorry VB guys!
  130.             ShowSplashFromResource(AfxGetInstanceHandle(), "IDB_SPLASH", m_nHowLong);
  131.                 
  132.         m_strSplashFileName.ReleaseBuffer();
  133.     
  134.         // End the splash screen
  135.         EndSplash();
  136.     }    
  137.             
  138.     // Do default processing of this message
  139.     CWnd::OnCommand(wParam, lParam);
  140.     
  141.     return 1;
  142. }
  143.  
  144. void CMainDlgWindow::OnCancel()
  145. {
  146.     // Override default processing that closes window
  147. }
  148.  
  149. void CMainDlgWindow::OnClose()
  150. {
  151.     DestroyWindow();
  152. }
  153.  
  154. void CMainDlgWindow::PostNcDestroy()
  155. {
  156.     // Destroy this dialog box pointer
  157.     delete this;
  158.  
  159.     // Tell Windows to shut us down
  160.     ::PostQuitMessage(0);
  161. }
  162.  
  163. BOOL CMainDlgWindow::OnInitDialog()
  164. {
  165.     CDialog::OnInitDialog();
  166.     
  167.     // Center this window on screen
  168.     CenterWindow();
  169.     
  170.     return TRUE;  // return TRUE  unless you set the focus to a control
  171. }
  172.  
  173. void CMainDlgWindow::DoDataExchange(CDataExchange* pDX)
  174. {
  175.     CDialog::DoDataExchange(pDX);
  176.     //{{AFX_DATA_MAP(CMainDlgWindow)
  177.     DDX_Text(pDX, IDC_EDIT1, m_strSplashFileName);
  178.     DDX_CBIndex(pDX, IDC_COMBO1, m_nHowLong);
  179.     DDX_Radio(pDX, IDC_RADIO1, m_nWhichDLL);
  180.     //}}AFX_DATA_MAP
  181. }
  182.  
  183. void CMainDlgWindow::KillTime(int nHowLong)
  184. {
  185.     // Loop for nHowLong seconds
  186.     DWORD CurTime = GetCurrentTime();    // This is in milliseconds (since Windows started)
  187.     while ( GetCurrentTime() < CurTime + (nHowLong * 1000) );
  188. }
  189.  
  190. BEGIN_MESSAGE_MAP(CMainDlgWindow, CDialog)
  191.     //{{AFX_MSG_MAP(CMainDlgWindow)
  192.     ON_WM_CLOSE()
  193.     //}}AFX_MSG_MAP
  194. END_MESSAGE_MAP()
  195.