Direct90Dlg.cpp
上传用户:maxzhb99
上传日期:2013-03-13
资源大小:48k
文件大小:5k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. // Direct90Dlg.cpp : 僀儞僾儕儊儞僥乕僔儑儞 僼傽僀儖
  2. //
  3. #include "stdafx.h"
  4. #include "Direct90.h"
  5. #include "Direct90Dlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // 傾僾儕働乕僔儑儞偺僶乕僕儑儞忣曬偱巊傢傟偰偄傞 CAboutDlg 僟僀傾儘僌
  13. class CAboutDlg : public CDialog
  14. {
  15. public:
  16. CAboutDlg();
  17. // 僟僀傾儘僌 僨乕僞
  18. //{{AFX_DATA(CAboutDlg)
  19. enum { IDD = IDD_ABOUTBOX };
  20. //}}AFX_DATA
  21. // ClassWizard 偼壖憐娭悢偺僆乕僶乕儔僀僪傪惗惉偟傑偡
  22. //{{AFX_VIRTUAL(CAboutDlg)
  23. protected:
  24. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 偺僒億乕僩
  25. //}}AFX_VIRTUAL
  26. // 僀儞僾儕儊儞僥乕僔儑儞
  27. protected:
  28. //{{AFX_MSG(CAboutDlg)
  29. //}}AFX_MSG
  30. DECLARE_MESSAGE_MAP()
  31. };
  32. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  33. {
  34. //{{AFX_DATA_INIT(CAboutDlg)
  35. //}}AFX_DATA_INIT
  36. }
  37. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  38. {
  39. CDialog::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(CAboutDlg)
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  44. //{{AFX_MSG_MAP(CAboutDlg)
  45. // 儊僢僙乕僕 僴儞僪儔偑偁傝傑偣傫丅
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CDirect90Dlg 僟僀傾儘僌
  50. CDirect90Dlg::CDirect90Dlg(CWnd* pParent /*=NULL*/)
  51. : CDialog(CDirect90Dlg::IDD, pParent)
  52. {
  53. //{{AFX_DATA_INIT(CDirect90Dlg)
  54. m_str = _T("");
  55. //}}AFX_DATA_INIT
  56. // 儊儌: LoadIcon 偼 Win32 偺 DestroyIcon 偺僒僽僔乕働儞僗傪梫媮偟傑偣傫丅
  57. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  58. }
  59. void CDirect90Dlg::DoDataExchange(CDataExchange* pDX)
  60. {
  61. CDialog::DoDataExchange(pDX);
  62. //{{AFX_DATA_MAP(CDirect90Dlg)
  63. DDX_Control(pDX, IDC_STATIC_CAPSHOW, m_CapShow);
  64. DDX_Text(pDX, IDC_EDIT_TEXT, m_str);
  65. //}}AFX_DATA_MAP
  66. }
  67. BEGIN_MESSAGE_MAP(CDirect90Dlg, CDialog)
  68. //{{AFX_MSG_MAP(CDirect90Dlg)
  69. ON_WM_SYSCOMMAND()
  70. ON_WM_PAINT()
  71. ON_WM_QUERYDRAGICON()
  72. ON_BN_CLICKED(IDC_BUTTON_FONT, OnButtonFont)
  73. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  74. ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
  75. //}}AFX_MSG_MAP
  76. END_MESSAGE_MAP()
  77. /////////////////////////////////////////////////////////////////////////////
  78. // CDirect90Dlg 儊僢僙乕僕 僴儞僪儔
  79. BOOL CDirect90Dlg::OnInitDialog()
  80. {
  81. CDialog::OnInitDialog();
  82. // "僶乕僕儑儞忣曬..." 儊僯儏乕崁栚傪僔僗僥儉 儊僯儏乕傊捛壛偟傑偡丅
  83. // IDM_ABOUTBOX 偼僐儅儞僪 儊僯儏乕偺斖埻偱側偗傟偽側傝傑偣傫丅
  84. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  85. ASSERT(IDM_ABOUTBOX < 0xF000);
  86. CMenu* pSysMenu = GetSystemMenu(FALSE);
  87. if (pSysMenu != NULL)
  88. {
  89. CString strAboutMenu;
  90. strAboutMenu.LoadString(IDS_ABOUTBOX);
  91. if (!strAboutMenu.IsEmpty())
  92. {
  93. pSysMenu->AppendMenu(MF_SEPARATOR);
  94. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  95. }
  96. }
  97. // 偙偺僟僀傾儘僌梡偺傾僀僐儞傪愝掕偟傑偡丅僼儗乕儉儚乕僋偼傾僾儕働乕僔儑儞偺儊僀儞
  98. // 僂傿儞僪僂偑僟僀傾儘僌偱側偄帪偼帺摦揑偵愝掕偟傑偣傫丅
  99. SetIcon(m_hIcon, TRUE); // 戝偒偄傾僀僐儞傪愝掕
  100. SetIcon(m_hIcon, FALSE); // 彫偝偄傾僀僐儞傪愝掕
  101. // TODO: 摿暿側弶婜壔傪峴偆帪偼偙偺応強偵捛壛偟偰偔偩偝偄丅
  102. return TRUE;  // TRUE 傪曉偡偲僐儞僩儘乕儖偵愝掕偟偨僼僅乕僇僗偼幐傢傟傑偣傫丅
  103. }
  104. void CDirect90Dlg::OnSysCommand(UINT nID, LPARAM lParam)
  105. {
  106. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  107. {
  108. CAboutDlg dlgAbout;
  109. dlgAbout.DoModal();
  110. }
  111. else
  112. {
  113. CDialog::OnSysCommand(nID, lParam);
  114. }
  115. }
  116. // 傕偟僟僀傾儘僌儃僢僋僗偵嵟彫壔儃僞儞傪捛壛偡傞側傜偽丄傾僀僐儞傪昤夋偡傞
  117. // 僐乕僪傪埲壓偵婰弎偡傞昁梫偑偁傝傑偡丅MFC 傾僾儕働乕僔儑儞偼 document/view
  118. // 儌僨儖傪巊偭偰偄傞偺偱丄偙偺張棟偼僼儗乕儉儚乕僋偵傛傝帺摦揑偵張棟偝傟傑偡丅
  119. void CDirect90Dlg::OnPaint() 
  120. {
  121. if (IsIconic())
  122. {
  123. CPaintDC dc(this); // 昤夋梡偺僨僶僀僗 僐儞僥僉僗僩
  124. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  125. // 僋儔僀傾儞僩偺嬮宍椞堟撪偺拞墰
  126. int cxIcon = GetSystemMetrics(SM_CXICON);
  127. int cyIcon = GetSystemMetrics(SM_CYICON);
  128. CRect rect;
  129. GetClientRect(&rect);
  130. int x = (rect.Width() - cxIcon + 1) / 2;
  131. int y = (rect.Height() - cyIcon + 1) / 2;
  132. // 傾僀僐儞傪昤夋偟傑偡丅
  133. dc.DrawIcon(x, y, m_hIcon);
  134. }
  135. else
  136. {
  137. CDialog::OnPaint();
  138. }
  139. }
  140. // 僔僗僥儉偼丄儐乕僓乕偑嵟彫壔僂傿儞僪僂傪僪儔僢僌偟偰偄傞娫丄
  141. // 僇乕僜儖傪昞帵偡傞偨傔偵偙偙傪屇傃弌偟傑偡丅
  142. HCURSOR CDirect90Dlg::OnQueryDragIcon()
  143. {
  144. return (HCURSOR) m_hIcon;
  145. }
  146. void CDirect90Dlg::OnOK() 
  147. {
  148. if(m_CapShow.m_hWnd)
  149. {
  150. HRESULT hr;
  151.         // Create DirectShow graph and start capturing video
  152.         hr = m_Show.CaptureVideo(m_CapShow.m_hWnd);
  153. if (FAILED (hr))
  154.         {
  155. m_Show.ResizeVideoWindow(m_CapShow.m_hWnd);
  156.             m_Show.CloseInterfaces();
  157.         }  
  158. }
  159. }
  160. void CDirect90Dlg::OnButtonFont() 
  161. {
  162. // TODO: 偙偺埵抲偵僐儞僩儘乕儖捠抦僴儞僪儔梡偺僐乕僪傪捛壛偟偰偔偩偝偄
  163. m_Show.SetFont(m_CapShow.m_hWnd);
  164. }
  165. void CDirect90Dlg::OnButtonAdd() 
  166. {
  167. // TODO: 偙偺埵抲偵僐儞僩儘乕儖捠抦僴儞僪儔梡偺僐乕僪傪捛壛偟偰偔偩偝偄
  168. UpdateData(TRUE);
  169. m_Show.UpdataStr(m_CapShow.m_hWnd, m_str);
  170. }
  171. void CDirect90Dlg::OnButtonSave() 
  172. {
  173. // TODO: 偙偺埵抲偵僐儞僩儘乕儖捠抦僴儞僪儔梡偺僐乕僪傪捛壛偟偰偔偩偝偄
  174. }