⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 supervisesystemdlg.cpp

📁 此代码使用bmp图作为主要界面
💻 CPP
字号:
// SuperViseSystemDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SuperViseSystem.h"
#include "SuperViseSystemDlg.h"
#include "ShowFirstRight.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

int CSuperViseSystemDlg::bright = 128;
int CSuperViseSystemDlg::contrast = 64;
int CSuperViseSystemDlg::sat = 64;
int CSuperViseSystemDlg::hue = 0;

#define MAX_CHANNELS 64
extern HANDLE ChannelHandle[64];
/////////////////////////////////////////////////////////////////////////////
// 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()

/////////////////////////////////////////////////////////////////////////////
// CSuperViseSystemDlg dialog

CSuperViseSystemDlg::CSuperViseSystemDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSuperViseSystemDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSuperViseSystemDlg)
		// 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);
}

void CSuperViseSystemDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSuperViseSystemDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSuperViseSystemDlg, CDialog)
	//{{AFX_MSG_MAP(CSuperViseSystemDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_MESSAGE(WM_MYMESSAGE,OnMyMessage)
	//}}AFX_MSG_MAP
	ON_MESSAGE(WM_CHANGE_RHT_PANEL,OnChangeRightPanel)
	ON_MESSAGE(WM_SECOND_RHT,OnChangeSecondRight)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSuperViseSystemDlg message handlers

BOOL CSuperViseSystemDlg::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
	
	CreateControl();

	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CSuperViseSystemDlg::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 CSuperViseSystemDlg::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 CSuperViseSystemDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CSuperViseSystemDlg::CreateControl()
{
//---副右边
	CRect rect;

	rect.left =790;
	rect.top = 44;
	rect.right = 1023;
	rect.bottom = 768;
	
	m_secondright.CreateWnd(WS_CHILD| WS_VISIBLE, rect, this, IDC_IW_INRIGHT);	
	HBITMAP *bpinright = (HBITMAP *)LoadImage(AfxGetInstanceHandle(),
	"res\\右边.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
	m_secondright.SetImage(bpinright);

//---右边
	rect.left = 790;
	rect.top = 45;
	rect.right = 1023;
	rect.bottom = 768;
	
	m_firstright.CreateWnd(WS_CHILD| WS_VISIBLE, rect, this, IDC_IW_TEST);	
	HBITMAP *bp2 = (HBITMAP *)LoadImage(AfxGetInstanceHandle(),
	"res\\主右边.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);	
	//因为m_iwTest是CCSowMap类的对象,CSowMap类又继承于CCreateMap类,
	m_firstright.SetImage(bp2);

//---副左边
	rect.left =0;
	rect.top = 44;
	rect.right = 45;
	rect.bottom = 645;
	
	m_secondleft.CreateWnd(WS_CHILD| WS_VISIBLE, rect, this, IDC_IW_INLEFT);
	
	HBITMAP *bpinleft = (HBITMAP *)LoadImage(AfxGetInstanceHandle(),
		"res\\副左边.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
	
	m_secondleft.SetImage(bpinleft);

//---左边
	rect.left =0;
	rect.top = 45;
	rect.right = 45;
	rect.bottom = 645;
	
	m_firstLeft.CreateWnd(WS_CHILD| WS_VISIBLE, rect, this, IDC_IW_LEFT);
	
	HBITMAP *bpleft = (HBITMAP *)LoadImage(AfxGetInstanceHandle(),
		"res\\主左边.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
	
	m_firstLeft.SetImage(bpleft);
	
//---上边
	rect.left = 0;
	rect.top = 0;
	rect.right = 1023;
	rect.bottom = 45;
	
	m_iwTop.Create(WS_CHILD| WS_VISIBLE, rect, this, IDC_IW_TOP);
	
	HBITMAP *m_bitmap1 = (HBITMAP *)LoadImage(AfxGetInstanceHandle(),
	"res\\主上边.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
	m_iwTop.SetImage(m_bitmap1);
	//---下边
	rect.left =0;
	rect.top = 645;
	rect.right = 790;
	rect.bottom = 768;
	m_iwBottom.Create(WS_CHILD| WS_VISIBLE, rect, this, IDC_IW_BOTTOM);
//---
	rect.left =40;
	rect.top = 45;
	rect.right = 790;
	rect.bottom = 645;
	
	m_iwCenter.Create(WS_CHILD| WS_VISIBLE, rect, this, IDC_IW_CENTER);	

	m_firstLeft.ShowWindow(SW_SHOW);
	m_secondleft.ShowWindow(SW_HIDE);
	
	m_firstright.ShowWindow(SW_SHOW);
	m_secondright.ShowWindow(SW_HIDE);
}
//---------------------------
void CSuperViseSystemDlg::OnChangeRightPanel(int PanelID)
{	
	switch(PanelID)
	{
	case 0 :
		{
			//左边--
			m_firstLeft.ShowWindow(SW_SHOW);
			m_secondleft.ShowWindow(SW_HIDE);
			//右边--	
			m_firstright.ShowWindow(SW_SHOW);
			m_secondright.ShowWindow(SW_HIDE);	
			m_iwCenter.ChangeControl();
		}
		break;
	case 1 :
		{
			//左边--	
			m_firstLeft.ShowWindow(SW_HIDE);
			m_secondleft.ShowWindow(SW_SHOW);
			//右边--
			m_firstright.ShowWindow(SW_HIDE);
			m_secondright.ShowWindow(SW_SHOW);
		   m_iwCenter.ChangeControl();
		}
		break;
	case 2:
		{
			AfxMessageBox("电子地图");
		}
		break;
	case 3:
		{
			AfxMessageBox("视频回放");
		}
		break;
	case 4:
		{
			OnSystemSettings();
		}
		break;
	} 
	
}

//------------接受消息来自CReateMap发下来的按钮ID号的消息!
void CSuperViseSystemDlg::OnMyMessage(int BT_IDC)
{

	switch(BT_IDC)
	{

//---4个规则的矩形屏幕分割
	case IDC_BW_ZERO:
		m_iwCenter.m_InumberCount = 0;
    	m_iwCenter.SetRowsCols(1,1,1);
		
		m_iwCenter.m_bDisplay = true;
		m_iwCenter.m_choosplay = true;
		m_iwCenter.m_bClicbutton = true;

		m_iwCenter.m_bDisplay1 = FALSE;
		m_iwCenter.Invalidate(FALSE);
		break;
	case IDC_BW_ONE:
		m_iwCenter.m_InumberCount = 1;
	    m_iwCenter.SetRowsCols(2,2,4);

		m_iwCenter.m_bDisplay = true;
		m_iwCenter.m_choosplay = true;
		m_iwCenter.m_bClicbutton = true;

		m_iwCenter.m_bDisplay1 = FALSE;
		m_iwCenter.Invalidate(FALSE);
		break;
	case IDC_BW_TWO:
		m_iwCenter.m_InumberCount = 2;
	    m_iwCenter.SetRowsCols(3,3,9);

		m_iwCenter.m_bDisplay = true;
		m_iwCenter.m_choosplay = true;
		m_iwCenter.m_bClicbutton = true;

		m_iwCenter.m_bDisplay1 = FALSE;
		m_iwCenter.Invalidate(FALSE);
		break;
	case IDC_BW_FOUR:
		m_iwCenter.m_InumberCount = 4;
        m_iwCenter.SetRowsCols(4,4,16);
		m_iwCenter.m_bDisplay = true;
		m_iwCenter.m_choosplay = true;
		m_iwCenter.m_bClicbutton = true;
		m_iwCenter.m_bDisplay1 = FALSE;
		m_iwCenter.Invalidate(FALSE);
		break;
//---5个不规则的矩形屏幕分割
	case IDC_BW_FIVE:

		m_iwCenter.m_InumberCount = 5;
		m_iwCenter.m_bDisplay = FALSE;
		m_iwCenter.m_choosplay = false;
		m_iwCenter.m_bDisplay1 = true;
		m_iwCenter.m_bClicbutton = false;


		m_iwCenter.m_bFirst = true;
	    m_iwCenter.m_bSecond = FALSE;
	    m_iwCenter.m_bThird = FALSE;
	    m_iwCenter.m_bFouth = FALSE;
		m_iwCenter.m_bFifth = FALSE;
	    	    

		m_iwCenter.Invalidate(FALSE);
		break;
		//-----
	case IDC_BW_SIX:
		m_iwCenter.m_InumberCount = 6;
		m_iwCenter.m_bDisplay = FALSE;
		m_iwCenter.m_bDisplay1 = true;
		m_iwCenter.m_choosplay = false;
		m_iwCenter.m_bClicbutton = false;
		
		m_iwCenter.m_bFirst = FALSE;
	    m_iwCenter.m_bSecond = true;
	    m_iwCenter.m_bThird = FALSE;
	    m_iwCenter.m_bFouth = FALSE;
	    m_iwCenter.m_bFifth = FALSE;

		m_iwCenter.Invalidate(FALSE);
		break;
		//-----------
	case IDC_BW_EIGHT:
		m_iwCenter.m_InumberCount = 8;
		m_iwCenter.m_bDisplay = FALSE;
		m_iwCenter.m_bDisplay1 = true;
		m_iwCenter.m_choosplay = false;
		m_iwCenter.m_bClicbutton = false;
		
		m_iwCenter.m_bFirst = FALSE;
	    m_iwCenter.m_bSecond = FALSE;
	    m_iwCenter.m_bThird = true;
	    m_iwCenter.m_bFouth = FALSE;
	    m_iwCenter.m_bFifth = FALSE;

		m_iwCenter.Invalidate(FALSE);
		break;
		//-----------
	case IDC_BW_NINE:
		m_iwCenter.m_InumberCount = 9;
		m_iwCenter.m_bDisplay = FALSE;
		m_iwCenter.m_bDisplay1 = true;
		m_iwCenter.m_choosplay = false;
		m_iwCenter.m_bClicbutton = false;
	
		m_iwCenter.m_bFirst = FALSE;
	    m_iwCenter.m_bSecond = FALSE;
	    m_iwCenter.m_bThird = FALSE;
	    m_iwCenter.m_bFouth = true;
	    m_iwCenter.m_bFifth = FALSE;

		m_iwCenter.Invalidate(FALSE);
		break;
		//-----------
	case IDC_BW_TEN:
		m_iwCenter.m_InumberCount = 10;
		m_iwCenter.m_bDisplay = FALSE;
		m_iwCenter.m_bDisplay1 = true;
		m_iwCenter.m_choosplay = false;
		m_iwCenter.m_bClicbutton = false;

		m_iwCenter.m_bFirst = FALSE;
	    m_iwCenter.m_bSecond = FALSE;
	    m_iwCenter.m_bThird = FALSE;
	    m_iwCenter.m_bFouth = FALSE;
	    m_iwCenter.m_bFifth = true;

	    m_iwCenter.Invalidate(FALSE);
		break;
	}
}

void CSuperViseSystemDlg::OnSystemSettings()
{
	CSystemSetting m_setting;
	
	USHORT Format1[] = {24, 240, _OSD_YEAR2, '-',_OSD_MONTH2,'-',_OSD_DAY,'-', 
		_OSD_HOUR24, ':', _OSD_MINUTE,':', _OSD_SECOND, '\0'};
	USHORT Format2[] = { 0, 0, 0x20, 0};

	PictureFormat_t encodeType,subEncodeType; 
	int i=0;


	if(m_setting.DoModal() == IDOK)
	{
//---设置视频的位置!
		if (m_setting.m_iX >=0 && m_setting.m_iY >=0)
			SetInputVideoPosition(ChannelHandle[0],m_setting.m_iX,m_setting.m_iY);
//---显示时间并且设置时间的存在的状态!
		switch(m_setting.m_iEncodeType)
		{
		case 0:
			encodeType = ENC_CIF_FORMAT;
			break;
		case 1:
			encodeType = ENC_4CIF_FORMAT;
			break;
		case 2:
			encodeType = ENC_QCIF_FORMAT;
			break;
		case 3:
			encodeType = ENC_2CIF_FORMAT;
			break;
		case 4:
			encodeType = ENC_DCIF_FORMAT;
			break;
		default:
			encodeType = ENC_CIF_FORMAT;
			break;
		}
		for(i = 0; i < GetTotalDSPs(); i++)
		{
			SetEncoderPictureFormat(ChannelHandle[i],encodeType);
		}
		//---控制打开与关闭时间器
		if(m_setting.m_iopen == 0)
		{	
			for(i = 0; i < GetTotalDSPs(); i++)
			{	
				SetOsdDisplayMode(ChannelHandle[i], 255, TRUE, 1, Format1, Format2);
				SetOsd(ChannelHandle[i], TRUE);
			}
		}
		else 
		{
			for(i = 0; i < GetTotalDSPs(); i++)
			{
				SetOsd(ChannelHandle[i], FALSE);
			}
		}
	}
}
//---
void CSuperViseSystemDlg::OnChangeSecondRight(int num)
{
	{	
		//-----------焦距
		switch(num) 
		{
		case 0:
			//	SetVideoPara(ChannelHandle[num], bright, contrast, sat, hue);
			break;
		case 1:
			//	SetVideoPara(ChannelHandle[num], bright, contrast, sat, hue);
			break;
			//-----------远近			
		case 2:
			break;
		case 3:	
			break;
			//-----------光圈
		case 4:
			{
				int i;
				
				if((i = m_iwCenter.m_iChangeCount) >= 0)
				{		
					bright = bright + 10;
					SetVideoPara(ChannelHandle[i], bright, contrast, sat, hue);
				}
				break;
			}
		case 5:
			{
				int i;
				if((i = m_iwCenter.m_iChangeCount) >= 0)
				{
					bright = bright - 10;
					SetVideoPara(ChannelHandle[i], bright, contrast, sat, hue);
				}
				break;
			}
			//--------------	
		default:
			break;
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -