📄 gpsplayerdlg.cpp
字号:
// GPSPlayerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "GPSPlayer.h"
#include "GPSPlayerDlg.h"
#include "wmpcontrols.h"
#include "afxdlgs.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()
/////////////////////////////////////////////////////////////////////////////
// CGPSPlayerDlg dialog
CGPSPlayerDlg::CGPSPlayerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGPSPlayerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGPSPlayerDlg)
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGPSPlayerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGPSPlayerDlg)
DDX_Control(pDX, IDC_LOAD_BUTTON, m_load);
DDX_Control(pDX, IDC_KIND_COMBO, m_Kind);
DDX_Control(pDX, IDC_OCX1, m_player);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGPSPlayerDlg, CDialog)
//{{AFX_MSG_MAP(CGPSPlayerDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_OPEN_BUTTON, OnOpenButton)
ON_BN_CLICKED(IDC_EXIT_BUTTON, OnExitButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGPSPlayerDlg message handlers
BOOL CGPSPlayerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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);
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
UpdateData(TRUE);
m_Kind.AddString("大豆");
m_Kind.AddString("棉花");
m_Kind.AddString("玉米");
m_Kind.AddString("裸地");
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
m_Kind.SelectString (-1,"冬小麦");
/*CMainWnd*pFrame=new CMainWnd;
pFrame->Create(0,_T("消息映射演示程序"));
pFrame->ShowWindow(SW_SHOW);
pFrame->UpdateWindow();
this->m_pMainWnd=pFrame;
return TRUE;*/
}
void CGPSPlayerDlg::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 CGPSPlayerDlg::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 CGPSPlayerDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
BOOL CGPSPlayerDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::OnNotify(wParam, lParam, pResult);
}
void CGPSPlayerDlg::OnOpenButton()
// TODO: Add your control notification handler code here
{
CString Filter;
CString FilePathName;
Filter = "Media Files (*.wav)|*.wav|AVI Files (*.avi)|*.avi|Midi Files (*.mid)|*.mid|MPEG Files (*.mpg)|*.mpg|All Files (*.*)|*.*||";
CFileDialog FileDlg(TRUE, "Media Files (*.wav|*.avi||)", NULL,
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
Filter,
this);//
// CFileDialog dlg(TRUE);//TRUE为OPEN对话框,FALSE为SAVE AS对话框
if (FileDlg.DoModal()==IDOK)
{
FilePathName=FileDlg.GetPathName();
(m_player.GetControls()).stop();
m_player.SetUrl(FilePathName);
(m_player.GetControls()).play();
}
}
BEGIN_EVENTSINK_MAP(CGPSPlayerDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CGPSPlayerDlg)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
//void CGPSPlayerDlg::OnOpenStateChangeOcx1(long NewState)
//{
// TODO: Add your control notification handler code here
//}
void CGPSPlayerDlg::OnExitButton()
{
// TODO: Add your control notification handler code here
OnOK();
}
/*
void CGPSPlayerDlg::OnDraw(CDC* pDC)
{
// TODO: Add your control notification handler code here
CMyGraphDoc* pDoc=GetDocument();
ASSERT_VALID(pDoc);
pDoc->MoveTo(410,60);
pDoc->Rectangle(200,80,300,200);
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -