📄 ~rightlr.~cpp
字号:
// RightLR.cpp : implementation file
//
#include "stdafx.h"
#include "..\dvrmanager.h"
#include "RightLR.h"
#include "../utils/common.h"
#include "../video/video_channel.h"
#include "../utils/update_data.h"
#include "rightlogin.h"
#include "reg.h"
#include "../utils/custom_msgs.h"
LPCTSTR rvLRDrive = _T("LRDrive");
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRightLR dialog
CRightLR* CRightLR::self = NULL;
CRightLR* CRightLR::the_one() {return self;}
CRightLR::CRightLR(CWnd* pParent /*=NULL*/)
: baseclass(CRightLR::IDD, pParent), vc(NULL)
{
//{{AFX_DATA_INIT(CRightLR)
m_drive = 0;
m_rec = FALSE;
m_ctrl = _T("");
m_str_chnl_info = _T("");
//}}AFX_DATA_INIT
self = this;
}
CRightLR::~CRightLR()
{
}
void CRightLR::DoDataExchange(CDataExchange* pDX)
{
vc = video_channel::current_sel();
if( !pDX->m_bSaveAndValidate )
{
TCHAR drive = CRightLogin::the_one()->SendMessage(WM_GET_LOCAL_REC, vc->index());
m_rec = IS_RECORDING(drive);
if( m_rec )
{
for( int i=0; i<m_cbdrives.GetCount(); i++ )
{
int idx = m_cbdrives.GetItemData(i);
if( idx + _T('A') == drive )
m_drive = i;
}
}
}
baseclass::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRightLR)
DDX_Control(pDX, ID_7, m_7);
DDX_Control(pDX, IDLB_CHNL_INFO, m_chnl_info);
DDX_Control(pDX, ID_2, m_4);
DDX_Control(pDX, ID_S, m_s);
DDX_Control(pDX, IDCK_REC, m_ck_rec);
DDX_Control(pDX, ID_6, m_6);
DDX_Control(pDX, ID_3, m_3);
DDX_Control(pDX, IDLB_CONTROL, m_2);
DDX_Control(pDX, ID_TITLE, m_title);
DDX_Control(pDX, ID_1, m_1);
DDX_Control(pDX, IDCB_DRIVES, m_cbdrives);
DDX_Control(pDX, ID_DRIVE_INFO, m_di);
DDX_CBIndex(pDX, IDCB_DRIVES, m_drive);
DDX_Check(pDX, IDCK_REC, m_rec);
DDX_Text(pDX, IDLB_CONTROL, m_ctrl);
DDX_Text(pDX, IDLB_CHNL_INFO, m_str_chnl_info);
//}}AFX_DATA_MAP
if( !IsWindow(m_ck_rec) )
return;
bool b = true;
if( !vc )
b = false;
else
b = vc->is_video_opened();
m_ck_rec.EnableWindow(b);
m_cbdrives.EnableWindow(!m_rec && b);
}
BEGIN_MESSAGE_MAP(CRightLR, baseclass)
//{{AFX_MSG_MAP(CRightLR)
ON_CBN_SELCHANGE(IDCB_DRIVES, OnSelchangeDrives)
ON_BN_CLICKED(IDCK_REC, OnRec)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_UPDATE_DATA, on_update_data)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRightLR message handlers
void CRightLR::get_drivers()
{
DWORD ld = GetLogicalDrives();
if( !ld )
return;
m_cbdrives.ResetContent();
CString str;
for( int i=2; i<32; i++ )
{
DWORD pow2 = 1<<i;
if( ld & pow2 )
{
str.Format(_T("%c:"), i+_T('A'));
if( GetDriveType(str) != DRIVE_FIXED )
continue;
int idx = m_cbdrives.AddString(str);
m_cbdrives.SetItemData(idx, i);
}
}
}
BOOL CRightLR::OnInitDialog()
{
baseclass::OnInitDialog();
get_drivers();
init_label(m_1);
init_label(m_2);
init_label(m_3);
init_label(m_4);
init_label(m_7);
init_label(m_chnl_info);
init_title(m_title);
m_drive = read_dword(rkSettings, rvLRDrive);
UpdateData(FALSE);
OnSelchangeDrives();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
static void add_backslash(CString& str)
{
if( str.Right(1) != _T("\\") )
str+= _T("\\");
}
void CRightLR::OnSelchangeDrives()
{
UpdateData();
CString str;
m_cbdrives.GetWindowText(str);
if( str.IsEmpty() )
return;
m_di.SetDriveLetter(str);
write_dword(rkSettings, rvLRDrive, m_drive);
add_backslash(str);
}
void CRightLR::OnRec()
{
vc = video_channel::current_sel();
if( !vc )
return;
if( !vc->is_video_opened() )
return;
UpdateData();
int idx = m_cbdrives.GetCurSel();
if( idx == -1 )
return;
idx = m_cbdrives.GetItemData(idx);
WPARAM w = m_rec;
w |= (idx + _T('A'))<<16;
CRightLogin::the_one()->PostMessage(WM_LOCAL_REC, w, (LPARAM)vc);
}
LRESULT CRightLR::on_update_data(WPARAM w, LPARAM l)
{
vc = (video_channel*)l;
m_chnl_info.SetText(m_str_chnl_info);
m_2.SetText(m_ctrl);
UpdateData(w);
return 0;
}
void CRightLR::on_join()
{
UpdateData();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -