第一种,将图片显示在对话框内,CxImage用来存储图片的信息,主要是采用 InsertImage 来将图片插入对话框,函数体的命名是 OnFinishScreenCapture()。
1 void SessionLayout::OnFinishScreenCapture(__in LPCTSTR lpFilePath) 2 { 3 CxImage img; 4 img.Load(lpFilePath, CXIMAGE_SUPPORT_BMP); 5 HBITMAP hBitmap = img.MakeBitmap(); 6 BITMAP bitmap; 7 GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bitmap); 8 SIZE bitmapSize = { bitmap.bmWidth, bitmap.bmHeight }; 9 CString szImgPath(lpFilePath); 10 InsertImage(szImgPath.GetBuffer(), bitmapSize, FALSE); 11 }
第二种,将图片以图片形式发送出去,void SessionLayout::_SendImage(CString& csFilePath)。
1 //构造纯图片消息
2 ST_picData picData; 3 picData.nPos = 0; 4 picData.strLocalPicPath = csFilePath; 5 MixedMsg mixMsg; 6 mixMsg.m_picDataVec.push_back(picData); 7 //发送图片
8 _SendSessionMsg(mixMsg); 9
10 //本地消息展现
11 MessageEntity msg; 12 msg.msgType = MSG_TYPE_TEXT_P2P; 13 msg.talkerSid = module::getSysConfigModule()->code(); 14 msg.sessionId = m_sId; 15 msg.msgRenderType = MESSAGE_RENDERTYPE_TEXT; 16 msg.msgStatusType = MESSAGE_TYPE_RUNTIME; 17 msg.content = util::cStringToString(mixMsg.MakeMixedLocalMSG()); 18 msg.msgTime = module::getSessionModule()->getTime(); 19 _DisplayMsgToIE(msg);