2019仿真程序设计面向对象程序课程设计说明精品.doc
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
河南科技大学
课程设计说明书
课程名称面向对象程序课程设计
题目DVD仿真程序设计
院系电子信息工程学院
课程设计任务书
课程设计报告文档
题目:DVD仿真程序设计
一.引言
1.编写目的:
实现模拟DVD的功能需要包含①数据显示区域(相当于显示类的产品),②DVD模拟区域,实现模拟DVD的快进,快退,播放,暂停,菜单,上一首,下一首,音量的加,音量减的功能。
此外模拟了一个接口按钮,用于DVD 向显示设备的数据输入。
还模拟了一个DVD的电源开关。
至此,实现此次DVD 仿真模拟的设计目的。
2. 定义:
MFC (Microsoft Foundation Classes):是一个微软公司提供的类库(class libraries),以C++类的形式封装了Windows的API,并且包含一个应用程序框架,以减少应用程序开发人员的工作量。
其中包含的类包含大量Windows句柄封装类和很多Windows的内建控件和组件的封装类
3.参考资料:
[1] 郑秋生. c/c++程序设计教程—面向对象分册. 北京:电子工业出版社,2012
[2]邱勇、肖春宝、白秀玲. 《可视化程序设计》. 北京:清华大学出版社
[3] 黄维通. visual c++面向对象与可视化程序设计. 北京:清华大学出版社
二.任务的描述
1.目标:
通过本课程设计,使学生巩固面向对象程序设计的基本概念、原理和技术,学会使用C++语言进行简单程序的开发,将理论与实际相结合,完成一个小型程序的设计与实现,并在此基础上强化学生的实践意识,提高其实际动手能力和创新能力。
2. 功能描述:
DVD的仿真模拟分为①数据显示区域(相当于显示类的产品),②DVD 模拟区域,模拟DVD的快进,快退,播放,暂停,菜单,上一首,下一首,音量的加,音量减的功能。
此外模拟了一个接口按钮,用于DVD向显示设备的数据输入。
模拟了一个DVD的电源开关。
③光碟数据的存储区域模拟。
点击按钮可以打开数据中心仓库,
区域1:可以点击此按钮打开光碟数据存储仓库,打开后的界面如下图所示。
区域2:点击鼠标的右键可以打开右键菜单:{1.添加文件到列表 2.删除列表中文件}
区域3:实现DVD的模拟功能:
点击快进按钮实现快进功能;
点击快退按钮实现快退功能;
点击播放按钮实现播放功能;
点击暂停按钮实现暂停功能;
点击+按钮实现音量的加功能;
点击--按钮实现音量减的功能;
点击菜单按钮可以实现DVD光碟返回到菜单的功能;
模拟了一个接口按钮,相当于DVD像显示接口插入的一条数据线,用于DVD 向显示设备的数据输入;
电源开关实现DVD机关闭的功能。
区域1:可以点击此按钮打开光碟数据然后直接打开播放器小窗口播放,播放器的小窗口如下图。
鼠标右键点击此按钮的可以弹出右键菜单,右键菜单响应的事件功能有,{播放和查看文件的大小属性}。
区域2:点击鼠标的右键可以打开右键菜单:{1.添加文件到列表 2.删除列表中文件}
区域3:显示当前播放文件的路径
区域4:点击可以打开文件选择对话框,实现让用户选择非DVD格式的文件。
这是在DVD 基础上对于播放的扩展。
功能的增强。
区域5:点击此按钮可以查看播放器支持的文件格式。
区域1:可以点击对应的菜单实现对应的音影的播放功能。
区域2:点击全屏按钮实现全屏播放
上图播放DVD时候的小窗口播放界面。
上面为DVD文件的播放菜单,DVD文件是用转换工具转换的DVD整个光碟,由于转换的速度较慢,且转换后文件较大,一个大约6G,一个大约2G,转换时间周期较长,用晚上转换的。
转换后的DVD文件没法加入电子档。
总计8G。
在此说明一下。
3.性能描述
(1)数据精确度:播放的时间在毫秒级
(2)时间特性:响应时间,更新处理时间,运行时间等都较短。
4.运行环境:
硬件:Windows7操作系统平台
软件:Visual C++6.0
5.条件与限制:条件是由于播放DVD的文件解码较苛刻,系统必须安装有DVD 格式的解码器。
三.任务设计
1.类的划分:
(1)类1:
class CAaDlg : public CDialog
{
public:
CAaDlg(CWnd* pParent = NULL); // standard constructor
enum { IDD = IDD_AA_DIALOG };
CListBox m_list;
CButton m_Open;
CButton m_Play;
CButton m_Up;
CButton m_Stop;
CButton m_Down1;
int t;
bool t1;
CButton m_Slow;
CButton m_V olSmall;
CButton m_V olBig;
CButton m_Menu;
CButton m_JieKou;
CButton m_Forhead;
CButton m_Close;
CWMPPlayer4 m_WMPlayer;
CWMPControls m_Control;
CWMPDVD m_wmpDVD;
CWMPSettings m_set;
CWMPPlaylist m_playlist;
CWMPMedia m_media;
CWMPPlayer4 m_WMp;
CString str1;
Dlg1 dlg1;
int k;
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
protected:
HICON m_hIcon;
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnBUTTOClose();
afx_msg void OnBUTTONForhead();
afx_msg void OnBUTTOSlow();
afx_msg void OnBUTTONV olBig();
afx_msg void OnBUTTONV olSmall();
afx_msg void OnBUTTONJIeKou();
afx_msg void OnBUTTONDown();
afx_msg void OnBUTTOPlay();
afx_msg void OnBUTTONStop();
afx_msg void OnButtonup();
afx_msg void OnBUTTONMenu();
afx_msg void OnOpen();
afx_msg void OnDblclkList1();
DECLARE_MESSAGE_MAP()
};
CAaDlg 类实现了模拟DVD的主界面的功能实现。
成员函数OnBUTTOClose()实现DVD 电源的关闭功能,成员函数OnBUTTOPlay()实现播放功能;成员函数OnBUTTONStop()实现音视频的暂停功能;成员函数OnBUTTONForhead()实现快进功能;成员函数OnBUTTOSlow()实现快退功能;成员函数OnBUTTONV olBig()实现音量增加功能;成员函数OnBUTTONV olSmall()实现音量减小功能等;
(2)类2:
class Dlg1 : public CDialog
{
public:
Dlg1(CWnd* pParent = NULL);
enum { IDD = IDD_DIALOG1 };
CListBox m_list;
CButton m_btn5;
CButton m_btn4;
CButton m_btn3;
CButton m_btn2;
CButton m_btn1;
SmallPlayer smallplayer;
int p;
CString m_edit;
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
protected:
afx_msg void OnButton1();
virtual BOOL OnInitDialog();
afx_msg void OnButton3();
afx_msg void OnButton2();
afx_msg void OnButton5();
afx_msg void OnButton4();
afx_msg void OnSelchangeList1();
afx_msg void OnDblclkList1();
DECLARE_MESSAGE_MAP()
};
类Dlg1实现把DVD光碟存放区域的显示,光碟在此区域存放。
(3)类3:
class SmallPlayer : public CDialog
{
public:
SmallPlayer(CWnd* pParent = NULL); // standard constructor
enum { IDD = IDD_DIALOG2 };
CButton m_btn1;
CButton m_btn2;
CWMPPlayer4 m_ocx1;
CWMPControls m_control;
CWMPDVD m_dvd;
CWMPPlaylist m_playlist;
CWMPSettings m_set;
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
protected:
afx_msg void OnButton1();
afx_msg void OnButton2();
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
};
类SmallPlayer 实现把DVD光碟的小窗口播放。
2.类的接口设计:
(1)类1:
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
(2)类2:
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
protected:
afx_msg void OnButton1();
virtual BOOL OnInitDialog();
afx_msg void OnButton3();
afx_msg void OnButton2();
afx_msg void OnButton5();
afx_msg void OnButton4();
afx_msg void OnSelchangeList1();
afx_msg void OnDblclkList1();
DECLARE_MESSAGE_MAP()
(3)类3:
protected:
afx_msg void OnButton1();
afx_msg void OnButton2();
virtual BOOL OnInitDialog();
DECLARE_MESSAGE_MAP()
说明protected是windows机制的消息函数。
Windows消息机制Windows系统是一个消息驱动的OS,一个消息由一个消息名称(UINT),和两个参数(WPARAM,LPARAM)。
当用户进行了输入或是窗口的状态发生改变时系统都会发送消息到某一个窗口。
例如当菜单转中之后会有WM_COMMAND消息发送,WPARAM的高字中(HIWORD(wParam))是命令的ID号,对菜单来讲就是菜单ID。
当然用户也可以定义自己的消息名称,也可以利用自定义消息来发送通知和传送数据。
一个消息必须由一个窗口接收。
在窗口的过程(WNDPROC)中可以对消息进行分析,对自己感兴趣的消息进行处理。
例如你希望对菜单选择进行处理那么你可以定义对WM_COMMAND进行处理的代码,如果希望在窗口中进行图形输出就必须对WM_PAINT 进行处理。
也相当于与用户交互的接口。
3. 类之间的关系:
类CAboutDlg、类SmallPlayer 、类Dlg1、类CAaDlg ,都是继承自CDialog类。
类CAaDlg 和类Dlg1是包含关系,类Dlg1和类SmallPlayer 也是包含关系
四.编写代码
1.问题1
(1)问题描述:
点击按钮新的窗体无法弹出。
(2)解决办法:
新的窗体类没有加到父窗体的头文件中。
且关于模态对话框与非模态对话框的显示机制不同。
模态可以使用Domal()函数实现。
非模态对
话框的建立需要dlg1.Create(IDD_DIALOG1,this);即类创建显示的窗体UI;
dlg1.ShowWindow(SW_SHOW);然后显示窗体。
这样才完成一个非模态对话框的建立。
问题得以解决。
2.问题2
(1)问题描述:播放文件时,列表中选中的文件播放的是列表中其他的文件
(2)解决办法:使用m_list.SetCurSel()设置列表索引号,这样索引顺序正确,问题得到解决。
五.运行结果与分析
1.程序运行的过程:程序先执行主对话框,当用户点击代开DVD数据按钮程序响应windows消息映射,通过windows机制在内存中建立新的类dlg1,此类是主窗体中包含的成员函数。
2.类的构造顺序:先构造类CAaDlg ,然后构造类Dlg1.
3.错误描述及其解决办法
(1)问题1:
问题描述:点击音量增加按钮音量无法增加,代码已经添加。
解决办法:没有把wmpcontrol类的头文件包含,加入头文件即可。
(2)问题2
问题描述:点击list区域鼠标点击的位置和右键菜单出现的位置有距离差;
解决办法:在ClientToScreen(&pt)这一句不需要把坐标转换成客户区域坐标。
………………………………………
六、感想认识
这次课程设计对于面向对象的思想有深刻的体会。
这次课程设计无论是我需找DVD格式文件的创建刻录,等等功能,自己没有接触过刚开始一头雾水自己的想法不好实现。
通过网络的搜索需找,得到解决的途径。
,这样不仅培养了遇到问题的思考方法,而且更培养了我编程中分析问题,解决问题的方法途径等等。
更使得我对于对面向对象的封装,继承以及多态性等特点以及优点理解,也让自己对微软MFC编程有了一定的认识,通过封装类我们把想要现的功能封装起来,通过继承我们可以对已有类进行扩充,通过多态性我可以让不同对象面对同一消息有各自的响应。
这次设计使我进步很大,收获颇丰。
七.程序代码
文件Aadlg.h
#include "wmpplayer4.h"
#include "wmpcontrols.h"
#include "wmpdvd.h"
#include "wmpplayer4.h"
#include "wmpmedia.h"
#include "wmpplaylist.h"
#include "wmpsettings.h"
#include "Dlg1.h"
//}}AFX_INCLUDES
#if !defined(AFX_AADLG_H__C8019617_E9EB_4714_B667_009BB531DE6E__INCLUDED_ )
#define AFX_AADLG_H__C8019617_E9EB_4714_B667_009BB531DE6E__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// CAaDlg dialog
class CAaDlg : public CDialog
{
// Construction
public:
CAaDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CAaDlg)
enum { IDD = IDD_AA_DIALOG };
CListBox m_list;
CButton m_Open;
CButton m_Play;
CButton m_Up;
CButton m_Stop;
CButton m_Down1;
int t;
bool t1;
CButton m_Slow;
CButton m_VolSmall;
CButton m_VolBig;
CButton m_Menu;
CButton m_JieKou;
CButton m_Forhead;
CButton m_Close;
CWMPPlayer4 m_WMPlayer;
CWMPControls m_Control;
CWMPDVD m_wmpDVD;
CWMPSettings m_set;
CWMPPlaylist m_playlist;
CWMPMedia m_media;
CWMPPlayer4 m_WMp;
CString str1;
Dlg1 dlg1;
int k;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAaDlg)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
protected:
HICON m_hIcon;
// Generated message map functions
//{{AFX_MSG(CAaDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnBUTTOClose();
afx_msg void OnBUTTONForhead();
afx_msg void OnBUTTOSlow();
afx_msg void OnBUTTONV olBig();
afx_msg void OnBUTTONV olSmall();
afx_msg void OnBUTTONJIeKou();
afx_msg void OnBUTTONDown();
afx_msg void OnBUTTOPlay();
afx_msg void OnBUTTONStop();
afx_msg void OnButtonup();
afx_msg void OnBUTTONMenu();
afx_msg void OnOpen();
afx_msg void OnDblclkList1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
文件aadlg.cpp
#include "stdafx.h"
#include "aa.h"
#include "aaDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAaDlg dialog
CAaDlg::CAaDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAaDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAaDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32 t=1;
t1=true;
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CAaDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAaDlg)
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_BUTTON2, m_Open);
DDX_Control(pDX, IDC_BUTTOPlay, m_Play);
DDX_Control(pDX, IDC_BUTTONUP, m_Up);
DDX_Control(pDX, IDC_BUTTONStop, m_Stop);
DDX_Control(pDX, IDC_BUTTONDown, m_Down1);
DDX_Control(pDX, IDC_BUTTOSlow, m_Slow);
DDX_Control(pDX, IDC_BUTTONVolSmall, m_V olSmall);
DDX_Control(pDX, IDC_BUTTONVolBig, m_V olBig);
DDX_Control(pDX, IDC_BUTTONMenu, m_Menu);
DDX_Control(pDX, IDC_BUTTONJIeKou, m_JieKou);
DDX_Control(pDX, IDC_BUTTONForhead, m_Forhead);
DDX_Control(pDX, IDC_BUTTOClose, m_Close);
DDX_Control(pDX, IDC_OCX1, m_WMp);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAaDlg, CDialog)
//{{AFX_MSG_MAP(CAaDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTOClose, OnBUTTOClose)
ON_BN_CLICKED(IDC_BUTTONForhead, OnBUTTONForhead) ON_BN_CLICKED(IDC_BUTTOSlow, OnBUTTOSlow)
ON_BN_CLICKED(IDC_BUTTONV olBig, OnBUTTONV olBig)
ON_BN_CLICKED(IDC_BUTTONV olSmall, OnBUTTONVolSmall) ON_BN_CLICKED(IDC_BUTTONJIeKou, OnBUTTONJIeKou)
ON_BN_CLICKED(IDC_BUTTONDown, OnBUTTONDown)
ON_BN_CLICKED(IDC_BUTTOPlay, OnBUTTOPlay)
ON_BN_CLICKED(IDC_BUTTONStop, OnBUTTONStop)
ON_BN_CLICKED(IDC_BUTTONUP, OnButtonup)
ON_BN_CLICKED(IDC_BUTTONMenu, OnBUTTONMenu)
ON_BN_CLICKED(IDC_BUTTON2, OnOpen)
ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAaDlg message handlers
BOOL CAaDlg::OnInitDialog()
{
HICON DVDIcon,BoxIcon;
CDialog::OnInitDialog();
DVDIcon=AfxGetApp()->LoadIcon(IDI_ICON1);
BoxIcon=AfxGetApp()->LoadIcon(IDI_ICON2);
SetIcon(DVDIcon,TRUE);
m_Open.SetIcon(BoxIcon);
dlg1.Create(IDD_DIALOG1,this);
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
m_Control=m_WMp.GetControls();
m_set=m_WMp.GetSettings();
m_wmpDVD=m_WMp.GetDvd();
m_WMp.SetUiMode("None");
m_WMp.SetEnableContextMenu(FALSE);
//m_WMp.SetFullScreen();
// a1=TRUE;
// a2=TRUE;
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CAaDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CAaDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CAaDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CAaDlg::OnBUTTOClose()
{
// TODO: Add your control notification handler code here
//m_WMp.
if(t1)
{
t1=false;
GetDlgItem(IDC_BUTTOClose)->SetWindowText("电源开");
m_Control.stop();
m_WMp.SetUrl(NULL);
}
else
{
t1=TRUE;
GetDlgItem(IDC_BUTTOClose)->SetWindowText("电源关");
m_Control.play();
}
}
// char szFileFilter[]=
//"VOB File(*.vob)|*.vob|"
// "Mp3 File(*.mp3)|*.mp3|"
// "MPEG File(*.mpeg)|*.mpeg|"
// "Media File(*.asf)|*.asf|"
// "Video File(*.dat)|*.dat|"
// "MPGA File(*.mpga)|*.mpga|"
// "Wave File(*.wav)|*.wav|"
// "AVI File(*.avi)|*.avi|"
// "Movie File(*.mov)|*.mov|"
// "Mid File(*.mid;*,rmi)|*.mid;*.rmi|"
// "Wma File(*.wma)|*.wma|"
// "All File(*.*)|*.*||";
// CFileDialog fileDialog( TRUE,NULL,NULL,NULL,szFileFilter,this); // if (fileDialog.DoModal() == IDOK)
// {
// CString fileName=fileDialog.GetPathName();
// m_avPlayer.put_URL(fileName);
// }
void CAaDlg::OnBUTTONForhead()
{
// TODO: Add your control notification handler code here
// if (a1)
// {
m_Control.fastForward();
// a1=false;
// }
// else
}
void CAaDlg::OnBUTTOSlow()
{
// TODO: Add your control notification handler code here
m_Control.fastReverse();
/*m_Control.*/
}
void CAaDlg::OnBUTTONV olBig()
{
// TODO: Add your control notification handler code here
int i=m_set.GetV olume();
i++;
m_set.SetVolume(i);
}
void CAaDlg::OnBUTTONV olSmall()
{
// TODO: Add your control notification handler code here
int i=m_set.GetV olume();
i--;
m_set.SetVolume(i);
}
void CAaDlg::OnBUTTONJIeKou()
{
// TODO: Add your control notification handler code here
if(t)
{
t=0;
GetDlgItem(IDC_BUTTONJIeKou)->SetWindowText("接口开");
m_Control.stop();
}
else
{
t=1;
GetDlgItem(IDC_BUTTONJIeKou)->SetWindowText("接口关");
m_Control.play();
}
}
BOOL CAaDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
CRect Rt1;
POINT pt;
CMenu cmenu;
if (pMsg->message==WM_RBUTTONDOWN)
{
::GetWindowRect(GetDlgItem(IDC_LIST1)->GetSafeHwnd(),&Rt1);
::GetCursorPos(&pt);
if (PtInRect(&Rt1,pt))
{
cmenu.LoadMenu(IDR_MENU1);
CMenu *pPopup=cmenu.GetSubMenu(0);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,this);
}
}
return CDialog::PreTranslateMessage(pMsg);
}
BOOL CAaDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
UINT uMsg=LOWORD(wParam);
char szFileFilter[]=
"DVD光碟(*.vob;*.ifo)|*.vob;*.ifo|"
"Mp3 File(*.mp3)|*.mp3|"
"MPEG File(*.mpeg)|*.mpeg|"
"Media File(*.asf)|*.asf|"
"Video File(*.dat)|*.dat|"
"MPGA File(*.mpga)|*.mpga|"
"Wave File(*.wav)|*.wav|"
"AVI File(*.avi)|*.avi|"
"Movie File(*.mov)|*.mov|"
"Mid File(*.mid;*.rmi)|*.mid;*.rmi|"
"Wma File(*.wma)|*.wma|"
"All File(*.*)|*.*||";
if (uMsg==ID_MENUITEM32771)
{
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONL Y,szFileFilter);
if (dlg.DoModal()==IDOK)
{
CString PathName=dlg.GetPathName();
PathName.MakeUpper();
int nIndex = m_list.GetCurSel();
m_list.InsertString(nIndex,PathName);
m_WMp.SetUrl(PathName);
//MessageBox(PathName);
}
}
if (uMsg==ID_MENUITEM32772)
{
int nIndex=m_list.GetCurSel();
int nState = this->m_list.GetSel(nIndex);
if (nState)
{
m_list.DeleteString(nIndex);
}
else
return 0;
}
return CDialog::OnCommand(wParam, lParam);
}
void CAaDlg::OnBUTTONDown()
{
// TODO: Add your control notification handler code here
m_Control.next();
}
void CAaDlg::OnBUTTOPlay()
{
// TODO: Add your control notification handler code here
m_Control.play();
}
void CAaDlg::OnBUTTONStop()
{
// TODO: Add your control notification handler code here m_Control.pause();
}
void CAaDlg::OnButtonup()
{
// TODO: Add your control notification handler code here
m_Control.previous();
}
void CAaDlg::OnBUTTONMenu()
{
// TODO: Add your control notification handler code here m_wmpDVD.titleMenu();
}
void CAaDlg::OnOpen()
{
// TODO: Add your control notification handler code here
dlg1.ShowWindow(SW_SHOW);
}
void CAaDlg::OnDblclkList1()
{
// TODO: Add your control notification handler code here CString tr;
int select;
//int a=m_CList.GetCurSel();
select=m_list.GetCurSel();
//total=m_list.GetCount();
m_list.GetText(select,tr);
m_WMp.SetUrl(tr);
m_Control.play();
//m_WMp.ShowWindow(SW_SHOW);
//SetDlgItemText(IDC_EDIT1,tr);
}
文件Dlg1.h
//
//{{AFX_INCLUDES()
#include "SmallPlayer.h"
//}}AFX_INCLUDES
#if !defined(AFX_DLG1_H__15EEADF6_D4B1_469E_B24C_30872496AF0D__INCLUDED_) #define AFX_DLG1_H__15EEADF6_D4B1_469E_B24C_30872496AF0D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// Dlg1.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// Dlg1 dialog
class Dlg1 : public CDialog
{
// Construction
public:
Dlg1(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(Dlg1)
enum { IDD = IDD_DIALOG1 };
CListBox m_list;
CButton m_btn5;
CButton m_btn4;
CButton m_btn3;
CButton m_btn2;
CButton m_btn1;
SmallPlayer smallplayer;
int p;
CString m_edit;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(Dlg1)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);
//}}AFX_VIRTUAL
// Implementation
protected:
// Generated message map functions
//{{AFX_MSG(Dlg1)
afx_msg void OnButton1();
virtual BOOL OnInitDialog();
afx_msg void OnButton3();
afx_msg void OnButton2();
afx_msg void OnButton5();
afx_msg void OnButton4();
afx_msg void OnSelchangeList1();
afx_msg void OnDblclkList1();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCA TION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif
// !defined(AFX_DLG1_H__15EEADF6_D4B1_469E_B24C_30872496AF0D__INCLUDE D_)
文件dlg1.cpp
// Dlg1.cpp : implementation file
//
#include "stdafx.h"
#include "aa.h"
#include "Dlg1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Dlg1 dialog
Dlg1::Dlg1(CWnd* pParent /*=NULL*/)
: CDialog(Dlg1::IDD, pParent)
{
//{{AFX_DATA_INIT(Dlg1)
m_edit = _T("");
//}}AFX_DATA_INIT
}
void Dlg1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Dlg1)
DDX_Control(pDX, IDC_LIST1, m_list);
DDX_Control(pDX, IDC_BUTTON5, m_btn5);
DDX_Control(pDX, IDC_BUTTON4, m_btn4);
DDX_Control(pDX, IDC_BUTTON3, m_btn3);
DDX_Control(pDX, IDC_BUTTON2, m_btn2);
DDX_Control(pDX, IDC_BUTTON1, m_btn1);
DDX_Text(pDX, IDC_EDIT1, m_edit);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Dlg1, CDialog)
//{{AFX_MSG_MAP(Dlg1)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1) ON_LBN_DBLCLK(IDC_LIST1, OnDblclkList1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Dlg1 message handlers
// bool Dlg1::OnInitDialog()
// {
// CDialog::OnInitDialog();
//
// return true;
// }
BOOL Dlg1::OnInitDialog()
{
HICON DVDIcon,BoxIcon;
CDialog::OnInitDialog();
DVDIcon=AfxGetApp()->LoadIcon(IDI_ICON1);
BoxIcon=AfxGetApp()->LoadIcon(IDI_ICON2);
SetIcon(DVDIcon,TRUE);
m_btn1.SetIcon(BoxIcon);
m_btn2.SetIcon(BoxIcon);
m_btn3.SetIcon(BoxIcon);
smallplayer.Create(IDD_DIALOG2,this);
p=0;
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE }
void Dlg1::OnButton1()
{
// TODO: Add your control notification handler code here
//Dlg1.EndDialog(IDCANCEL)
//
//CString PathName=dlg.GetPathName();
smallplayer.ShowWindow(SW_SHOW);
//
smallplayer.m_ocx1.SetUrl(((CAaApp *)AfxGetApp())->str1);
//MessageBox(((CAaApp *)AfxGetApp())->str1);
//smallplayer.m_ocx1.GetControls().play();
}
void Dlg1::OnButton3()
{
// TODO: Add your control notification handler code here
MessageBox("光碟夹里无光碟");
}
void Dlg1::OnButton2()
{
// TODO: Add your control notification handler code here
smallplayer.ShowWindow(SW_SHOW);
smallplayer.m_ocx1.SetUrl(((CAaApp *)AfxGetApp())->str2);
//smallplayer.m_ocx1.GetControls().play();
}
void Dlg1::OnButton5()
{
// TODO: Add your control notification handler code here
CString str3("所支持的非格式:mp3,wma,Avi,MP4,mpeg,asf,dat,mpga,wav,mov,mid,rmi");
MessageBox(str3,"支持格式",MB_OK);
}
BOOL Dlg1::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
CRect r1,r2,r3,r4,r5;
CRect Rt1;
CMenu cmenu1;
POINT pt;
CMenu c_menu;
::GetWindowRect(GetDlgItem(IDC_BUTTON1)->GetSafeHwnd(),&r1); //得到button所在的rect
::GetWindowRect(GetDlgItem(IDC_BUTTON2)->GetSafeHwnd(),&r2);
::GetWindowRect(GetDlgItem(IDC_BUTTON3)->GetSafeHwnd(),&r3);
::GetWindowRect(GetDlgItem(IDC_BUTTON4)->GetSafeHwnd(),&r4);
::GetWindowRect(GetDlgItem(IDC_EDIT1)->GetSafeHwnd(),&r5);
::GetCursorPos(&pt);//得到鼠标动作的位置
if (pMsg->message==WM_RBUTTONDOWN)
{
::GetWindowRect(GetDlgItem(IDC_LIST1)->GetSafeHwnd(),&Rt1);
::GetCursorPos(&pt);
if (PtInRect(&Rt1,pt))
{
cmenu1.LoadMenu(IDR_MENU1);
CMenu *pPopup=cmenu1.GetSubMenu(0);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,this);
}
}
//
// {
// pMsg->message==WM_LBUTTONDOWN;
//
if (PtInRect(&r1,pt))
{
if (pMsg->message==WM_LBUTTONUP)
{
if (PtInRect(&r5,pt))
{
smallplayer.m_ocx1.SetUrl(((CAaApp *)AfxGetApp())->str1);
smallplayer.ShowWindow(SW_SHOW);
}
}
}
// TODO: 在此添加专用代码和/或调用基类
if (pMsg->message==WM_RBUTTONDOWN)
{
if (PtInRect(&r1,pt)||PtInRect(&r2,pt)||PtInRect(&r3,pt))
{
c_menu.LoadMenu(IDR_MENU2);
CMenu *pPopup=c_menu.GetSubMenu(0);
//ClientToScreen(&pt);//因为point的位置是从屏幕的左上角为起点开始计算的,要想让菜单在正确的位置显示就要使用这个ClientToScreen函数将屏幕菜单转化成为正确的view坐标。
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y,this);//不想在框架类显示就把GetParent()改为this。
//trackpopupmenu是用来显示右击菜单的。
//AfxMessageBox(_T("右键单击"))
}
if (PtInRect(&r4,pt))
{
c_menu.LoadMenu(IDR_MENU3);
CMenu *pPopup=c_menu.GetSubMenu(0);
//ClientToScreen(&pt);//因为point的位置是从屏幕的左上角为起点开始计算的,要想让菜单在正确的位置显示就要使用这个ClientToScreen函数将屏幕菜单转化成为正确的view坐标。
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y,this);//不想在框架类显示就把GetParent()改为this。
//trackpopupmenu是用来显示右击菜单的。
//AfxMessageBox(_T("右键单击"))
}
}
return CDialog::PreTranslateMessage(pMsg);
}
BOOL Dlg1::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
UINT uMsg=LOWORD(wParam);
CRect r1,r2;
POINT pt;
char szFileFilter[]=
"Mp3 File(*.mp3)|*.mp3|"
"MPEG File(*.mpeg)|*.mpeg|"
"Media File(*.asf)|*.asf|"
"Video File(*.dat)|*.dat|"
"MPGA File(*.mpga)|*.mpga|"
"Wave File(*.wav)|*.wav|"
"AVI File(*.avi)|*.avi|"
"Movie File(*.mov)|*.mov|"
"Mid File(*.mid;*.rmi)|*.mid;*.rmi|"
"Wma File(*.wma)|*.wma|"
"All File(*.*)|*.*||";
::GetWindowRect(GetDlgItem(IDC_BUTTON1)->GetSafeHwnd(),&r1); //得到button所在的rect
::GetWindowRect(GetDlgItem(IDC_BUTTON2)->GetSafeHwnd(),&r2);
::GetCursorPos(&pt);//得到鼠标动作的位置
if (uMsg==ID_MENUITEM32771)
{
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONL Y,szFileFilter);
if (dlg.DoModal()==IDOK)
{
CString PathName=dlg.GetPathName();
PathName.MakeUpper();
int nIndex = m_list.GetCurSel();
m_list.InsertString(nIndex,PathName);
smallplayer.m_ocx1.SetUrl(PathName);
//MessageBox(PathName);
}
}
if (uMsg==ID_MENUITEM32772)
{
int nIndex=m_list.GetCurSel();。