Use dazzle colour component interface library to provide the chat bubbles, complete code has been uploaded to CSDN, waiting for audit.
//contains dazzle colour interface library file
# pragma comment (lib, "XCGUI. Lib")
# include "xcgui. H"
The class CEditRecv
{
Public:
Mr HELE m_hEdit;
USHORT m_style1;
HIMAGE m_hImageAvatar;
HIMAGE m_hImageAvatar2;
HIMAGE m_hImageBubble;
HIMAGE m_hImageBubble2;
Void OnExit ()
{
If (XC_IsHXCGUI (m_hImageAvatar XC_IMAGE_FRAME)) XImage_Release (m_hImageAvatar);
If (XC_IsHXCGUI (m_hImageAvatar2 XC_IMAGE_FRAME)) XImage_Release (m_hImageAvatar2);
If (XC_IsHXCGUI (m_hImageBubble XC_IMAGE_FRAME)) XImage_Release (m_hImageBubble);
If (XC_IsHXCGUI (m_hImageBubble2 XC_IMAGE_FRAME)) XImage_Release (m_hImageBubble2);
}
Void Init (HWINDOW HWINDOW, int left, int top, int width, int height)
{
M_hEdit=XEdit_Create (left, top, width, height, edit_type_chat, hWindow);
XEle_EnableKeyTab (m_hEdit, TRUE);
XEdit_SetRowHeight (m_hEdit, 20);
//XEle_SetPadding (m_hEdit, 50, 0, 60, 0).
HFONTX hFont1=XFont_Create2 (L "Microsoft jas black", 9);
M_style1=XEdit_AddStyle (m_hEdit hFont1, RGB (0, 0, 255), TRUE);
M_hImageAvatar=XImage_LoadFile (L "image \ \ avatar PNG");//picture
M_hImageAvatar2=XImage_LoadFile (L "image \ \ logo PNG");//picture
M_hImageBubble=XImage_LoadFileAdaptive (L "image \ \ mercifully PNG", 20,15,20,15);//bubble
M_hImageBubble2=XImage_LoadFileAdaptive (L "image \ \ bubble2 PNG", 20, 16, 20, 10); 2//bubbles
//XEdit_AddText (m_hEdit, L "\ n");
//XChat_AddChatBegin (m_hEdit, 0, 0, 0 x4);
//XEdit_AddText (m_hEdit, L "system message: 123456 \ n");
//XChat_AddChatEnd (m_hEdit);
}
Void Recv (edit_data_copy_ * data)
{
{
XEdit_AddText (m_hEdit, L "\ n");
XEdit_AddChatBegin (m_hEdit, 0, 0, 0 x4);
XEdit_AddText (m_hEdit, L "system message: 123456 \ n");
XEdit_AddChatEnd (m_hEdit);
}
Static int send_left=1;
If (send_left % 2)
XEdit_AddChatBegin (m_hEdit, m_hImageAvatar m_hImageBubble, 0 x1 | 0 by 8);
The else
XEdit_AddChatBegin (m_hEdit, m_hImageAvatar2 m_hImageBubble2, 0 x2 | 0 by 8);
Send_left + +;
XEdit_AddTextEx (m_hEdit, L "[training] dream fly (154460336) 2019/1/23 20:30:12 \ n", m_style1);
Int iCurRow=XEdit_GetCurRow (m_hEdit);
XEdit_SetRowHeightEx (m_hEdit, iCurRow - 1, 40);
AddData (data);
XEdit_AddChatEnd (m_hEdit);
XEdit_AddText (m_hEdit, L "\ n");
XEdit_AutoScroll (m_hEdit);
XEle_RedrawEle (m_hEdit);
}
Void AddData (edit_data_copy_ * data)
{
//read the stylesheet
VectorStyleTable (data - & gt; NStyleCount edit_style_no);
for (int i=0; i {
HIMAGE hObj=data - & gt; PStyle [I] hFont_image_obj;
XC_OBJECT_TYPE ty=XObj_GetTypeBase (hObj);
If (XC_IMAGE_FRAME==ty)
{
//HIMAGE hSrc=https://bbs.csdn.net/topics/XImage_GetImageSrc (hObj);
//const would * pFile=XImgSrc_GetFile (hSrc);
Int iStyle=XEdit_AddStyle (m_hEdit hObj, 0, FALSE);
StyleTable [I]=iStyle;
} else if (XC_FONT==ty)
{
COLORREF color=data - & gt; PStyle [I]. Color;
Int iStyle=XEdit_AddStyle (m_hEdit, HFONTX hObj, color, data - & gt; PStyle [I] bColor);
StyleTable [I]=iStyle;
} else if (XC_ELE==ty)
{
If (XC_BUTTON==XC_GetObjectType (hObj))
{
Mr HELE hBtn=XBtn_Create (0, 0, XEle_GetWidth (Mr HELE hObj), XEle_GetHeight (Mr HELE hObj), XBtn_GetText (Mr HELE hObj), m_hEdit);
Int iStyle=XEdit_AddStyle (hBtn m_hEdit, 0, FALSE);
StyleTable [I]=iStyle;
}
} else if (XC_SHAPE==ty)
{
If (XC_IsHXCGUI (hObj XC_SHAPE_GIF))
{
HIMAGE hImageGif=XShapeGif_GetImage (hObj);
//HIMAGE hSrc=https://bbs.csdn.net/topics/XImage_GetImageSrc (hImageGif);
//const would * pFile=XImgSrc_GetFile (hSrc);
{
HXCGUI hGif=XShapeGif_Create (0, 0, XImage_GetWidth (hImageGif), XImage_GetHeight (hImageGif), m_hEdit);
XShapeGif_SetImage (hGif hImageGif);
Int iStyle=XEdit_AddStyle (m_hEdit hGif, 0, FALSE);
StyleTable [I]=iStyle;
}
}
}
}
XEdit_AddData (m_hEdit, data, styleTable. Data (), data - & gt; NStyleCount);
}
};
The class CEditSend
{
Public:
HWINDOW m_hWindow;
Mr HELE m_hEdit;
Mr HELE m_hBtnSend;
Mr HELE m_hBtnImg1;
Mr HELE m_hBtnImg2;
Mr HELE m_hBtnImg3;
Mr HELE m_hButton;
Mr HELE m_hBtnFont1;
Mr HELE m_hBtnFont2;
Mr HELE m_hBtnFont3;
Mr HELE m_hBtnColor1;
Mr HELE m_hBtnColor2;
Mr HELE m_hBtnColor3;
Int m_iCurStyle;
CEditRecv * m_pRecv;
Void Init (HWINDOW HWINDOW, int left, int top, int width, int height)
{
M_hWindow=hWindow;
InitBar (left, top);
M_hBtnSend=XBtn_Create (left + width + 10, top, 80, 30, L "send to", hWindow);
XEle_EnableFocus (m_hBtnSend, FALSE);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull