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

📄 visconfdlg.cpp

📁 VIS H.323 Library V2.1 Release
💻 CPP
📖 第 1 页 / 共 3 页
字号:
/*
  VIS H.323 Video Conference System
      --Sample for VIS H.323 DLL Library 2.1 Release

  For more information,visit our homepage 
  
    [http://www.115studio.com]

  or mail to us for tech support and bug report

    [support@115studio.com]

  2000-2004 115Studio
  
  2004-04-05
*/
// VISConfDlg.cpp : implementation file
//

#include "stdafx.h"
#include "VISConf.h"
#include "VISConfDlg.h"
#include "MyEndPoint.h"
#include "config.h"
#include "SendUserInputDlg.h"
#include "SetupGeneralDlg.h"
#include "SetupNetworkDlg.h"
#include "SetupAudioDlg.h"
#include "SetupVideoDlg.h"
#include "PropertiesDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//The global pointer to CMyEndPoint object
CMyEndPoint * g_pep=NULL;
/////////////////////////////////////////////////////////////////////////////
// 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()

/////////////////////////////////////////////////////////////////////////////
// CVISConfDlg dialog

CVISConfDlg::CVISConfDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CVISConfDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CVISConfDlg)
	m_Address = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	//
	m_pep=new CMyEndPoint(*this);
	g_pep=m_pep;
}
CVISConfDlg::~CVISConfDlg()
{
	//
	delete m_pep;
}
void CVISConfDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CVISConfDlg)
	DDX_Control(pDX, IDC_ANSWER, m_btnAnswer);
	DDX_Control(pDX, IDC_HANG_UP, m_btnHangup);
	DDX_Control(pDX, IDC_MEMBERLIST, m_MemberList);
	DDX_Control(pDX, IDC_ADDRESS, m_comboAddress);
	DDX_Control(pDX, IDC_CALL, m_btnCall);
	DDX_CBString(pDX, IDC_ADDRESS, m_Address);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CVISConfDlg, CDialog)
	//{{AFX_MSG_MAP(CVISConfDlg)
	ON_WM_GETMINMAXINFO()
	ON_WM_SYSCOMMAND()
	ON_WM_QUERYDRAGICON()
	ON_WM_SIZE()
	ON_WM_CLOSE()
	ON_NOTIFY(LVN_ITEMCHANGED, IDC_MEMBERLIST, OnItemchangedMemberlist)
	ON_BN_CLICKED(IDC_ANSWER, OnAnswer)
	ON_BN_CLICKED(IDC_CALL, OnCall)
	ON_CBN_EDITCHANGE(IDC_ADDRESS, OnEditchangeAddress)
	ON_WM_TIMER()
	ON_COMMAND(ID_LOCAL_VIDEO, OnLocalVideo)
	ON_COMMAND(ID_REMOTE_VIDEO, OnRemoteVideo)
	ON_MESSAGE(UM_CHILD_CLOSE,OnChildClose)
	ON_COMMAND(ID_ABOUT, OnAbout)
	ON_NOTIFY(NM_RCLICK, IDC_MEMBERLIST, OnRclickMemberlist)
	ON_COMMAND(ID_HANG_UP, OnHangUp)
	ON_COMMAND(ID_HANG_UP_ALL, OnHangUpAll)
	ON_COMMAND(ID_EXIT, OnExit)
	ON_COMMAND(ID_SEND_USER_INPUT, OnSendUserInput)
	ON_COMMAND(ID_USER_INPUT, OnUserInput)
	ON_COMMAND(ID_VISIT_HOMEPAGE, OnVisitHomepage)
	ON_COMMAND(ID_ILS_CLIENT, OnIlsClient)
	ON_COMMAND(ID_GENERAL, OnGeneral)
	ON_CBN_SELCHANGE(IDC_ADDRESS, OnSelchangeAddress)
	ON_COMMAND(ID_NETWORK, OnNetwork)
	ON_COMMAND(ID_AUDIO, OnAudio)
	ON_COMMAND(ID_VIDEO, OnVideo)
	ON_COMMAND(ID_LOG_OUTPUT, OnLogOutput)
	ON_COMMAND(ID_PROPERTIES, OnProperties)
	ON_NOTIFY(NM_DBLCLK, IDC_MEMBERLIST, OnDblclkMemberlist)
	ON_COMMAND(ID_START_SEND_AUDIO, OnStartSendAudio)
	ON_COMMAND(ID_HOLD_SEND_AUDIO, OnHoldSendAudio)
	ON_COMMAND(ID_HOLD_RECEIVE_AUDIO, OnHoldReceiveAudio)
	ON_COMMAND(ID_START_SEND_VIDEO, OnStartSendVideo)
	ON_COMMAND(ID_HOLD_RECEIVE_VIDEO, OnHoldReceiveVideo)
	ON_COMMAND(ID_HOLD_SEND_VIDEO, OnHoldSendVideo)
	ON_COMMAND(ID_FLIPX_RECEIVE_VIDEO, OnFlipxReceiveVideo)
	ON_COMMAND(ID_FLIPX_SEND_VIDEO, OnFlipxSendVideo)
	ON_COMMAND(ID_FLIPY_RECEIVE_VIDEO, OnFlipyReceiveVideo)
	ON_COMMAND(ID_FLIPY_SEND_VIDEO, OnFlipySendVideo)
	ON_COMMAND(ID_CALL, OnCall)
	ON_BN_CLICKED(IDC_HANG_UP, OnHangUp)
	ON_COMMAND(ID_ANSWER, OnAnswer)
	ON_NOTIFY(HDN_ITEMCLICK, IDC_MEMBERLIST, OnItemclickMemberlist)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVISConfDlg message handlers

BOOL CVISConfDlg::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
	
	
	CConfig config;
	//Create and set the status bar
	int w[3]={150,250,-1};
	CRect rc;
    m_StatusBar.Create(WS_CHILD|WS_VISIBLE|CCS_BOTTOM|SBARS_SIZEGRIP,CRect(0,0,0,0), this, AFX_IDW_STATUS_BAR );	
	m_StatusBar.SetParts(3,w);
	m_StatusBar.SetText("Not in conference",0,0);
	m_StatusBar.SetText("MIC",1,SBT_NOBORDERS);	
	m_StatusBar.GetRect(1,&rc);
	rc.left=rc.left+30;
	//Insert a progress ctrl into status bar
	m_micVolume.Create(WS_CHILD|WS_VISIBLE|PBS_SMOOTH,rc,&m_StatusBar,1);

	//Set the member list
	m_MemberList.SetExtendedStyle(m_MemberList.GetExtendedStyle()|LVS_EX_FULLROWSELECT );
	m_MemberList.InsertColumn(0,"Member",LVCFMT_LEFT,150,0);
	m_MemberList.InsertColumn(1,"Status",LVCFMT_LEFT,150,0);
	m_MemberList.InsertColumn(2,"Duration",LVCFMT_LEFT,100,0);
	
	//Create a window to display user input
	m_UserInputDlg.Create(IDD_USER_INPUT_DLG,this);

	//Create the ILS client window
	m_ILSClientWnd.Create(IDD_ILS_CLIENT_WND,this);

	//Create the Log output window
	m_LogOutputDlg.m_writeLogToFile=config.GetBoolean(KEY_WRITE_LOG_TO_FILE,FALSE);
	m_LogOutputDlg.Create(IDD_LOG_OUTPUT_DLG,this);
	
	//Read the recent calls,and fill them into combobox
	CString OldKey;
	CString Call;
	CString Index;
	OldKey=config.GetDefaultKey();
	config.SetDefaultKey(SEC_RECENT_CALL);
	//fill the callee list
	for(int i=0;i<20;i++)
	{
		Index.Format("%d",i);
		
		Call=config.GetString(Index,"");
		if(Call.IsEmpty())
			break;
		m_comboAddress.InsertString(-1,Call);
			
	}
	config.SetDefaultKey(OldKey);

	//Initialize the VIS H.323 endpoint
	InitEndPoint();
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CVISConfDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CVISConfDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CVISConfDlg::OnAbout() 
{
	CAboutDlg dlgAbout;
	dlgAbout.DoModal();
}

void CVISConfDlg::OnSize(UINT nType, int cx, int cy) 
{	
	CDialog::OnSize(nType, cx, cy);
	
	//Resize the controls
	m_StatusBar.SendMessage(WM_SIZE,0,0);
	CRect rc;
	CRect rcStatus;
	m_StatusBar.GetWindowRect(rcStatus);

	m_MemberList.GetWindowRect(&rc);
	ScreenToClient(&rc);
	rc.right=cx-1;
	rc.bottom=cy-rcStatus.Height();
	m_MemberList.SetWindowPos(NULL,0,0,rc.Width(),rc.Height(),SWP_NOMOVE);

}


void CVISConfDlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
	//Limit the min track size of main window
	lpMMI->ptMinTrackSize.x=440;
	lpMMI->ptMinTrackSize.y=250;

	CDialog::OnGetMinMaxInfo(lpMMI);
}

void CVISConfDlg::OnClose() 
{
	//Main window to be closed

	//Save the recent calls into registry
	CConfig config;
	CString OldKey;
	CString Call;
	CString Index;
	OldKey=config.GetDefaultKey();
	config.SetDefaultKey(SEC_RECENT_CALL);
	for(int i=0;i<m_comboAddress.GetCount();i++)
	{
		Index.Format("%d",i);
		m_comboAddress.GetLBText(i,Call);
		
		config.SetString(Index,Call);
		
	}				
	config.SetDefaultKey(OldKey);

	//Hang up all connections
	m_pep->HangUp();
	//Wait until all connection has actually been cleared
	MSG msg;
	while(m_pep->GetConnectionCount()>0)
	{
		PeekMessage(&msg,NULL,0,0,PM_REMOVE);
	}	
	
	//Stop audio and video
	m_pep->StopLocalAudio();
	m_pep->StopLocalVideo();
	m_pep->StopRemoteAudio();
	m_pep->StopRemoteVideo();

	//Try unregistering with GK
	char name[256]="";
	m_pep->GetGateKeeperName(name,256);
	if(m_pep->UnuseGatekeeper())
	{				
		Output("Unregistered with gatekeeper \"%s\"",name);	
	}

	config.SetBoolean(KEY_WRITE_LOG_TO_FILE,m_LogOutputDlg.m_writeLogToFile);
	EndDialog(0);
	//CDialog::OnClose();
}

void CVISConfDlg::UpdateConnStatus(DWORD connID)
{
	LVFINDINFO fi;
	fi.flags=LVFI_PARAM;
	fi.lParam=connID;
	int index=m_MemberList.FindItem(&fi);
	if(index>=0)
	{
		//Item found
		//Get and translate the connection status
		enum ConnStatus status=m_pep->GetConnectionStatus(connID);
		CString txt;

		switch(status)
		{
		case ConnNotExist:
			txt="N/A";
			break;
		case MakingCall:
			txt="Making call";
			break;
		case IncomingCallWait:
			txt="Incoming call wait";
			break;
		case WaitingForAnswer:
			txt="Waiting for answer";
			break;
		case ConnEstablished:
			txt="Talking";
			break;
		case HangingUp:
			txt="Hanging up";
			break;
		}
		m_MemberList.SetItemText(index,1,txt);
	}
}

void CVISConfDlg::OnItemchangedMemberlist(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	
	UpdateButtons();
	*pResult = 0;
}

void CVISConfDlg::UpdateButtons()
{
    int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
	int count=m_MemberList.GetItemCount();
	DWORD connID=0;
	enum ConnStatus status=ConnNotExist;
	CMenu *menu=GetMenu();
	if(index>=0)
	{
		//Item selected

		//Update the buttons' state
		connID=m_MemberList.GetItemData(index);
		status=m_pep->GetConnectionStatus(connID);
		
		m_btnAnswer.EnableWindow(status==IncomingCallWait);
		m_btnHangup.EnableWindow(status!=ConnNotExist);
		
		
	}
	else
	{
		//No item selected
		
		m_btnAnswer.EnableWindow(FALSE);
		m_btnHangup.EnableWindow(FALSE);
	}

	if(menu)
	{			
		//Update the main menu
		menu->EnableMenuItem(ID_HANG_UP,MF_BYCOMMAND|(m_btnHangup.IsWindowEnabled()?MF_ENABLED:MF_GRAYED));
		menu->EnableMenuItem(ID_ANSWER,MF_BYCOMMAND|(m_btnAnswer.IsWindowEnabled()?MF_ENABLED:MF_GRAYED));
		menu->EnableMenuItem(ID_HANG_UP_ALL,MF_BYCOMMAND|(count>0?MF_ENABLED:MF_GRAYED));
		menu->EnableMenuItem(ID_PROPERTIES,MF_BYCOMMAND|(index>=0?MF_ENABLED:MF_GRAYED));
		menu->EnableMenuItem(ID_SEND_USER_INPUT,MF_BYCOMMAND|(index>=0?MF_ENABLED:MF_GRAYED));
	
	}
	
	//Update the status bar
	if(count==0)
	{
		m_StatusBar.SetText("Not in conference",0,0);
	}
	else
	{
		CString s;
		s.Format("%d member(s) in conference",count);
		m_StatusBar.SetText(s,0,0);
	}

}


void CVISConfDlg::OnAnswer() 
{
	int index=m_MemberList.GetNextItem(-1,LVNI_SELECTED);
	//First check whether item selected
	if(index>=0)
	{
		DWORD connID=m_MemberList.GetItemData(index);
		enum ConnStatus status=m_pep->GetConnectionStatus(connID);
		char name[256]="";
		m_pep->GetRemotePartyName(connID,name,256);
		//Then check the connection status
		//AnswerCall only when status==IncomingCallWait
		if(status==IncomingCallWait)

⌨️ 快捷键说明

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