home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 February / CMCD0205.ISO / Software / Shareware / Programare / flashplayer / Samples / MFC / Demo / Demo.cpp next >
Encoding:
C/C++ Source or Header  |  2004-10-30  |  2.3 KB  |  101 lines

  1. // Demo.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Demo.h"
  6. #include "DemoDlg.h"
  7.  
  8. #include "../../../FlashPlayerControl/include/FlashPlayerControl.h"
  9. #pragma comment(lib, "../../../FlashPlayerControl/lib/FlashPlayerControl.lib")
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #endif
  14.  
  15.  
  16. // CDemoApp
  17.  
  18. BEGIN_MESSAGE_MAP(CDemoApp, CWinApp)
  19.     ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  20. END_MESSAGE_MAP()
  21.  
  22.  
  23. // CDemoApp construction
  24.  
  25. CDemoApp::CDemoApp()
  26. {
  27.     // TODO: add construction code here,
  28.     // Place all significant initialization in InitInstance
  29. }
  30.  
  31.  
  32. // The one and only CDemoApp object
  33.  
  34. CDemoApp theApp;
  35.  
  36.  
  37. // CDemoApp initialization
  38.  
  39. BOOL CDemoApp::InitInstance()
  40. {
  41.     // InitCommonControls() is required on Windows XP if an application
  42.     // manifest specifies use of ComCtl32.dll version 6 or later to enable
  43.     // visual styles.  Otherwise, any window creation will fail.
  44.     InitCommonControls();
  45.  
  46.     CWinApp::InitInstance();
  47.  
  48.     AfxEnableControlContainer();
  49.  
  50.     //!
  51. #ifdef WITH_EMBEDDED_FLASH_OCX_CODE
  52.  
  53.     HMODULE hModule = GetModuleHandle(NULL);
  54.     HRSRC hResInfo = FindResource(hModule, _T("FLASHOCXCODE"), _T("BIN"));
  55.     HGLOBAL hResData = LoadResource(hModule, hResInfo);
  56.     LPVOID lpFlashOCXCodeData = LockResource(hResData);
  57.     DWORD dwFlashOCXCodeSize = SizeofResource(hModule, hResInfo);
  58.  
  59.     if (!RegisterFlashWindowClassEx(lpFlashOCXCodeData, dwFlashOCXCodeSize))
  60.     {
  61.         AfxMessageBox(_T("RegisterFlashWindowClass() failed"), MB_OK | MB_ICONSTOP);
  62.         return FALSE;
  63.     }
  64.  
  65. #else
  66.  
  67.     if (!RegisterFlashWindowClass())
  68.     {
  69.         AfxMessageBox(_T("RegisterFlashWindowClass() failed"), MB_OK | MB_ICONSTOP);
  70.         return FALSE;
  71.     }
  72.  
  73. #endif // WITH_EMBEDDED_FLASH_OCX_CODE
  74.     //!
  75.  
  76.     CDemoDlg dlg;
  77.     m_pMainWnd = &dlg;
  78.     INT_PTR nResponse = dlg.DoModal();
  79.     if (nResponse == IDOK)
  80.     {
  81.         // TODO: Place code here to handle when the dialog is
  82.         //  dismissed with OK
  83.     }
  84.     else if (nResponse == IDCANCEL)
  85.     {
  86.         // TODO: Place code here to handle when the dialog is
  87.         //  dismissed with Cancel
  88.     }
  89.  
  90.     // Since the dialog has been closed, return FALSE so that we exit the
  91.     //  application, rather than start the application's message pump.
  92.     return FALSE;
  93. }
  94.  
  95. int CDemoApp::ExitInstance()
  96. {
  97.     UnregisterFlashWindowClass();
  98.  
  99.     return CWinApp::ExitInstance();
  100. }
  101.