// MainDlg.cpp : implementation of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "aboutdlg.h"
#include "MainDlg.h"
CFontInfo g_buddyFontInfo;
LRESULT CALLBACK CMainDlg::NewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
CMainDlg * lpThis = (CMainDlg *)::GetWindowLong(hWnd, GWL_USERDATA);
if (NULL == lpThis)
return ::DefWindowProc(hWnd, message, wParam, lParam);
switch (message)
{
case WM_MOUSEMOVE:
{
IImageOle * pNewImageOle = NULL;
RECT rc = {0};
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
IImageOle * pImageOle = NULL;
BOOL bRet = RichEdit_GetImageOle(hWnd, pt, &pImageOle);
if (bRet && pImageOle != NULL)
{
pNewImageOle = pImageOle;
pImageOle->GetObjectRect(&rc);
}
if (pImageOle != NULL)
pImageOle->Release();
if (lpThis->m_pLastImageOle != pNewImageOle)
{
lpThis->m_pLastImageOle = pNewImageOle;
if (lpThis->m_pLastImageOle != NULL)
{
lpThis->m_hRBtnDownWnd = hWnd;
lpThis->m_ptRBtnDown = pt;
if (!lpThis->m_PicBarDlg.IsWindow())
lpThis->m_PicBarDlg.Create(lpThis->m_hWnd);
RECT rc2 = {0};
::GetClientRect(hWnd, &rc2);
POINT pt = {rc.right, rc.bottom-lpThis->m_cyPicBarDlg};
if (pt.x < rc2.left)
pt.x = rc2.left;
if (pt.x > rc2.right)
pt.x = rc2.right;
if (pt.y > rc2.bottom-lpThis->m_cyPicBarDlg)
pt.y = rc2.bottom-lpThis->m_cyPicBarDlg;
::ClientToScreen(hWnd, &pt);
::SetWindowPos(lpThis->m_PicBarDlg.m_hWnd, NULL, pt.x, pt.y, lpThis->m_cxPicBarDlg, lpThis->m_cyPicBarDlg, SWP_NOACTIVATE|SWP_SHOWWINDOW);
}
else
{
::ShowWindow(lpThis->m_PicBarDlg.m_hWnd, SW_HIDE);
}
}
}
break;
}
return ::CallWindowProc(lpThis->m_lpOldWndProc, hWnd, message, wParam, lParam);
}
CFontInfo::CFontInfo(void)
{
m_nSize = 9;
m_clrText = RGB(0,0,0);
m_strName = _T("宋体");
m_bBold = FALSE;
m_bItalic = FALSE;
m_bUnderLine = FALSE;
}
CFontInfo::~CFontInfo(void)
{
}
CMainDlg::CMainDlg(void)
{
m_hDlgIcon = m_hDlgSmallIcon = NULL;
m_hRBtnDownWnd = NULL;
memset(&m_ptRBtnDown, 0, sizeof(m_ptRBtnDown));
m_pLastImageOle = NULL;
m_cxPicBarDlg = 122;
m_cyPicBarDlg = 24;
m_lpOldWndProc = NULL;
}
CMainDlg::~CMainDlg(void)
{
}
BOOL CMainDlg::PreTranslateMessage(MSG* pMsg)
{
if (::GetForegroundWindow() == m_hWnd && !m_Accelerator.IsNull() &&
m_Accelerator.TranslateAccelerator(m_hWnd, pMsg))
return TRUE;
if (pMsg->message == WM_RBUTTONDOWN)
{
if (pMsg->hwnd == m_richSend.m_hWnd)
{
m_hRBtnDownWnd = pMsg->hwnd;
m_ptRBtnDown.x = GET_X_LPARAM(pMsg->lParam);
m_ptRBtnDown.y = GET_Y_LPARAM(pMsg->lParam);
CMenuHandle menuPopup = m_menuRichEdit.GetSubMenu(0);
UINT nSel = ((m_richSend.GetSelectionType() != SEL_EMPTY) ? 0 : MF_GRAYED);
menuPopup.EnableMenuItem(ID_MENU_CUT, MF_BYCOMMAND|nSel);
menuPopup.EnableMenuItem(ID_MENU_COPY, MF_BYCOMMAND|nSel);
UINT nPaste = (m_richSend.CanPaste() ? 0 : MF_GRAYED) ;
menuPopup.EnableMenuItem(ID_MENU_PASTE, MF_BYCOMMAND|nPaste);
IImageOle * pImageOle = NULL;
BOOL bRet = RichEdit_GetImageOle(pMsg->hwnd, m_ptRBtnDown, &pImageOle);
UINT nSaveAs = ((bRet && pImageOle != NULL) ? 0 : MF_GRAYED) ;
menuPopup.EnableMenuItem(ID_MENU_SAVEAS, MF_BYCOMMAND|nSaveAs);
if (pImageOle != NULL)
pImageOle->Release();
menuPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
pMsg->pt.x, pMsg->pt.y, m_hWnd, NULL);
}
else if (pMsg->hwnd == m_richRecv.m_hWnd)
{
m_hRBtnDownWnd = pMsg->hwnd;
m_ptRBtnDown.x = GET_X_LPARAM(pMsg->lParam);
m_ptRBtnDown.y = GET_Y_LPARAM(pMsg->lParam);
CMenuHandle menuPopup = m_menuRichEdit.GetSubMenu(1);
UINT nSel = ((m_richRecv.GetSelectionType() != SEL_EMPTY) ? 0 : MF_GRAYED);
menuPopup.EnableMenuItem(ID_MENU_COPY, MF_BYCOMMAND|nSel);
//menuPopup.EnableMenuItem(ID_MENU_CLEAR, MF_BYCOMMAND|nSel);
IImageOle * pImageOle = NULL;
BOOL bRet = RichEdit_GetImageOle(pMsg->hwnd, m_ptRBtnDown, &pImageOle);
UINT nSaveAs = ((bRet && pImageOle != NULL) ? 0 : MF_GRAYED) ;
menuPopup.EnableMenuItem(ID_MENU_SAVEAS, MF_BYCOMMAND|nSaveAs);
if (pImageOle != NULL)
pImageOle->Release();
menuPopup.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
pMsg->pt.x, pMsg->pt.y, m_hWnd, NULL);
}
}
if ((pMsg->message == WM_LBUTTONDBLCLK) && (pMsg->hwnd == m_richRecv.m_hWnd))
{
POINT pt = {GET_X_LPARAM(pMsg->lParam), GET_Y_LPARAM(pMsg->lParam)};
IImageOle * pImageOle = NULL;
BOOL bRet = RichEdit_GetImageOle(pMsg->hwnd, pt, &pImageOle);
if (bRet && pImageOle != NULL)
{
BSTR bstrFileName = NULL;
HRESULT hr = pImageOle->GetFileName(&bstrFileName);
if (SUCCEEDED(hr))
::ShellExecute(NULL, _T("open"), bstrFileName, NULL, NULL, SW_SHOWNORMAL);
if (bstrFileName != NULL)
::SysFreeString(bstrFileName);
}
if (pImageOle != NULL)
pImageOle->Release();
}
if ((pMsg->hwnd == m_richSend.m_hWnd) && (pMsg->message == WM_KEYDOWN)
&& (pMsg->wParam == 'V') && (pMsg->lParam & VK_CONTROL)) // 发送消息框的Ctrl+V消息
{
m_richSend.PasteSpecial(CF_TEXT);
return TRUE;
}
return CWindow::IsDialogMessage(pMsg);
}
BOOL CMainDlg::OnIdle()
{
return FALSE;
}
BOOL CMainDlg::OnInitDialog(CWindow wndFocus, LPARAM lInitParam)
{
// center the dialog on the screen
CenterWindow();
LPCTSTR lpfile = _T("file://C:\\DOCUME~1\\Admin\\LOCALS~1\\Temp\\4A(I71_$_G9OSK(G@PRX)ND.gif");
FILE * fp = _tfopen(lpfile, _T("rb"));
if (fp)
{
fclose(fp);
}
// set icons
m_hDlgIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
SetIcon(m_hDlgIcon, TRUE);
m_hDlgSmallIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
SetIcon(m_hDlgSmallIcon, FALSE);
// register object for message filtering and idle updates
CMessageLoop* pLoop = _Module.GetMessageLoop();
ATLASSERT(pLoop != NULL);
pLoop->AddMessageFilter(this);
pLoop->AddIdleHandler(this);
UIAddChildWindowContainer(m_hWnd);
tstring strPath = ZYM::CPath::GetCurDir() + _T("Face\\FaceConfig.xml");
m_FaceList.LoadConfigFile(strPath.c_str());
m_richRecv = GetDlgItem(ID_RICHEDIT_RECV);
m_richSend = GetDlgItem(ID_RICHEDIT_SEND);
m_btnFace = GetDlgItem(ID_BTN_FACE);
m_btnImage = GetDlgItem(ID_BTN_IMAGE);
m_btnColor = GetDlgItem(ID_BTN_COLOR);
m_cboFontName = GetDlgItem(ID_COMBO_FONT_NAME);
m_cboFontSize = GetDlgItem(ID_COMBO_FONT_SIZE);
m_btnBold = GetDlgItem(ID_CHECK_BOLD);
m_btnItalic = GetDlgItem(ID_CHECK_ITALIC);
m_btnUnderLine = GetDlgItem(ID_CHECK_UNDERLINE);
m_btnClose = GetDlgItem(ID_BTN_CLOSE);
m_btnSend = GetDlgItem(ID_BTN_SEND);
m_fontInfo = g_buddyFontInfo;
// 发送消息富文本框控件
RichEdit_SetDefFont(m_richSend.m_hWnd, m_fontInfo.m_strName.c_str(),
m_fontInfo.m_nSize, m_fontInfo.m_clrText, m_fontInfo.m_bBold,
m_fontInfo.m_bItalic, m_fontInfo.m_bUnderLine, FALSE);
// 接收消息富文本框控件
DWORD dwMask = m_richRecv.GetEventMask();
dwMask = dwMask | ENM_LINK | ENM_MOUSEEVENTS | ENM_SCROLLEVENTS | ENM_KEYEVENTS;
m_richRecv.SetEventMask(dwMask);
m_richRecv.SetAutoURLDetect();
m_richRecv.SetReadOnly();
std::vector<tstring> arrSysFont;
EnumSysFont(&arrSysFont);
for (int i = 0; i < (int)arrSysFont.size(); i++)
{
m_cboFontName.AddString(arrSysFont[i].c_str());
}
arrSysFont.clear();
int nIndex = m_cboFontName.FindString(0, m_fontInfo.m_strName.c_str());
m_cboFontName.SetCurSel(nIndex);
CString strFontSize;
for (int i = 8; i <= 22; i++)
{
strFontSize.Format(_T("%d"), i);
m_cboFontSize.AddString(strFontSize);
}
strFontSize.Format(_T("%d"), m_fontInfo.m
没有合适的资源?快使用搜索试试~ 我知道了~
1、支持输入框文字格式设置,包括字体名称、字体大小、加粗、倾斜、下划线、文字颜色等。 2、支持插入BMP、JPG、PNG、GIF等格式的图片文件。 3、支持图片和文字的复制剪切粘贴拖放,并与QQ、IE、Google Chrome、Word等的剪切板格式互相兼容。 4、支持表情选择框、图片文件选择框等方式插入表情或图片。 5、支持设置显示比例,图片自动缩放,图片右键另存为菜单,图片双击打开,图片悬浮工具栏等。
资源推荐
资源详情
资源评论











收起资源包目录





































































































共 334 条
- 1
- 2
- 3
- 4
zym_123456
- 粉丝: 268
- 资源: 17

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制

- 1
- 2
- 3
- 4
- 5
- 6
前往页