MFC视频聊天


一个MFC编写的多人视频聊天程序源代码,可以供相关同学初步学习MFC
资源截图
代码片段和文件信息
// AdvButton.cpp : implementation file
//

#include “stdafx.h“
#include “instantmessaging.h“
#include “AdvButton.h“

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

#define NORMAL 1 /// 处于正常状态
#define HOVER 2 /// 处于焦点状态
#define DOWN 3 /// 处于按下状态
#define DISABLE 4 /// 处于无效状态

#define TRANSPARENTCOLOR RGB( 255 0 255 ) /// 定义透明位图的RGB值

#pragma comment( lib “C:\Program Files\Microsoft Visual Studio\VC98\Lib\MSIMG32.LIB“ )

/////////////////////////////////////////////////////////////////////////////
// CAdvButton

static BOOL bTrackLeave = FALSE;

CAdvButton::CAdvButton()
{
m_nState = NORMAL;
}

CAdvButton::~CAdvButton()
{
DeleteBmp();
}


BEGIN_MESSAGE_MAP(CAdvButton CButton)
//{{AFX_MSG_MAP(CAdvButton)
ON_WM_MOUSEMOVE()
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
ON_MESSAGE( WM_MOUSELEAVE onmouseleave )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAdvButton message handlers

void CAdvButton::PreSubclassWindow() 
{
Modifystyle( 0 BS_OWNERDRAW );
CButton::PreSubclassWindow();

m_pToolTipCtrl.Create( this TTS_ALWAYSTIP );
m_pToolTipCtrl.SetDelayTime( 100 );
CString strText;
GetWindowText( strText );
m_pToolTipCtrl.AddTool( this strText ); 
}

void CAdvButton::onmousemove(UINT nFlags CPoint point) 
{
if( !bTrackLeave )
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof( TRACKMOUSEEVENT );
tme.hwndTrack = m_hWnd;
tme.dwFlags = TME_LEAVE;
::_TrackMouseEvent( &tme );
bTrackLeave = TRUE;
m_nState = HOVER;
Invalidate();
}
CButton::onmousemove(nFlags point);
}

void CAdvButton::onmouseleave( WPARAM wParam LPARAM lParam )
{
bTrackLeave = FALSE;
m_nState = NORMAL;
Invalidate();
}

void CAdvButton::OnLButtonDown(UINT nFlags CPoint point) 
{
m_nState = DOWN;
Invalidate();
CButton::OnLButtonDown(nFlags point);
}

void CAdvButton::OnLButtonUp(UINT nFlags CPoint point) 
{
m_nState = HOVER;
Invalidate();
CButton::OnLButtonUp(nFlags point);
}

void CAdvButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
if( lpDrawItemStruct->itemState & ODS_DISABLED )
{
m_nState = DISABLE;
}

switch( m_nState )
{
case NORMAL:
DrawNORMAL();
break;
case HOVER:
DrawHOVER();
break;
case DOWN:
DrawDOWN();
break;
case DISABLE:
DrawDISABLE();
break;
default:
break;
}
}

void CAdvButton::DrawNORMAL()
{
CDC *pDC = GetDC();
BITMAP bmp;
if( !m_bmpNormal.m_hobject )
{
return;
}
m_bmpNormal.GetBitmap( &bmp );
SetWindowPos( NULL 0 0 bmp.bmWidth bmp.bmHeight SWP_NOMOVE | SWP_NOZORDER);
CDC dcMem;
dcMem.CreateCompatibleDC( pDC );
CBitmap *pOldBmp;
pOldBmp = dcMem.Selectobject( &m_bmpNormal );
pOldBmp->Deleteobject();

TransparentBlt( pDC->m_hDC 0 0 bmp.bmWidth bmp.bmHeight 
dcMem.m_hDC 0 0 bmp

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       5799  2011-02-08 00:23  InstantMessagingAdvButton.cpp

     文件       2098  2011-02-08 00:15  InstantMessagingAdvButton.h

     文件        708  2011-01-30 11:51  InstantMessagingAdvComboBox.cpp

     文件       1176  2011-01-30 11:51  InstantMessagingAdvComboBox.h

     文件      10660  2011-02-27 17:57  InstantMessagingCanvasStatic.cpp

     文件       2546  2011-02-20 18:32  InstantMessagingCanvasStatic.h

     文件       5798  2011-02-28 21:39  InstantMessagingChatDlg.cpp

     文件       1979  2011-02-14 10:17  InstantMessagingChatDlg.h

     文件      13135  2011-02-27 16:22  InstantMessagingChatRoomClientDlg.cpp

     文件       2582  2011-02-27 16:20  InstantMessagingChatRoomClientDlg.h

     文件       1100  2011-02-09 23:46  InstantMessagingChatRoomClientSocket.cpp

     文件       1477  2011-02-09 23:45  InstantMessagingChatRoomClientSocket.h

     文件      17636  2011-02-27 15:25  InstantMessagingChatRoomServerDlg.cpp

     文件       2698  2011-02-27 15:14  InstantMessagingChatRoomServerDlg.h

     文件       1100  2011-02-09 22:31  InstantMessagingChatRoomServerSocket.cpp

     文件       1477  2011-02-09 22:29  InstantMessagingChatRoomServerSocket.h

     文件        785  2011-02-25 23:22  InstantMessagingDebug.cpp

     文件        567  2011-02-23 23:32  InstantMessagingDebug.h

     文件       3187  2011-05-12 16:34  InstantMessagingDialogSetting.cpp

     文件       1619  2011-02-15 21:27  InstantMessagingDialogSetting.h

     文件       2098  2011-02-12 19:09  InstantMessagingfont.cpp

     文件       1461  2011-02-12 19:09  InstantMessagingfont.h

     文件       9886  2011-03-02 15:08  InstantMessagingFriendsListCtrl.cpp

     文件       2153  2011-02-28 15:38  InstantMessagingFriendsListCtrl.h

     文件       9233  2011-03-04 22:27  InstantMessagingGlobal.h

     文件     398972  2011-02-28 21:21  InstantMessagingInstantMessaging.aps

     文件      13188  2011-05-13 08:25  InstantMessagingInstantMessaging.clw

     文件       2209  2011-02-28 16:42  InstantMessagingInstantMessaging.cpp

     文件      24210  2011-03-02 15:13  InstantMessagingInstantMessaging.dsp

     文件        584  2011-02-12 19:09  InstantMessagingInstantMessaging.dsw

............此处省略262个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)