sSent = 0;
m_Video_x=7;
m_Video_y=30;
//make the title bar region
POINT pt[4];
pt[0].x=25; pt[0].y=5;
pt[1].x=162; pt[1].y=5;
pt[2].x=144; pt[2].y=23;
pt[3].x=7; pt[3].y=23;
m_hTitleRgn = CreatePolygonRgn(pt,4,ALTERNATE);
pt[0].x =m_Video_x; pt[0].y =m_Video_y;
pt[1].x=m_Video_x+176; pt[1].y =m_Video_y;
pt[2].x=m_Video_x+176; pt[2].y =m_Video_y+144;
pt[3].x =m_Video_x; pt[3].y =m_Video_y+144;
m_hVideoRgn = CreatePolygonRgn(pt,4,ALTERNATE);
pt[0].x =10; pt[0].y =179;
pt[1].x=249; pt[1].y =179;
pt[2].x=249; pt[2].y =198;
pt[3].x =10; pt[3].y =198;
m_hMesgRgn = CreatePolygonRgn(pt,4,ALTERNATE);
// Setup the parent for differnt datagram sockets
dcontrol.SetParent(this);
dcontrol.CreateSocket(PORT_CONTROL,TYPE_CONTROL);
m_VUnComped =NULL;
m_VComped =NULL;
m_AUnComped =NULL;
m_AComped =NULL;
m_vidcap=NULL;
m_bmpinfo= NULL;
hdib = NULL;
// setup Video Codec
m_VideoCodec.SetCodecType (MS_MPEG4V3);
m_VideoCodec.SetParent (this);
m_RemoteDlg.Create (IDD_REMOTE,this);
m_RemoteDlg.SetParent (this);
m_RemoteDlg.ShowWindow (SW_HIDE);
m_AddrBook = NULL;
m_TextChatDlg.Create (IDD_TEXTCHAT,this);
m_TextChatDlg.SetParent (this);
m_TextChatDlg.ShowWindow (SW_HIDE);
m_AudioPlay=new CAudioPlay(this);
m_AudioPlay->CreateThread();
if(m_AudioPlay)
{
m_AudioPlay->PostThreadMessage(WM_PLAYSOUND_STARTPLAYING,0,0);
}
m_AudioRec=new CAudioRec(this);
m_AudioRec->CreateThread();
m_State=STATE_IDLE;
SetTimer(1,2000,NULL);
return TRUE; // return TRUE unless you set the focus to a control
}
void CGraghDialogDlg::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 CGraghDialogDlg::OnPaint()
{
CPaintDC dc(this);
if (IsIconic())
{
// 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
{
DrawTitleBar(m_hdc);
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CGraghDialogDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
BOOL CGraghDialogDlg::InitCap()
{
TRACE("CGraghDialogDlg::InitCap\n");
if(m_bVidInit) return TRUE;
m_vidcap=new VideoCapture;
m_vidcap->SetDialog(this);
if(m_vidcap->Initialize()) // success
{
m_bmpinfo=&(m_vidcap->m_bmpinfo);
m_bVidInit =TRUE;
}else
{
if(m_bmpinfo) delete m_bmpinfo;
m_bVidInit = FALSE;
m_bmpinfo=new BITMAPINFO;
m_bmpinfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
m_bmpinfo->bmiHeader.biWidth=IMAGE_WIDTH;
m_bmpinfo->bmiHeader.biHeight=IMAGE_HEIGHT;
m_bmpinfo->bmiHeader.biPlanes=1;
m_bmpinfo->bmiHeader.biBitCount=24;
m_bmpinfo->bmiHeader.biCompression=0;
m_bmpinfo->bmiHeader.biSizeImage=IMAGE_WIDTH*IMAGE_HEIGHT*3;
m_bmpinfo->bmiHeader.biXPelsPerMeter=0;
m_bmpinfo->bmiHeader.biYPelsPerMeter=0;
m_bmpinfo->bmiHeader.biClrUsed=0;
m_bmpinfo->bmiHeader.biClrImportant=0;
}
return m_bVidInit;
}
void CGraghDialogDlg::DestroyCap()
{
TRACE("CGraghDialogDlg::DestroyCap\n");
if(m_vidcap)
{
m_vidcap->StopCapture ();
m_vidcap->Destroy ();
delete m_vidcap;
m_vidcap=NULL;
}
if(m_bmpinfo )
{
if(!m_bVidInit) delete m_bmpinfo;
m_bmpinfo=NULL;
}