資源簡介
平時我們在做IM聊天之類的軟件的時候,一般都會使用Rich Edit控件來作為聊天編輯框和聊天記錄框的控件在Visual Studio 2008 SP1下擴展了些功能,比如解碼轉義字符、編碼轉義字符、自動檢測超鏈接、聊天記錄框的用戶內容和信息內容顏色和縮進分開顯示等等,加上原來的插入位圖表情、右鍵菜單、表情拾取器、RTF輸入輸出等等,可以符合基本的聊天控件要求了。見http://blog.csdn.net/akof1314/archive/2010/11/03/5983443.aspx文章
1.2版本更新修復內存泄露

代碼片段和文件信息
/*
?* 文件名:BmpContainer.cpp
?* 作用:位圖拾取器的容器面板
?*/
//?BmpContainer.cpp?:?實現文件
//
#include?“stdafx.h“
#include?“BmpContainer.h“
#include?“BmpPicker.h“
#include?“math.h“
//?CBmpContainer
#define?IDC_INNERBUTTON?10000
#define?IDC_ICONCONTAINER?10001
IMPLEMENT_DYNAMIC(CBmpContainer?CWnd)
CBmpContainer::CBmpContainer()
{
m_nRow=0;
m_nCol=0;
m_bClosed=FALSE;
}
CBmpContainer::~CBmpContainer()
{
CInnerButton*?pInnerButton;
for(int?i=0;i {
pInnerButton=m_InnerButtonArray.GetAt(i);
pInnerButton->SendMessage(WM_CLOSE00);
delete?pInnerButton;
}
}
BEGIN_MESSAGE_MAP(CBmpContainer?CWnd)
ON_WM_KILLFOCUS()
ON_WM_PAINT()
END_MESSAGE_MAP()
//?CBmpContainer?消息處理程序
BOOL?CBmpContainer::Create(POINT?ptCButton*?pParentButtonCArray?*pBitmapArrayBOOL?hasCreate)?
{
if(pBitmapArray->GetSize()<=0)return?FALSE;
m_pParentButton=pParentButton;
///根據每張圖片的大小創建IconContainer
//m_nCol=int(sqrt((double)pBitmapArray->GetSize()))+1;????//計算列數
m_nCol=10;
BITMAP?bm;
pBitmapArray->GetAt(0)->GetBitmap(&bm); //以圖片列表中的第0號圖片的大小為基準
m_nCellWidth=bm.bmWidth+4; //內部單元的寬度
m_nCellHeight=bm.bmHeight+4; //內部單元的高度
CRect?rect;
rect.left=pt.xrect.top=pt.y;
rect.right=pt.x+m_nCellWidth*m_nCol; //容器的寬度
if(pBitmapArray->GetSize()%m_nCol==0) //計算行數
{
m_nRow=pBitmapArray->GetSize()/m_nCol;
}
else
{
m_nRow=pBitmapArray->GetSize()/m_nCol+1;
}
//rect.bottom=pt.y+m_nCellHeight*m_nRow+2+46; ///容器的高度=(行數+2)*單元寬度要多兩個擴展功能按鈕的話,用這一行
rect.bottom=pt.y+m_nCellHeight*m_nRow+2;
rect.top=pt.y-m_nCellHeight*m_nRow-2;
rect.bottom=pt.y;
//pParentButton->GetParent()->ScreenToClient(&rect);
if?(hasCreate)
{
SetWindowPos(&wndToprect.leftrect.top00SWP_NOSIZE);
return?TRUE;
}
///創建容器
//CWnd::Create(NULL?NULL?WS_VISIBLE?|?WS_CHILD
//rectpParentButton->GetParent()IDC_ICONCONTAINER?NULL);
CWnd::CreateEx(WS_EX_LEFT|?WS_EX_TOOLWINDOWAfxRegisterWndClass(0)NULLWS_VISIBLE|WS_POPUPrectNULLNULL?);
///創建圖片張數+2個按鈕
for(int?i=0;i {
for(int?j=0;jGetSize();j++)
{
///計算按鈕的位置
CRect?innerrect;
innerrect.left=j*m_nCellWidth;
innerrect.top=i*m_nCellHeight;
innerrect.right=innerrect.left+m_nCellWidth;
innerrect.bottom=innerrect.top+m_nCellHeight;
innerrect.DeflateRect(22);
///新建按鈕
CInnerButton?*pInnerButton;
pInnerButton=new?CInnerButton;
pInnerButton->Create(NULLWS_CHILD?|WS_VISIBLE
innerrectthisIDC_INNERBUTTON+i*m_nCol+j);
///設置按鈕的圖標
pInnerButton->SetBitmap(pBitmapArray->GetAt(i*m_nCol+j));
pInnerButton->ShowWindow(SW_SHOW);
///記錄該按鈕的指針
m_InnerButtonArray.Add(pInnerButton);
}
}
////創建兩個擴展功能按鈕
/*
this->GetClientRect(&rect);
CInnerButton?*pInnerButton;
pInnerButton=new?CInnerButton;
rect.left=2;
rect.right-=2;
rect.top=m_nRow*m_nCellHeight+3;
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6500??2010-12-18?23:08??TestCoolChat\TestCoolChat\TestCoolChat.vcproj
?????文件???????2827??2010-10-22?00:16??TestCoolChat\TestCoolChat\ReadMe.txt
?????文件????????481??2010-10-22?00:16??TestCoolChat\TestCoolChat\TestCoolChat.h
?????文件???????1844??2011-05-13?23:52??TestCoolChat\TestCoolChat\TestCoolChat.cpp
?????文件???????1008??2010-10-28?10:25??TestCoolChat\TestCoolChat\TestCoolChatDlg.h
?????文件???????5102??2011-05-14?13:32??TestCoolChat\TestCoolChat\TestCoolChatDlg.cpp
?????文件???????1854??2010-10-22?00:16??TestCoolChat\TestCoolChat\stdafx.h
?????文件???????1030??2010-10-22?00:16??TestCoolChat\TestCoolChat\targetver.h
?????文件????????145??2010-10-22?00:16??TestCoolChat\TestCoolChat\stdafx.cpp
?????文件???????5748??2010-10-31?20:47??TestCoolChat\TestCoolChat\TestCoolChat.rc
?????文件????????368??2010-10-22?00:16??TestCoolChat\TestCoolChat\res\TestCoolChat.rc2
????.......?????67777??2007-11-28?16:21??TestCoolChat\TestCoolChat\res\TestCoolChat.ico
?????文件????????925??2011-05-14?02:15??TestCoolChat\TestCoolChat\BmpPicker.h
?????文件???????3758??2011-05-14?02:31??TestCoolChat\TestCoolChat\BmpPicker.cpp
?????文件????????727??2010-10-25?02:27??TestCoolChat\TestCoolChat\InnerButton.h
?????文件???????5227??2010-10-26?13:30??TestCoolChat\TestCoolChat\InnerButton.cpp
?????文件??????42366??2010-10-22?00:51??TestCoolChat\TestCoolChat\img\InnerButtonMark.bmp
?????文件???????2167??2008-08-20?13:00??TestCoolChat\TestCoolChat\img\shame_32.png
?????文件???????2627??2008-08-20?12:59??TestCoolChat\TestCoolChat\img\after_boom_32.png
?????文件???????2611??2008-08-20?12:59??TestCoolChat\TestCoolChat\img\angry_32.png
?????文件???????2575??2008-08-20?13:00??TestCoolChat\TestCoolChat\img\stop_32.png
?????文件???????2540??2008-08-20?13:00??TestCoolChat\TestCoolChat\img\sleep_32.png
?????文件???????2518??2008-08-20?12:59??TestCoolChat\TestCoolChat\img\music_32.png
?????文件???????2512??2008-08-20?12:59??TestCoolChat\TestCoolChat\img\love_32.png
?????文件???????2499??2008-08-20?12:59??TestCoolChat\TestCoolChat\img\adore_32.png
?????文件???????2495??2008-08-20?12:59??TestCoolChat\TestCoolChat\img\haha_32.png
?????文件???????2474??2008-08-20?13:00??TestCoolChat\TestCoolChat\img\what_32.png
?????文件???????2429??2008-08-20?12:59??TestCoolChat\TestCoolChat\img\faint_32.png
?????文件???????2376??2008-08-20?12:59??TestCoolChat\TestCoolChat\img\grimace_32.png
?????文件???????2370??2008-08-20?12:59??TestCoolChat\TestCoolChat\img\cool_32.png
............此處省略134個文件信息
評論
共有 條評論