📄 mmsserverdlg.cpp
字号:
/*
* Openmysee
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
//
#include "stdafx.h"
#include "MMSServer.h"
#include "MMSServerDlg.h"
#include "addmmsdlg.h"
#include "ConfigFile.h"
#include "MMSINFO.h"
#include ".\mmsserverdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define NIIF_WARNING 0x00000002
/////////////////////////////////////////////////////////////////////////////
// CMMSServerDlg dialog
CMMSServerDlg::CMMSServerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMMSServerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMMSServerDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
//m_Button = FALSE;
}
void CMMSServerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMMSServerDlg)
DDX_Control(pDX, IDC_BTN_STOP, m_Button);
DDX_Control(pDX, IDC_LIST_MMS, m_lstMMS);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMMSServerDlg, CDialog)
//{{AFX_MSG_MAP(CMMSServerDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_DESTROY()
ON_COMMAND(ID_MAXIMIZE, OnMaximize)
ON_COMMAND(ID_QUIT, OnQuit)
ON_WM_SYSCOMMAND()
ON_BN_CLICKED(IDC_BTN_ADD_MMS, OnBtnAddMms)
ON_BN_CLICKED(IDC_BTN_PLAY, OnBtnPlay)
ON_BN_CLICKED(IDC_BTN_PAUSE, OnBtnPause)
ON_BN_CLICKED(IDC_BTN_STOP, OnBtnStop)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BTN_DELETE_MMS, OnBtnDeleteMms)
ON_NOTIFY(NM_CLICK, IDC_LIST_MMS, OnClickListMms)
ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMMSServerDlg message handlers
BOOL CMMSServerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 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 icod
(void)m_lstMMS.SetExtendedStyle( LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
m_lstMMS.SetHeadings(
_T("频道名,40;MMS地址,150;KBPS,20;时间,20;状态,50;SP地址,110;数据大小,20")
);
m_lstMMS.LoadColumnInfo();
HICON hIcon = ::LoadIcon(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME)); // Icon to use
// Create the tray icon
if (!m_TrayIcon.Create(
NULL, // Let icon deal with its own messages
WM_ICON_NOTIFY, // Icon notify message to use
_T("MMSServer1.1"), // tooltip
hIcon,
IDR_POPUP_MENU, // ID of tray icon
FALSE,
_T("你可以双击这儿打开操作界面!\n此版本支持播放列表的mms流。"), // balloon tip
_T("MMSServer1.1"), // balloon title
NIIF_WARNING, // balloon icon
20 )) // balloon timeout
{
return -1;
}
////////////////////////// find the file
CString str_path;
GetModuleFileName(NULL,str_path.GetBuffer(MAX_PATH),MAX_PATH);
str_path.ReleaseBuffer();
int index = str_path.ReverseFind('\\');
str_path = str_path.Left(index+1);
CFileFind fileFind;
static const TCHAR szFileToFind[] = _T("MMSControl.ini");
BOOL bResult = fileFind.FindFile(str_path+szFileToFind);
if (bResult)
{
ConfigFile myfile((str_path+"MMSControl.ini").GetBuffer(MAX_PATH));
for( m_Item=0; ; m_Item++)
{
char buffer[20];
_itoa( m_Item, buffer, 10 );
string CC="CaptureServer"+(string)buffer;
string Name =myfile.Value(CC,"channelName");
if(Name=="")
break ;
string MMSAdress=myfile.Value(CC,"MMSAddress");
string DataRate=myfile.Value(CC,"DataRate(KB/s)");
string TimeEscaped=myfile.Value(CC,"time escaped");
string State=myfile.Value(CC,"State");
string spIP=myfile.Value(CC,"spAddress");
m_lstMMS.AddItem(Name.data(),
MMSAdress.data(),
"0.00",//DataRate.data(),
"0", // TimeEscaped.data(),
State.data(),
spIP.data(),
"0");
}
}
else
{
;
}
// MFC version of CSystemTray automatically sends messages to the main app window
#ifdef USING_NONMFC_TRAY // This is set in project settings
m_TrayIcon.SetTargetWnd(GetSafeHwnd()); // Send all menu messages here.
#endif
m_TrayIcon.SetMenuDefaultItem(3, TRUE);
m_dwTimer = SetTimer(1000, 1000, NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
// 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 CMMSServerDlg::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 CMMSServerDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMMSServerDlg::OnDestroy()
{
m_lstMMS.SaveColumnInfo();
KillTimer(m_dwTimer);
CDialog::OnDestroy();
}
void CMMSServerDlg::OnMaximize()
{
#ifndef _WIN32_WCE
#ifdef USING_NONMFC_TRAY // This is set in project settings
CSystemTray::MaximiseFromTray(GetSafeHwnd());
#else
CSystemTray::MaximiseFromTray(this);
#endif
m_TrayIcon.SetMenuDefaultItem(IDC_BTN_HIDE, FALSE);
#endif
}
void CMMSServerDlg::OnQuit()
{
/* CFileFind fileFind;
static const TCHAR szFileToFind[] = _T("MMSControl.ini");
BOOL bResult = fileFind.FindFile(szFileToFind);
if(bResult)
{
char* pFileName = "MMSControl.ini";
CFile::Remove(pFileName);
}
*/
//////////////////////// Write The File
int nCount = m_lstMMS.GetItemCount();
CString str_path;
GetModuleFileName(NULL,str_path.GetBuffer(MAX_PATH),MAX_PATH);
str_path.ReleaseBuffer();
int index = str_path.ReverseFind('\\');
str_path= str_path.Left(index+1);
FILE *file=fopen(str_path+"MMSControl.ini","w+");
for( m_Item=0;m_Item< nCount ; m_Item++)
{
string channel = string (m_lstMMS.GetItemText(m_Item,0));
string address = string (m_lstMMS.GetItemText(m_Item,1));
string spIP = string (m_lstMMS.GetItemText(m_Item,5));
char buffer[20];
_itoa( m_Item, buffer, 10 );
fprintf(file,"%s%s%s\n","[CaptureServer",buffer,"]");
fprintf(file,"%s%s\n","channelName=",channel.data());
fprintf(file,"%s%s\n","MMSAddress=",address.data());
fprintf(file,"%s%s\n","State=","Stopped");
fprintf(file,"%s","spAddress=");
fprintf(file,"%s\n",spIP.data());
fprintf(file,"\n\n");
}
fclose(file);
SendMessage(WM_CLOSE);
}
void CMMSServerDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_MINIMIZE || nID == SC_CLOSE)
{
#ifndef _WIN32_WCE
#ifdef USING_NONMFC_TRAY // This is set in project settings
CSystemTray::MinimiseToTray(GetSafeHwnd());
#else
CSystemTray::MinimiseToTray(this);
#endif
m_TrayIcon.SetMenuDefaultItem(ID_MAXIMIZE, FALSE);
#endif
return;
}
CDialog::OnSysCommand(nID, lParam);
}
///////////////////////////////////////////////////////////////////////////////////////
void CMMSServerDlg::OnBtnAddMms()
{
CAddMMSDlg dlg(&m_MMSPool);
if(dlg.DoModal() == IDOK)
{
///////Read the File Add Get the data
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -