630 lines
15 KiB
C++
630 lines
15 KiB
C++
// BaseTextDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "BaseTextDlg.h"
|
|
#include "chardlg.h"
|
|
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
//TARCH_IMPEXP bool FindRT_MANIFEST();
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CBaseTextDlg dialog
|
|
//modify by lgy 20120111 第一次启动软件时文字高度应该从文字管理中读取
|
|
//double CBaseTextDlg::g_nHeight=3.5;
|
|
double CBaseTextDlg::g_nHeight = GetTextHeightByTs(TS_SYMBOL);
|
|
CString CBaseTextDlg::m_strFontStyle = GetTextStyleName(TS_SYMBOL);
|
|
|
|
IMPLEMENT_DYNAMIC(CBaseTextDlg, CModelessDialog)
|
|
CBaseTextDlg::CBaseTextDlg(UINT IDD, CWnd* pParent /*=NULL*/)
|
|
: CModelessDialog(IDD, pParent) //, m_bContinue(FALSE)
|
|
{
|
|
if(fabs(g_nHeight) < 1.0E-3)
|
|
g_nHeight = 3.5;
|
|
//{{AFX_DATA_INIT(CBaseTextDlg)
|
|
m_strHeight.Format(_T("%.1f"), g_nHeight);
|
|
m_strInputText = _T("");
|
|
//}}AFX_DATA_INIT
|
|
|
|
//注释 by lgy 20120111 文字样式不能置为当前文字样式,要改为上次命令记忆的文字样式
|
|
// XString sStyle;
|
|
// xg_getvar(_T("TEXTSTYLE"), sStyle);
|
|
// m_strFontStyle=(const TCHAR *)sStyle;
|
|
// m_strFontStyle = _T("");
|
|
|
|
// Add By Lcf On 2005-6-06-24
|
|
m_bPost = FALSE;
|
|
m_nOperCode=-1;
|
|
// sg add 090324
|
|
m_bNeedSingleLineText = TRUE;
|
|
}
|
|
|
|
void CBaseTextDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CModelessDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CBaseTextDlg)
|
|
DDX_Control(pDX, IDC_COMBO_FONGSTYLE, m_comboStyleName);
|
|
DDX_CBString(pDX, IDC_COMBO_HEIGHT, m_strHeight);
|
|
if(pDX->m_bSaveAndValidate && _tstof(m_strHeight)<1.0E-3)
|
|
pDX->Fail();
|
|
if(pDX->m_bSaveAndValidate)
|
|
DDX_CBString(pDX, IDC_COMBO_FONGSTYLE, m_strFontStyle);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CBaseTextDlg, CModelessDialog)
|
|
//{{AFX_MSG_MAP(CBaseTextDlg)
|
|
ON_CBN_SELCHANGE(IDC_COMBO_FONGSTYLE, OnSelchangeComboFongstyle)
|
|
ON_BN_CLICKED(IDC_BUTTON_TEXT_HEIGHT, OnButtonTextHeight)
|
|
ON_COMMAND_RANGE(ID_SPECIAL_CHAR, ID_PICKTEXT, OnChar)
|
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
|
|
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
|
|
ON_WM_ACTIVATE()
|
|
ON_WM_CLOSE()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CBaseTextDlg message handlers
|
|
BOOL CBaseTextDlg::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
ASSERT(pNMHDR->code == TTN_NEEDTEXTA || pNMHDR->code == TTN_NEEDTEXTW);
|
|
|
|
// if there is a top level routing frame then let it handle the message
|
|
if (GetRoutingFrame() != NULL) return FALSE;
|
|
|
|
// to be thorough we will need to handle UNICODE versions of the message also !!
|
|
TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
|
|
TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
|
|
CString strTipText;
|
|
// Zyu modify on 100726,支持64位
|
|
//UINT nID = pNMHDR->idFrom;
|
|
UINT nID = (UINT)pNMHDR->idFrom;
|
|
|
|
if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) ||
|
|
pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND))
|
|
{
|
|
// idFrom is actually the HWND of the tool
|
|
//nID = ::GetDlgCtrlID((HWND)nID);
|
|
return FALSE; // shen rui add 对话框控件不显示
|
|
}
|
|
|
|
if (nID != 0) // will be zero on a separator
|
|
{
|
|
{
|
|
CTemporaryResourceOverride vTmp;
|
|
strTipText.LoadString(nID); //=szFullText;
|
|
}
|
|
|
|
#ifndef _UNICODE
|
|
if (pNMHDR->code == TTN_NEEDTEXTA)
|
|
{
|
|
lstrcpyn(pTTTA->szText, strTipText, sizeof(pTTTA->szText));
|
|
}
|
|
else
|
|
{
|
|
_mbstowcsz(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
|
|
}
|
|
#else
|
|
if (pNMHDR->code == TTN_NEEDTEXTA)
|
|
{
|
|
_wcstombsz(pTTTA->szText, strTipText,sizeof(pTTTA->szText));
|
|
}
|
|
else
|
|
{
|
|
lstrcpyn(pTTTW->szText, strTipText, sizeof(pTTTW->szText));
|
|
}
|
|
#endif
|
|
|
|
*pResult = 0;
|
|
|
|
// bring the tooltip window above other popup windows
|
|
::SetWindowPos(pNMHDR->hwndFrom, HWND_TOP, 0, 0, 0, 0,SWP_NOACTIVATE|
|
|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOOWNERZORDER); return TRUE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CBaseTextDlg::OnInitDialog()
|
|
{
|
|
CModelessDialog::OnInitDialog();
|
|
LoadTextStyle();
|
|
|
|
m_toolbar.Create(this);
|
|
{
|
|
CTemporaryResourceOverride vTmp;
|
|
m_toolbar.LoadToolBar(IDR_TOOLBAR_TEXT);
|
|
}
|
|
m_toolbar.ShowWindow(SW_SHOW);
|
|
m_toolbar.SetBarStyle(CBRS_ALIGN_TOP | CBRS_TOOLTIPS | CBRS_FLYBY );
|
|
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
|
|
|
|
// sg modify 120706,增加一个判断,如果当前记忆的样式没有的话,那么使用上华固定的文字样式
|
|
//m_comboStyleName.SetCurSel(m_comboStyleName.FindStringExact(0, m_strFontStyle));
|
|
int nRet = m_comboStyleName.FindStringExact(0, m_strFontStyle);
|
|
if (nRet < 0) // 当前图纸没有此样式
|
|
{
|
|
nRet = m_comboStyleName.FindStringExact(0, _T("_TCH_DIM"));
|
|
}
|
|
m_comboStyleName.SetCurSel(nRet);
|
|
|
|
// Add By Lcf On 2005-6-06-24
|
|
if(m_bModeless)
|
|
{
|
|
CRect rOk;
|
|
GetDlgItem(IDOK)->GetWindowRect(rOk);
|
|
CRect rect;
|
|
GetWindowRect(rect);
|
|
rect.bottom -= rOk.Height();
|
|
rect.bottom -= 5;//add by whl
|
|
MoveWindow(rect);
|
|
GetDlgItem(IDOK)->ShowWindow(SW_HIDE);
|
|
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
|
|
}
|
|
// add by xly on 100902 去掉“连续标注”标签
|
|
/*else
|
|
GetDlgItem(IDC_CONTINUE)->ShowWindow(SW_HIDE);*/
|
|
GetDlgItem(IDC_CONTINUE)->ShowWindow(SW_HIDE);
|
|
|
|
UpdateData(FALSE);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
}
|
|
|
|
void CBaseTextDlg::UpdateInputText()
|
|
{
|
|
return;
|
|
}
|
|
|
|
// Modify by lcf On 2005-07-05
|
|
BOOL CBaseTextDlg::GetPosition(int& h, int& l)
|
|
{
|
|
DWORD n;
|
|
CComboBox *pComboBox = NULL;
|
|
CEdit *pEdit = NULL;
|
|
CWnd *pWnd1 = this->GetFocus();
|
|
if(m_pCurWnd->IsKindOf(RUNTIME_CLASS(CComboBox)))
|
|
{
|
|
pComboBox = (CComboBox*)m_pCurWnd;
|
|
if(pComboBox->m_hWnd != pWnd1->GetParent()->m_hWnd)
|
|
{
|
|
int nSel = pComboBox->GetWindowTextLength();
|
|
pComboBox->SetEditSel(nSel, nSel);
|
|
}
|
|
n = pComboBox->GetEditSel();
|
|
}
|
|
else if(m_pCurWnd->IsKindOf(RUNTIME_CLASS(CEdit)))
|
|
{
|
|
pEdit = (CEdit*)m_pCurWnd;
|
|
if(pEdit->m_hWnd != pWnd1->m_hWnd)
|
|
{
|
|
int nBegin = pEdit->LineIndex( pEdit->GetLineCount()-1 );
|
|
int nEnd = nBegin + pEdit->LineLength(nBegin);
|
|
pEdit->SetSel(nEnd, nEnd);
|
|
}
|
|
n = pEdit->GetSel();
|
|
}
|
|
else
|
|
return FALSE;
|
|
|
|
l = (int)LOWORD(n);
|
|
h = (int)HIWORD(n);
|
|
|
|
#if (ADS>15)
|
|
if(!FindRT_MANIFEST())
|
|
return TRUE;
|
|
|
|
OSVERSIONINFO osVer;
|
|
osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
|
|
VERIFY(GetVersionEx(&osVer)==TRUE);
|
|
if(osVer.dwPlatformId==VER_PLATFORM_WIN32_NT && osVer.dwMajorVersion>=5 && osVer.dwMinorVersion>=1) {
|
|
CString csText;
|
|
m_pCurWnd->GetWindowText(csText);
|
|
XString xsText;
|
|
xsText=csText;
|
|
// Zyu modify on 100726,去掉编译警告
|
|
//int nCount=_tcslen(xsText);
|
|
int nCount = (int)_tcslen(xsText);
|
|
int iLow=l, iUp=h;
|
|
for(int idx=0; idx<nCount; idx++) {
|
|
if(idx>=iUp)
|
|
break;
|
|
TCHAR c=xsText[idx];
|
|
if(c<0) { //汉字
|
|
if(idx<iLow)
|
|
iLow++;
|
|
if(idx<iUp)
|
|
iUp++;
|
|
idx++;
|
|
}
|
|
}
|
|
l=iLow;
|
|
h=iUp;
|
|
}
|
|
#endif
|
|
return TRUE;
|
|
}
|
|
void CBaseTextDlg::OnChar(UINT nID)
|
|
{
|
|
UpdateData(TRUE);
|
|
m_pCurWnd = GetCurWnd();
|
|
if(!m_pCurWnd)
|
|
{
|
|
AfxMessageBox(_T("只能在指定控件中输入特殊字符!"));
|
|
return;
|
|
}
|
|
|
|
int h, l;
|
|
if(!GetPosition(h, l))
|
|
return;
|
|
|
|
int i = 0;// Modify By Lcf On 2005-07-01
|
|
switch (nID)
|
|
{
|
|
case ID_DOWN_MARK:
|
|
if(h==l)
|
|
{
|
|
AfxMessageBox(_T("请先在文字框中选择字符!"));
|
|
return;
|
|
}
|
|
m_strInputText.Insert(l, _T("^L"));
|
|
m_strInputText.Insert(h + 2, _T("^L"));
|
|
i=h+4;
|
|
break;
|
|
case ID_UP_MARK:
|
|
if(h==l)
|
|
{
|
|
AfxMessageBox(_T("请先在文字框中选择字符!"));
|
|
return;
|
|
}
|
|
m_strInputText.Insert(l,_T("^U"));
|
|
m_strInputText.Insert(h + 2, _T("^U"));
|
|
i=h+4;
|
|
break;
|
|
case ID_CIRCLE:
|
|
if(h==l)
|
|
{
|
|
AfxMessageBox(_T("请先在文字框中选择字符!"));
|
|
return;
|
|
}
|
|
m_strInputText.Insert(l,_T("^C"));
|
|
m_strInputText.Insert(h + 2, _T("^C"));
|
|
i=h+4;
|
|
break;
|
|
case ID_ANGLE_CHAR:
|
|
m_strInputText.Delete(l, h - l);
|
|
m_strInputText.Insert(l, _T("%%d"));
|
|
i=l+3;
|
|
break;
|
|
case ID_DIA_CHAR:
|
|
m_strInputText.Delete(l, h - l);
|
|
m_strInputText.Insert(l, _T("%%c"));
|
|
i=l+3;
|
|
break;
|
|
case ID_TOLERANCE_CHAR:
|
|
m_strInputText.Delete(l, h - l);
|
|
m_strInputText.Insert(l, _T("%%p"));
|
|
i=l+3;
|
|
break;
|
|
case ID_PERCENT_CHAR:
|
|
m_strInputText.Delete(l, h - l);
|
|
m_strInputText.Insert(l,_T("%%%"));
|
|
i=l+3;
|
|
break;
|
|
case ID_ONE_STEEL:
|
|
m_strInputText.Delete(l, h - l);
|
|
m_strInputText.Insert(l,_T("^1"));
|
|
i=l+2;
|
|
break;
|
|
case ID_TWO_STEEL:
|
|
m_strInputText.Delete(l, h - l);
|
|
m_strInputText.Insert(l, _T("^2"));
|
|
i=l+2;
|
|
break;
|
|
case ID_THREE_STEEL:
|
|
m_strInputText.Delete(l, h - l);
|
|
m_strInputText.Insert(l, _T("^3"));
|
|
i=l+2;
|
|
break;
|
|
case ID_FOUR_STEEL:
|
|
m_strInputText.Delete(l, h - l);
|
|
m_strInputText.Insert(l, _T("^4"));
|
|
i=l+2;
|
|
break;
|
|
case ID_SPECIAL_CHAR:
|
|
{
|
|
XPushAutoHide nAutoHide(this);
|
|
|
|
CCharDlg dlg(this);
|
|
CString str;
|
|
CTemporaryResourceOverride vTemp;
|
|
if(dlg.DoModal() != IDOK || dlg.m_character == _T(""))
|
|
return;
|
|
str = dlg.m_character;
|
|
m_strInputText.Delete(l, h - l);
|
|
m_strInputText.Insert(l, str);
|
|
i=l+str.GetLength();
|
|
}
|
|
break;
|
|
case ID_WORD://词库
|
|
{
|
|
XPushAutoHide nAutoHide(this);
|
|
|
|
CInsTextDlg dlg(this);
|
|
dlg.SetPreText(m_strInputText);
|
|
dlg.SetSingleText(m_bNeedSingleLineText); // zzg 2009 03 24
|
|
if(dlg.DoModal()!=IDOK||dlg.GetEditText()==_T(""))
|
|
return;
|
|
m_strInputText.Delete(l,h-l);
|
|
m_strInputText.Insert(l,dlg.GetEditText());
|
|
i=l+dlg.GetEditText().GetLength();
|
|
}
|
|
break;
|
|
case ID_PICKTEXT:// Add By Lcf On 2005-07-01
|
|
{
|
|
if(m_bModeless && m_bPost)
|
|
{
|
|
m_nOperCode = 1;
|
|
PostCommand(_T("` "), false);
|
|
}
|
|
else
|
|
{
|
|
GetPickText();
|
|
acedGetAcadDwgView()->SetFocus();
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
UpdateInputText(); // 回传给子类
|
|
|
|
CComboBox *pComboBox = NULL;
|
|
CEdit *pEdit = NULL;
|
|
|
|
if(m_pCurWnd->IsKindOf(RUNTIME_CLASS(CComboBox))) {
|
|
pComboBox = (CComboBox*)m_pCurWnd;
|
|
int index = pComboBox->FindStringExact(0, m_strInputText);
|
|
if(index < 0)
|
|
pComboBox->InsertString(0, m_strInputText);
|
|
pComboBox->SelectString(0, m_strInputText);
|
|
pComboBox->SetEditSel(i, i);
|
|
}// 以上四行目的为了防止COMBOBOX在已有列表选择一个最匹配的,所加m_strInputText只是临时的。
|
|
if(m_pCurWnd->IsKindOf(RUNTIME_CLASS(CEdit))) {
|
|
pEdit = (CEdit*)m_pCurWnd;
|
|
pEdit->SetSel(i, i);
|
|
}
|
|
UpdateData(FALSE);
|
|
if(pEdit)
|
|
pEdit->SetSel(i, i);
|
|
else
|
|
pComboBox->SetEditSel(i, i);
|
|
}
|
|
|
|
// Add by lcf On 2005-07-01
|
|
BOOL CBaseTextDlg::GetPickText()
|
|
{
|
|
XPushAutoHide noAutoHide(this);
|
|
|
|
m_nOperCode = -1;
|
|
int h, l;
|
|
if(!GetPosition(h, l))
|
|
return FALSE;
|
|
int i = 0;// Modify By Lcf On 2005-07-01
|
|
|
|
BeginEditorCommand();
|
|
Entity ent;
|
|
RBList mask(RTDXF0,_T("TCH_*,TEXT"),NULL);
|
|
XPoint pt;
|
|
if(SelectEntity(_T("\n屏幕拾取文字内容:"),ent,pt,mask) != RTNORM)
|
|
{
|
|
CompleteEditorCommand();
|
|
return FALSE;
|
|
}
|
|
|
|
PickSet ss(SS_FREE);
|
|
ss+=ent;
|
|
TSubText* pSubText = HitTestOnText(ss,Ucs2Wcs(pt));
|
|
if(pSubText!=NULL)
|
|
{
|
|
CString sText=pSubText->GetText();
|
|
delete pSubText;
|
|
m_strInputText.Delete(l,h-l);
|
|
m_strInputText.Insert(l,sText);
|
|
i=l+sText.GetLength();
|
|
}
|
|
CompleteEditorCommand();
|
|
|
|
UpdateInputText(); // 回传给子类
|
|
|
|
CComboBox *pComboBox = NULL;
|
|
CEdit *pEdit = NULL;
|
|
|
|
if(m_pCurWnd->IsKindOf(RUNTIME_CLASS(CComboBox))) {
|
|
pComboBox = (CComboBox*)m_pCurWnd;
|
|
int index = pComboBox->FindStringExact(0, m_strInputText);
|
|
if(index < 0)
|
|
pComboBox->InsertString(0, m_strInputText);
|
|
pComboBox->SelectString(0, m_strInputText);
|
|
pComboBox->SetEditSel(i, i);
|
|
}// 以上四行目的为了防止COMBOBOX在已有列表选择一个最匹配的,所加m_strInputText只是临时的。
|
|
if(m_pCurWnd->IsKindOf(RUNTIME_CLASS(CEdit))) {
|
|
pEdit = (CEdit*)m_pCurWnd;
|
|
pEdit->SetSel(i, i);
|
|
}
|
|
UpdateData(FALSE);
|
|
if(pEdit)
|
|
pEdit->SetSel(i, i);
|
|
else
|
|
pComboBox->SetEditSel(i, i);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CBaseTextDlg::OnOK()
|
|
{
|
|
g_nHeight = _tstof(m_strHeight);
|
|
CModelessDialog::OnOK();
|
|
|
|
}
|
|
|
|
void CBaseTextDlg::LoadTextStyle()
|
|
{
|
|
XSymbolList lstStyle(_T("STYLE"));
|
|
|
|
for (int m =0; m < lstStyle.Length(); m++)
|
|
m_comboStyleName.AddString(lstStyle[m]);
|
|
}
|
|
|
|
// Modify By Lcf On 2005-6-06-24
|
|
void CBaseTextDlg::OnButtonTextHeight()
|
|
{
|
|
if(m_bModeless && m_bPost)
|
|
{
|
|
m_nOperCode = 0;
|
|
PostCommand(_T("` "), false);
|
|
}
|
|
else
|
|
{
|
|
GetTextHeight();
|
|
acedGetAcadDwgView()->SetFocus();
|
|
}
|
|
}
|
|
|
|
void CBaseTextDlg::OnSelchangeComboFongstyle()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
if(m_comboStyleName.GetCurSel()>=0)
|
|
m_comboStyleName.GetLBText(m_comboStyleName.GetCurSel(),m_strFontStyle);
|
|
AcDbObjectId idTextStyle = GetTextStyleId(m_strFontStyle);
|
|
if(!idTextStyle)
|
|
return;
|
|
|
|
OPENOBJ_BEGIN(idTextStyle, AcDb::kForRead, AcDbTextStyleTableRecord, pStyle);
|
|
// sg modify 110118,解决因为文字样式缺少,而产生的崩溃问题
|
|
// ASSERT(pStyle);
|
|
if (pStyle != NULL)
|
|
{
|
|
CString strTemp;
|
|
strTemp.Format(_T("%.1f"), pStyle->textSize()); //读文字风格的字高
|
|
if(_tstof(strTemp)>1.0E-3)
|
|
m_strHeight = strTemp;
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(_T("文字风格已删除!"));
|
|
}
|
|
OPENOBJ_END();
|
|
UpdateData(FALSE);
|
|
m_comboStyleName.SetCurSel(m_comboStyleName.FindStringExact(0, m_strFontStyle));
|
|
}
|
|
|
|
|
|
void CBaseTextDlg::Obj2Dlg(TDbSymbWithText *pText)
|
|
{
|
|
m_strHeight.Format(_T("%.1f"), pText->GetTextHeight());
|
|
AcDbObjectId idTextStyle = pText->GetTextStyleId();
|
|
|
|
OPENOBJ_BEGIN(idTextStyle, AcDb::kForRead, AcDbTextStyleTableRecord, pStyle);
|
|
// sg modify 110118,解决因为文字样式缺少,而产生的崩溃问题
|
|
// ASSERT(pStyle);
|
|
if (pStyle != NULL)
|
|
{
|
|
const TCHAR* pName = NULL;
|
|
if (pStyle->getName(pName) == Acad::eOk && pName != NULL)
|
|
m_strFontStyle = pName;
|
|
else
|
|
AfxMessageBox(_T("文字风格已删除!"));
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(_T("文字风格已删除!"));
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
|
|
|
|
void CBaseTextDlg::Dlg2Obj(TDbSymbWithText *pText)
|
|
{
|
|
AcDbObjectId idTextStyle = GetTextStyleId(m_strFontStyle);
|
|
if(!idTextStyle)
|
|
return;
|
|
pText->SetTextStyleId(idTextStyle);
|
|
g_nHeight = _tstof(m_strHeight);
|
|
pText->SetTextHeight(g_nHeight);
|
|
|
|
|
|
}
|
|
|
|
// Add By Lcf On 2005-6-06-24
|
|
void CBaseTextDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
|
|
{
|
|
CModelessDialog::OnActivate(nState, pWndOther, bMinimized);
|
|
if(nState == WA_CLICKACTIVE)
|
|
{
|
|
CWnd *pWnd = GetCurWnd();
|
|
CWnd *pWnd1 = this->GetFocus();
|
|
if(pWnd->IsKindOf(RUNTIME_CLASS(CComboBox)))
|
|
{
|
|
CComboBox *pComboBox = (CComboBox*)pWnd;
|
|
if(pComboBox->m_hWnd == pWnd1->GetParent()->m_hWnd)
|
|
{
|
|
int nSel = pComboBox->GetWindowTextLength();
|
|
pComboBox->SetEditSel(nSel, nSel);
|
|
}
|
|
}
|
|
else if(pWnd->IsKindOf(RUNTIME_CLASS(CEdit)))
|
|
{
|
|
CEdit *pEdit = (CEdit*)pWnd;
|
|
if(pEdit->m_hWnd == pWnd1->m_hWnd)
|
|
{
|
|
int nBegin = pEdit->LineIndex( pEdit->GetLineCount()-1 );
|
|
int nEnd = nBegin + pEdit->LineLength(nBegin);
|
|
pEdit->SetSel(nEnd, nEnd);
|
|
}
|
|
}
|
|
}
|
|
else if(nState == WA_INACTIVE)
|
|
{
|
|
UpdateData();
|
|
if(m_bModeless && m_bPost)
|
|
PostCommand(_T("` "), false);
|
|
}
|
|
}
|
|
|
|
// Add By Lcf On 2005-6-06-24
|
|
void CBaseTextDlg::OnClose()
|
|
{
|
|
if(m_bModeless)
|
|
{
|
|
m_bPost = FALSE;
|
|
PostCommand(_T(" "), false);
|
|
}
|
|
CModelessDialog::OnClose();
|
|
}
|
|
|
|
// Add By Lcf On 2005-6-06-24
|
|
void CBaseTextDlg::GetTextHeight()
|
|
{
|
|
XPushAutoHide noAutoHide(this);
|
|
|
|
XPushMemVar<BOOL> vTemp(m_bPost,FALSE);
|
|
m_nOperCode = -1;
|
|
UpdateData(TRUE);
|
|
double nHeight = _tstof(m_strHeight)*DocGetPScale();
|
|
|
|
BeginEditorCommand();
|
|
if(GetDist(_T("\n字高"), nHeight, RSG_NOZERO|RSG_NONEG) == RTNORM) {
|
|
nHeight /= DocGetPScale();
|
|
m_strHeight.Format(_T("%.1f"), nHeight);
|
|
}
|
|
CompleteEditorCommand();
|
|
UpdateData(FALSE);
|
|
}
|