home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 November / Chip_2002-11_cd1.bin / zkuste / vbasic / Data / Utils / WME71SDK.exe / RCDATA / CABINET / enccontroldlg.cpp < prev    next >
C/C++ Source or Header  |  2001-03-02  |  4KB  |  147 lines

  1. // ENCControlDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "ENCControl.h"
  6. #include "ENCControlDlg.h"
  7. #include "ENCControlConfig.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CENCControlDlg dialog
  16.  
  17. CENCControlDlg::CENCControlDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CENCControlDlg::IDD, pParent)
  19. {
  20.     
  21.     //{{AFX_DATA_INIT(CENCControlDlg)
  22.         // NOTE: the ClassWizard will add member initialization here
  23.     //}}AFX_DATA_INIT
  24.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  25.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  26.     
  27. }
  28.  
  29. CENCControlDlg::~CENCControlDlg()
  30. {
  31.     m_pEncoder->Release();
  32. }
  33.  
  34. void CENCControlDlg::DoDataExchange(CDataExchange* pDX)
  35. {
  36.     CDialog::DoDataExchange(pDX);
  37.     //{{AFX_DATA_MAP(CENCControlDlg)
  38.     DDX_Control(pDX, IDC_PROPSHELLCTRL, m_PropShell);
  39.     //}}AFX_DATA_MAP
  40. }
  41.  
  42. BEGIN_MESSAGE_MAP(CENCControlDlg, CDialog)
  43.     //{{AFX_MSG_MAP(CENCControlDlg)
  44.     ON_WM_PAINT()
  45.     ON_WM_QUERYDRAGICON()
  46.     ON_BN_CLICKED(IDC_START, OnStart)
  47.     ON_BN_CLICKED(IDC_STOP, OnStop)
  48.     ON_BN_CLICKED(IDC_CONFIGURE, OnConfigure)
  49.     //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51.  
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CENCControlDlg message handlers
  54.  
  55. BOOL CENCControlDlg::OnInitDialog()
  56. {
  57.     CDialog::OnInitDialog();
  58.  
  59.     // Set the icon for this dialog.  The framework does this automatically
  60.     //  when the application's main window is not a dialog
  61.     SetIcon(m_hIcon, TRUE);            // Set big icon
  62.     SetIcon(m_hIcon, FALSE);        // Set small icon
  63.     
  64.     // TODO: Add extra initialization here
  65.  
  66.     
  67.     IUnknown* pMainPage;
  68.     IMSPropShell* pPropShell;
  69.     
  70.     m_PropShell.GetControlUnknown()->QueryInterface(IID_IMSPropShell,(void**)&pPropShell);
  71.     HRESULT hr=CoCreateInstance(CLSID_WMEncMonMainPage,NULL,CLSCTX_INPROC_SERVER,IID_IUnknown,(void**) &pMainPage);
  72.     HRESULT hr1=CoCreateInstance(CLSID_WMEncoder,NULL,CLSCTX_INPROC_SERVER,IID_IWMEncoder,(void**) &m_pEncoder);
  73.  
  74.     pPropShell->AddObject(m_pEncoder);
  75.     pPropShell->AddPage(pMainPage);
  76.     
  77.  
  78.     pMainPage->Release();
  79.     pPropShell->Release();
  80.  
  81.  
  82.     return TRUE;  // return TRUE  unless you set the focus to a control
  83. }
  84.  
  85. // If you add a minimize button to your dialog, you will need the code below
  86. //  to draw the icon.  For MFC applications using the document/view model,
  87. //  this is automatically done for you by the framework.
  88.  
  89. void CENCControlDlg::OnPaint() 
  90. {
  91.     if (IsIconic())
  92.     {
  93.         CPaintDC dc(this); // device context for painting
  94.  
  95.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  96.  
  97.         // Center icon in client rectangle
  98.         int cxIcon = GetSystemMetrics(SM_CXICON);
  99.         int cyIcon = GetSystemMetrics(SM_CYICON);
  100.         CRect rect;
  101.         GetClientRect(&rect);
  102.         int x = (rect.Width() - cxIcon + 1) / 2;
  103.         int y = (rect.Height() - cyIcon + 1) / 2;
  104.  
  105.         // Draw the icon
  106.         dc.DrawIcon(x, y, m_hIcon);
  107.     }
  108.     else
  109.     {
  110.         CDialog::OnPaint();
  111.     }
  112. }
  113.  
  114. // The system calls this to obtain the cursor to display while the user drags
  115. //  the minimized window.
  116. HCURSOR CENCControlDlg::OnQueryDragIcon()
  117. {
  118.     return (HCURSOR) m_hIcon;
  119. }
  120.  
  121. void CENCControlDlg::OnStart() 
  122. {
  123.     m_pEncoder->Start();
  124.     
  125. }
  126.  
  127. void CENCControlDlg::OnStop() 
  128. {
  129.     WMENC_ENCODER_STATE EncoderState;
  130.     m_pEncoder->get_RunState(&EncoderState);
  131.     //TCHAR szBuffer[64];
  132.     //wsprintf( szBuffer, _T("%d"), EncoderState ); 
  133.     //AfxMessageBox(szBuffer);
  134.     if ((EncoderState==WMENC_ENCODER_RUNNING)||(EncoderState==WMENC_ENCODER_PAUSED)){
  135.         
  136.         m_pEncoder->Stop();    
  137.     }
  138.     
  139. }
  140.  
  141. void CENCControlDlg::OnConfigure() 
  142. {
  143.     ENCControlConfig ConfigDlg;
  144.     ConfigDlg.SetEncoder(m_pEncoder);
  145.     ConfigDlg.DoModal();
  146. }
  147.