void CLogEditCtrl::Init(LPCTSTR pszTitle, LPCTSTR pszSkinKey) { CHAR szClassName[MAX_PATH]; GetClassNameA(*this, szClassName, ARRSIZE(szClassName)); m_bRichEdit = __ascii_stricmp(szClassName, "EDIT") != 0; m_strSkinKey = pszSkinKey; SetTitle(pszTitle); m_LogMenu.CreatePopupMenu(); m_LogMenu.AddMenuTitle(GetResString(IDS_LOGENTRY)); m_LogMenu.AppendMenu(MF_STRING, MP_COPYSELECTED, GetResString(IDS_COPY)); m_LogMenu.AppendMenu(MF_SEPARATOR); m_LogMenu.AppendMenu(MF_STRING, MP_SELECTALL, GetResString(IDS_SELECTALL)); m_LogMenu.AppendMenu(MF_STRING, MP_REMOVEALL, GetResString(IDS_PW_RESET)); m_LogMenu.AppendMenu(MF_STRING, MP_SAVELOG, GetResString(IDS_SAVELOG) + _T("...")); m_LogMenu.AppendMenu(MF_SEPARATOR); m_LogMenu.AppendMenu(MF_STRING, MP_AUTOSCROLL, GetResString(IDS_AUTOSCROLL)); VERIFY( SendMessage(EM_SETUNDOLIMIT, 0, 0) == 0 ); int iMaxLogBuff = thePrefs.GetMaxLogBuff(); if (afxData.bWin95) LimitText(m_iMaxLogBuff = (iMaxLogBuff > 0xFFFF ? 0xFFFF : iMaxLogBuff)); else LimitText(m_iMaxLogBuff = (iMaxLogBuff ? iMaxLogBuff : 128*1024)); FlushBuffer(); }
void CStatusCtrl::OnOutputcontextClearall() { USES_CONVERSION; CString rtfstr = m_RTFHeader; rtfstr += "} "; char *buffer = new char[rtfstr.GetLength() + 5]; strcpy(buffer + 4, T2CA(rtfstr)); *(int *)buffer = 0; EDITSTREAM es; es.dwCookie = (DWORD)buffer; // Pass a pointer to the CString to the callback function es.pfnCallback = RichEditStreamInCallback; // Specify the pointer to the callback function. StreamIn(SF_RTF, es); // Perform the streaming SetSel(-1, -1); LimitText(1000*1000); int res = GetLimitText(); delete [] buffer; m_bEmpty = TRUE; m_nMoveToBottom = 0; }
int CStatusCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CRichEditCtrl::OnCreate(lpCreateStruct) == -1) return -1; USES_CONVERSION; m_RTFHeader = "{\\rtf1\\ansi\\deff0"; HFONT hSysFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); LOGFONT lf; CFont* pFont = CFont::FromHandle( hSysFont ); pFont->GetLogFont( &lf ); LOGFONT m_lfFont; pFont->GetLogFont(&m_lfFont); int pointsize = (-m_lfFont.lfHeight*72/ GetDeviceCaps(GetDC()->GetSafeHdc(), LOGPIXELSY))*2; CString fontname = m_lfFont.lfFaceName; //if (COptions::GetOptionVal(OPTION_MESSAGELOG_USECUSTOMFONT)) //{ // CString fn = COptions::GetOption(OPTION_MESSAGELOG_FONTNAME); // int pt = COptions::GetOptionVal(OPTION_MESSAGELOG_FONTSIZE); // if (fn != "") // fontname = fn; // if (pt != 0) // pointsize = pt * 2; //} m_RTFHeader += ("{\\fonttbl{\\f0\\fnil "); m_RTFHeader += fontname; m_RTFHeader += (";}}"); m_RTFHeader += "{\\colortbl ;"; for (int i=0; i<16; i++) { CString tmp; tmp.Format(_T("\\red%d\\green%d\\blue%d;"), GetRValue(m_ColTable[i]), GetGValue(m_ColTable[i]), GetBValue(m_ColTable[i])); m_RTFHeader+=tmp; } m_RTFHeader += "}"; CString tmp; tmp.Format(_T("%d"), pointsize); m_RTFHeader += ("\\uc1\\pard\\fi-50\\li50\\tx50\\f0\\fs"); m_RTFHeader += tmp; CString rtfstr = m_RTFHeader; rtfstr += "} "; EDITSTREAM es; string s = Util::ws2s(wstring(rtfstr)); es.dwCookie = (DWORD)&s; // Pass a pointer to the string to the callback function es.pfnCallback = RichEditStreamInCallback; // Specify the pointer to the callback function. StreamIn(SF_RTF, es); // Perform the streaming SetSel(-1, -1); LimitText(1000*1000); return 0; }
void CHTRichEditCtrl::Init(LPCTSTR pszTitle, LPCTSTR pszSkinKey) { SetProfileSkinKey(pszSkinKey); SetTitle(pszTitle); VERIFY( SendMessage(EM_SETUNDOLIMIT, 0, 0) == 0 ); int iMaxLogBuff = thePrefs.GetMaxLogBuff(); if (afxIsWin95()) LimitText(iMaxLogBuff > 0xFFFF ? 0xFFFF : iMaxLogBuff); else LimitText(iMaxLogBuff ? iMaxLogBuff : 128*1024); m_iLimitText = GetLimitText(); VERIFY( GetSelectionCharFormat(m_cfDefault) ); // prevent the RE control to change the font height within single log lines (may happen with some Unicode chars) DWORD dwLangOpts = SendMessage(EM_GETLANGOPTIONS); SendMessage(EM_SETLANGOPTIONS, 0, dwLangOpts & ~(IMF_AUTOFONT /*| IMF_AUTOFONTSIZEADJUST*/)); //SendMessage(EM_SETEDITSTYLE, SES_EMULATESYSEDIT, SES_EMULATESYSEDIT); }
void CRichView::OnInitialUpdate() { //increase the text limit of the rich edit window LimitText(-1); //Determine which messages will be passed to the parent DWORD dwMask = ENM_KEYEVENTS | ENM_DROPFILES ; SetEventMask(dwMask); SetFontDefaults(); }
int CStatusCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CRichEditCtrl::OnCreate(lpCreateStruct) == -1) return -1; USES_CONVERSION; m_RTFHeader = "{\\rtf1\\ansi\\deff0"; HFONT hSysFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); LOGFONT lf; CFont* pFont = CFont::FromHandle( hSysFont ); pFont->GetLogFont( &lf ); LOGFONT m_lfFont; pFont->GetLogFont(&m_lfFont); m_RTFHeader += "{\\fonttbl{\\f0\\fnil "+ CString(m_lfFont.lfFaceName)+";}}"; m_RTFHeader += "{\\colortbl ;"; for (int i=0; i<16; i++) { CString tmp; tmp.Format(_T("\\red%d\\green%d\\blue%d;"), GetRValue(m_ColTable[i]), GetGValue(m_ColTable[i]), GetBValue(m_ColTable[i])); m_RTFHeader+=tmp; } m_RTFHeader += "}"; int pointsize = (-m_lfFont.lfHeight*72/ GetDeviceCaps(GetDC()->GetSafeHdc(), LOGPIXELSY))*2; CString tmp; tmp.Format(_T("%d"), pointsize); m_RTFHeader += "\\uc1\\pard\\fi-200\\li200\\tx200\\f0\\fs"+tmp; //180*m_nAvgCharWidth; CString rtfstr = m_RTFHeader; rtfstr += "} "; char *buffer = new char[rtfstr.GetLength() + 5]; strcpy(buffer + 4, T2CA(rtfstr)); *(int *)buffer = 0; EDITSTREAM es; es.dwCookie = (DWORD)buffer; // Pass a pointer to the CString to the callback function es.pfnCallback = RichEditStreamInCallback; // Specify the pointer to the callback function. StreamIn(SF_RTF, es); // Perform the streaming SetSel(-1, -1); LimitText(1000*1000); delete [] buffer; return 0; }
void CStatusCtrl::OnOutputcontextClearall() { USES_CONVERSION; CString rtfstr = m_RTFHeader; rtfstr += "} "; EDITSTREAM es; string s = Util::ws2s(wstring(rtfstr)); es.dwCookie = (DWORD)&s; // Pass a pointer to the CString to the callback function es.pfnCallback = RichEditStreamInCallback; // Specify the pointer to the callback function. StreamIn(SF_RTF, es); // Perform the streaming SetSel(-1, -1); LimitText(1000*1000); int res = GetLimitText(); m_bEmpty = TRUE; m_nMoveToBottom = 0; }
void CAutoRichEditCtrlFx::InitEx() { LimitText(0x7FFFFFF0); }
void CHexEdit::SetMaxChars(int nMax) { m_nMaxChar = nMax; LimitText(nMax); }