VideoPlayerDlg.cpp
上传用户:zbtianhong
上传日期:2022-07-12
资源大小:3707k
文件大小:4k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. // VideoPlayerDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "VideoPlayer.h"
  5. #include "VideoPlayerDlg.h"
  6. #include "Usage.h"
  7. #include "AboutDeveloper.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CVideoPlayerDlg dialog
  15. CVideoPlayerDlg::CVideoPlayerDlg(CWnd* pParent /*=NULL*/)
  16. : CDialog(CVideoPlayerDlg::IDD, pParent)
  17. {
  18. //{{AFX_DATA_INIT(CVideoPlayerDlg)
  19. // NOTE: the ClassWizard will add member initialization here
  20. //}}AFX_DATA_INIT
  21. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  22. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  23. m_csPathName = _T("");
  24. }
  25. void CVideoPlayerDlg::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CDialog::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(CVideoPlayerDlg)
  29. // NOTE: the ClassWizard will add DDX and DDV calls here
  30. DDX_Control(pDX, IDC_MediaPlay_OCX, m_MediaPlayer);
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(CVideoPlayerDlg, CDialog)
  34. //{{AFX_MSG_MAP(CVideoPlayerDlg)
  35. ON_WM_PAINT()
  36. ON_WM_QUERYDRAGICON()
  37. ON_COMMAND(IDC_FILE_OPEN, OnFileOpen)
  38. ON_COMMAND(IDC_FILE_QUIT, OnFileQuit)
  39. ON_COMMAND(IDC_HELP_USAGE, OnHelpUsage)
  40. ON_COMMAND(IDC_HELP_ABOUT_DEVELOPER, OnHelpAboutDeveloper)
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CVideoPlayerDlg message handlers
  45. BOOL CVideoPlayerDlg::OnInitDialog()
  46. {
  47. CDialog::OnInitDialog();
  48. // Set the icon for this dialog.  The framework does this automatically
  49. //  when the application's main window is not a dialog
  50. SetIcon(m_hIcon, TRUE); // Set big icon
  51. SetIcon(m_hIcon, FALSE); // Set small icon
  52. // TODO: Add extra initialization here
  53. return TRUE;  // return TRUE  unless you set the focus to a control
  54. }
  55. // If you add a minimize button to your dialog, you will need the code below
  56. //  to draw the icon.  For MFC applications using the document/view model,
  57. //  this is automatically done for you by the framework.
  58. void CVideoPlayerDlg::OnPaint() 
  59. {
  60. if (IsIconic())
  61. {
  62. CPaintDC dc(this); // device context for painting
  63. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  64. // Center icon in client rectangle
  65. int cxIcon = GetSystemMetrics(SM_CXICON);
  66. int cyIcon = GetSystemMetrics(SM_CYICON);
  67. CRect rect;
  68. GetClientRect(&rect);
  69. int x = (rect.Width() - cxIcon + 1) / 2;
  70. int y = (rect.Height() - cyIcon + 1) / 2;
  71. // Draw the icon
  72. dc.DrawIcon(x, y, m_hIcon);
  73. }
  74. else
  75. {
  76. CDialog::OnPaint();
  77. }
  78. }
  79. // The system calls this to obtain the cursor to display while the user drags
  80. //  the minimized window.
  81. HCURSOR CVideoPlayerDlg::OnQueryDragIcon()
  82. {
  83. return (HCURSOR) m_hIcon;
  84. }
  85. void CVideoPlayerDlg::OnFileOpen()
  86. {
  87.    // TODO: Add your command handler code here
  88. char szFileFilter[]="All Music Files(*.*)|*.*||";
  89. CFileDialog FileOpenDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY,szFileFilter/*, this*/);
  90. if( FileOpenDlg.DoModal() == IDOK )
  91. {
  92. m_csPathName = FileOpenDlg.GetPathName();//获取路径名(包括文件名)
  93. }
  94. m_MediaPlayer.SetUrl(m_csPathName); //为播放器设定文件的绝对路径名。
  95. }
  96. void CVideoPlayerDlg::OnFileQuit() 
  97. {
  98. // TODO: Add your command handler code here  
  99. CDialog::OnCancel(); //退出程序
  100. }
  101. void CVideoPlayerDlg::OnHelpUsage() 
  102. {
  103. // TODO: Add your command handler code here
  104. CUsage UsageDlg;
  105. UsageDlg.DoModal(); //显示"使用说明"对话框
  106. }
  107. void CVideoPlayerDlg::OnHelpAboutDeveloper() 
  108. {
  109. // TODO: Add your command handler code here
  110. CAboutDeveloper AboutDeveloperDlg;
  111. AboutDeveloperDlg.DoModal();//显示"关于开发者"对话框
  112.     //AboutDeveloperDlg.Create(IDC_HELP_ABOUT_DEVELOPER,this);
  113.     //AboutDeveloperDlg.ShowWindow(SW_SHOW);
  114. }