145 lines
3.5 KiB
C++
145 lines
3.5 KiB
C++
|
|
//
|
|
//------------------------------------------------------------------------
|
|
//文件名: inplaceedit.cpp : implementation file
|
|
// 创建人: cwk
|
|
// 日 期:
|
|
// 描 述:
|
|
// 版 本:
|
|
// 修改人:
|
|
// 修改日期:
|
|
// 修改目的:
|
|
//-------------------------------------------------------------------------
|
|
|
|
#include "stdafx.h"
|
|
#include "InplaceEdit.h"
|
|
#include "resource.h"
|
|
|
|
CInPlaceEdit::CInPlaceEdit()
|
|
{
|
|
m_colorInPlaceText = g_colorInPlaceText;
|
|
m_colorInPlaceGround = g_colorInPlaceGround;
|
|
m_iInPlaceFontHeight = g_iInPlaceFontHeight;
|
|
|
|
//add by xlc on 071019
|
|
m_nMenuBKColor1 = g_menuColors[0];
|
|
m_nMenuBKColor2 = g_menuColors[1];
|
|
m_nMenuBKColor3 = g_menuColors[2];
|
|
m_nMenuBKColor4 = g_menuColors[3];
|
|
}
|
|
|
|
CInPlaceEdit::~CInPlaceEdit()
|
|
{
|
|
|
|
}
|
|
|
|
void CInPlaceEdit::SetHeight()
|
|
{
|
|
LOGFONT logFont;
|
|
m_font.GetObject (sizeof (logFont),&logFont);
|
|
logFont.lfHeight = - m_iInPlaceFontHeight;
|
|
m_font.CreateFontIndirect (&logFont);
|
|
SetFont(&m_font);
|
|
|
|
CDC *pCdc = GetDC();
|
|
pCdc->SelectObject(&m_font);
|
|
CSize size = pCdc->GetOutputTextExtent("上华软件Tangent Software");//modified by fxj 081229
|
|
CRect rect;
|
|
GetWindowRect(rect);
|
|
|
|
//modified by whl on 060104
|
|
// rect.right = rect.left + size.cx;
|
|
// rect.bottom = rect.top + size.cy;
|
|
rect.right = rect.left + size.cx+10;
|
|
rect.bottom = rect.top + size.cy+5;
|
|
|
|
GetParent()->ScreenToClient(rect);
|
|
MoveWindow(rect);
|
|
ReleaseDC(pCdc);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CInPlaceEdit,CEdit)
|
|
ON_WM_CTLCOLOR_REFLECT()
|
|
END_MESSAGE_MAP()
|
|
HBRUSH CInPlaceEdit::CtlColor(CDC* pDC,UINT nCtlColor)
|
|
{
|
|
if (::GetDlgCtrlID(m_hWnd) == IDC_EDIT_FONTCOL)
|
|
{
|
|
m_brush.DeleteObject();
|
|
m_brush.CreateSolidBrush(m_colorInPlaceText);
|
|
pDC->SetBkMode(TRANSPARENT);
|
|
pDC->SelectObject(&m_brush);
|
|
}
|
|
|
|
//add by xlc on 071019
|
|
else if (::GetDlgCtrlID(m_hWnd) == IDC_EDIT_BK1)
|
|
{
|
|
m_brush.DeleteObject();
|
|
m_brush.CreateSolidBrush(m_nMenuBKColor1);
|
|
pDC->SetBkMode(TRANSPARENT);
|
|
pDC->SelectObject(&m_brush);
|
|
}
|
|
else if (::GetDlgCtrlID(m_hWnd) == IDC_EDIT_BK2)
|
|
{
|
|
m_brush.DeleteObject();
|
|
m_brush.CreateSolidBrush(m_nMenuBKColor2);
|
|
pDC->SetBkMode(TRANSPARENT);
|
|
pDC->SelectObject(&m_brush);
|
|
}
|
|
else if (::GetDlgCtrlID(m_hWnd) == IDC_EDIT_BK3)
|
|
{
|
|
m_brush.DeleteObject();
|
|
m_brush.CreateSolidBrush(m_nMenuBKColor3);
|
|
pDC->SetBkMode(TRANSPARENT);
|
|
pDC->SelectObject(&m_brush);
|
|
}
|
|
else if (::GetDlgCtrlID(m_hWnd) == IDC_EDIT_BK4)
|
|
{
|
|
m_brush.DeleteObject();
|
|
m_brush.CreateSolidBrush(m_nMenuBKColor4);
|
|
pDC->SetBkMode(TRANSPARENT);
|
|
pDC->SelectObject(&m_brush);
|
|
}
|
|
|
|
else
|
|
{
|
|
m_brush.DeleteObject();
|
|
m_brush.CreateSolidBrush(m_colorInPlaceGround);
|
|
pDC->SelectObject(&m_brush);
|
|
pDC->SetBkMode(TRANSPARENT);
|
|
if (::GetDlgCtrlID(m_hWnd) == IDC_EDIT_PREVIEW)
|
|
{
|
|
pDC->SetTextColor((COLORREF)m_colorInPlaceText);
|
|
pDC->SetBkColor((COLORREF)m_colorInPlaceGround);
|
|
}
|
|
}
|
|
return (HBRUSH)(m_brush.GetSafeHandle());
|
|
}
|
|
|
|
void CInPlaceEdit::Init()
|
|
{
|
|
m_font.CreateStockObject(DEFAULT_GUI_FONT);
|
|
|
|
LOGFONT logFont;
|
|
m_font.GetObject (sizeof (logFont),&logFont);
|
|
logFont.lfHeight = - m_iInPlaceFontHeight;
|
|
m_font.CreateFontIndirect (&logFont);
|
|
|
|
SetFont(&m_font);
|
|
//zzg
|
|
//m_colorInPlaceText = g_colorInPlaceText;
|
|
//m_colorInPlaceGround = g_colorInPlaceGround;
|
|
//m_iInPlaceFontHeight = g_iInPlaceFontHeight;
|
|
|
|
CDC *pCdc = GetDC();
|
|
pCdc->SelectObject(&m_font);
|
|
CSize size=pCdc->GetOutputTextExtent(_T("上华建筑TArch7.0"));
|
|
|
|
CRect rect;
|
|
GetWindowRect(rect);
|
|
rect.right = rect.left + size.cx;
|
|
rect.bottom = rect.top + size.cy;
|
|
GetParent()->ScreenToClient(rect);
|
|
MoveWindow(rect);
|
|
ReleaseDC(pCdc);
|
|
} |