示例#1
0
/////////////////////////////////////////////////////////////////////////////
// initialize
/////////////////////////////////////////////////////////////////////////////
void CChatControl::initControl()
{
	CRect rect;
	CHARFORMAT cf;
	CNetSysMessage msg;

	//go black
	SetBackgroundColor(FALSE, RGB(0, 0, 0));

	//set default font stuff
	cf.dwMask = CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_BOLD;
	cf.dwEffects = 0;
	cf.yHeight = 162;
	cf.crTextColor = RGB(255, 255, 255);
	strncpy(cf.szFaceName, "Tahoma", sizeof(cf.szFaceName));
	SetDefaultCharFormat(cf);

	//give a little border
	GetRect(&rect);
	rect.DeflateRect(5, 3, 0, 0);
	SetRect(&rect);

	//add the starting message
	addString("***Chat services have been initialized.", FALSE, COLOR_WHITE);
}
示例#2
0
void CInputRichEdit::SetFontSize( UINT fontsize )
{
	CHARFORMAT cf;
	memset(&cf, 0, sizeof(CHARFORMAT));

	GetDefaultCharFormat(cf);
	cf.yHeight = fontsize * 15;
	m_stFont.font_size = fontsize;

	SetDefaultCharFormat(cf);
}
示例#3
0
void CInputRichEdit::SetFontColor( COLORREF crColor )
{
	CHARFORMAT cf;
	memset(&cf, 0, sizeof(CHARFORMAT));

	GetDefaultCharFormat(cf);
	cf.dwEffects &= ~CFE_AUTOCOLOR;
	cf.crTextColor = crColor;
	m_stFont.font_color = crColor;

	SetDefaultCharFormat(cf);
}
void CFulEditCtrl::SetTextColor( COLORREF color ) {
	CHARFORMAT cf;
	cf.cbSize = sizeof(CHARFORMAT);
	cf.dwMask = CFM_COLOR;
	cf.dwEffects = 0;
	cf.crTextColor = color;
	SetDefaultCharFormat(cf);

	//otroligt fulhack, måste lagas riktigt nån gång
	selFormat.cbSize = sizeof(CHARFORMAT2);
	GetSelectionCharFormat(selFormat);
}
示例#5
0
文件: LogViewRE.cpp 项目: bver/ancho
LRESULT CLogView::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
  DefWindowProc();

  SetReadOnly();
  SetFont(AtlGetDefaultGuiFont());
  SetBackgroundColor(LOG_BGCOLOR);

  CHARFORMAT cf = {0};
  cf.cbSize = sizeof(CHARFORMAT);
  cf.crTextColor = LOG_DEFAULTCOLOR;
  cf.yHeight = 200;
  cf.dwMask = CFM_COLOR | CFM_SIZE;
  SetDefaultCharFormat(cf);
  return 0;
}
示例#6
0
void CInputRichEdit::SetDefaultFont(UINT fontsize/* = 12*/)
{
	CHARFORMAT cf;
	memset(&cf, 0, sizeof(CHARFORMAT));

	GetDefaultCharFormat(cf);
	cf.yHeight = fontsize * 15;
	cf.dwEffects &= ~CFE_BOLD;
	cf.dwEffects &= ~CFE_ITALIC;
	cf.dwEffects &= ~CFE_UNDERLINE;
	swprintf_s(cf.szFaceName, L"宋体");

	SetDefaultCharFormat(cf);

	m_stFont.font_size = fontsize;
}
示例#7
0
void CInputRichEdit::SetFontName( std::wstring strFontName )
{
	CHARFORMAT cf;
	memset(&cf, 0, sizeof(CHARFORMAT));

	GetDefaultCharFormat(cf);
	swprintf_s(cf.szFaceName, strFontName.c_str());
	m_stFont.font_type = strFontName;

	//CFontDialog dlg;
	//if (dlg.DoModal() == IDOK)
	//{
	//	dlg.GetCharFormat(cf);
	//}

	SetDefaultCharFormat(cf);
}
void CHTRichEditCtrl::SetFont(CFont* pFont, BOOL bRedraw)
{
	LOGFONT lf = {0};
	pFont->GetLogFont(&lf);

	CHARFORMAT cf = {0};
	cf.cbSize = sizeof cf;

	cf.dwMask |= CFM_BOLD;
	cf.dwEffects |= (lf.lfWeight == FW_BOLD) ? CFE_BOLD : 0;

	cf.dwMask |= CFM_ITALIC;
	cf.dwEffects |= (lf.lfItalic) ? CFE_ITALIC : 0;

	cf.dwMask |= CFM_UNDERLINE;
	cf.dwEffects |= (lf.lfUnderline) ? CFE_UNDERLINE : 0;

	cf.dwMask |= CFM_STRIKEOUT;
	cf.dwEffects |= (lf.lfStrikeOut) ? CFE_STRIKEOUT : 0;

	cf.dwMask |= CFM_SIZE;
	HDC hDC = ::GetDC(NULL);
	int iPointSize = -MulDiv(lf.lfHeight, 72, GetDeviceCaps(hDC, LOGPIXELSY));
	cf.yHeight = iPointSize * 20;
	::ReleaseDC(NULL, hDC);

	cf.dwMask |= CFM_FACE;
	cf.bPitchAndFamily = lf.lfPitchAndFamily;
	_tcsncpy(cf.szFaceName, lf.lfFaceName, ARRSIZE(cf.szFaceName));
	cf.szFaceName[ARRSIZE(cf.szFaceName) - 1] = _T('\0');

	// although this should work correctly (according SDK) it may give false results (e.g. the "click here..." text
	// which is shown in the server info window may not be entirely used as a hyperlink???)
	//	cf.dwMask |= CFM_CHARSET;
	//	cf.bCharSet = lf.lfCharSet;

	cf.yOffset = 0;
	VERIFY( SetDefaultCharFormat(cf) );
	VERIFY( GetSelectionCharFormat(m_cfDefault) );

	if (bRedraw){
		Invalidate();
		UpdateWindow();
	}
}
示例#9
0
LRESULT LogViewRE::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
  DefWindowProc();

  SetReadOnly();
  mFont.CreateFont(
   20,                  // nHeight
   0,                         // nWidth
   0,                         // nEscapement
   0,                         // nOrientation
   FW_NORMAL,                 // nWeight
   FALSE,                     // bItalic
   FALSE,                     // bUnderline
   0,                         // cStrikeOut
   ANSI_CHARSET,              // nCharSet
   OUT_DEFAULT_PRECIS,        // nOutPrecision
   CLIP_DEFAULT_PRECIS,       // nClipPrecision
   DEFAULT_QUALITY,           // nQuality
   DEFAULT_PITCH | FF_SWISS,  // nPitchAndFamily
   _T("Consolas")                // font face
   );
  SetFont(mFont);
//  SetFont(AtlGetDefaultGuiFont());
  SetBackgroundColor(LOG_BGCOLOR);

  CHARFORMAT cf = {0};
  cf.cbSize = sizeof(CHARFORMAT);
  cf.crTextColor = LOG_DEFAULTCOLOR;
  cf.yHeight = 200;
  cf.dwMask = CFM_COLOR | CFM_SIZE;
  SetDefaultCharFormat(cf);

  PARAFORMAT2 pf;
  memset(&pf, 0, sizeof(PARAFORMAT2));
  pf.cbSize = sizeof(PARAFORMAT2);
  pf.cTabCount = 2;
  pf.rgxTabs[0] = cf.yHeight * 5;
  pf.rgxTabs[1] = cf.yHeight * 10;
  pf.dwMask = PFM_TABSTOPS;
  SetParaFormat(pf);

  return 0;
}
示例#10
0
void CInputRichEdit::SetFontBold( bool bBold )
{
	CHARFORMAT cf;
	memset(&cf, 0, sizeof(CHARFORMAT));

	GetDefaultCharFormat(cf);
	if (bBold)
	{
		cf.dwEffects |= CFE_BOLD;
		m_stFont.font_style |= core::FONTSTYLETYPE_BOLD;
	}
	else
	{
		cf.dwEffects &= ~CFE_BOLD;
		m_stFont.font_style &= ~core::FONTSTYLETYPE_BOLD;
	}

	SetDefaultCharFormat(cf);
}
示例#11
0
void CInputRichEdit::SetFontItalic( bool bItalic )
{
	CHARFORMAT cf;
	memset(&cf, 0, sizeof(CHARFORMAT));

	GetDefaultCharFormat(cf);
	if (bItalic)
	{
		cf.dwEffects |= CFE_ITALIC;
		m_stFont.font_style |= core::FONTSTYLETYPE_ITALICS;
	}
	else
	{
		cf.dwEffects &= ~CFE_ITALIC;
		m_stFont.font_style &= ~core::FONTSTYLETYPE_ITALICS;
	}

	SetDefaultCharFormat(cf);
}
示例#12
0
int CHelpBox::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	CRichEditCtrl::OnCreate(lpCreateStruct);
	//set the color and font of the control
	SetBackgroundColor(false,0x00CEFFFF); //light yellow
	CHARFORMAT cf;
	cf.cbSize=sizeof(CHARFORMAT);
	cf.dwMask=CFM_BOLD|CFM_COLOR|CFM_FACE|CFM_ITALIC|CFM_SIZE|CFM_UNDERLINE;
	cf.dwEffects=0;
	cf.yHeight=180;
	cf.yOffset=0;
	cf.crTextColor=0x00000000;
	cf.bCharSet=ANSI_CHARSET;
	cf.bPitchAndFamily=DEFAULT_PITCH;
	strcpy(cf.szFaceName, "Arial");
	
	SetDefaultCharFormat(cf);

	return 0;
}
示例#13
0
void CExtRichEdit::InitSettings()
{	
	////////////////////////////////////////////////////////////

	////////////////////////////////////////////////////////////
	unsigned mask = ::SendMessage(m_hWnd, EM_GETEVENTMASK, 0, 0);
    ::SendMessage(m_hWnd, EM_SETEVENTMASK, 0, mask | ENM_LINK  | ENM_MOUSEEVENTS | ENM_SCROLLEVENTS | ENM_KEYEVENTS);
    ::SendMessage(m_hWnd, EM_AUTOURLDETECT, true, 0);
	
	CHARFORMAT cf;
	cf.cbSize = sizeof (CHARFORMAT);  
	cf.dwMask = CFM_FACE | CFM_SIZE |CFM_BOLD;
	cf.dwEffects = ~CFE_BOLD;
	cf.yHeight = 180;
	_tcscpy_s(cf.szFaceName,32, _T("新細明體")); 


	
	SetDefaultCharFormat(cf);
}
示例#14
0
void CInputRichEdit::SetFontUnderLine( bool bUnderLine )
{
	CHARFORMAT cf;
	memset(&cf, 0, sizeof(CHARFORMAT));

	GetDefaultCharFormat(cf);
	if (bUnderLine)
	{
		cf.dwEffects |= CFE_UNDERLINE;
		m_stFont.font_style |= core::FONTSTYLETYPE_UNDERLINE;
	}
	else
	{
		cf.dwEffects &= ~CFE_UNDERLINE;
		m_stFont.font_style &= ~core::FONTSTYLETYPE_UNDERLINE;
	}
	

	SetDefaultCharFormat(cf);
}
示例#15
0
void CTWScriptEdit::Initialize() 
{
	PARAFORMAT pf;
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_TABSTOPS ;
	pf.cTabCount = MAX_TAB_STOPS;
	for( int itab = 0 ; itab < pf.cTabCount  ; itab++ )
		pf.rgxTabs[itab] = (itab + 1) * 1440/5 ;

	SetParaFormat( pf );

	CHARFORMAT cfDefault;
	cfDefault.cbSize = sizeof(cfDefault);
	cfDefault.dwEffects = CFE_PROTECTED; 
	cfDefault.dwMask = CFM_BOLD | CFM_FACE | CFM_SIZE | CFM_CHARSET | CFM_PROTECTED;
	cfDefault.yHeight = 200;
	cfDefault.bCharSet = 0xEE; 
	strcpy(cfDefault.szFaceName, _T("Courier New")); 

	SetDefaultCharFormat(cfDefault);
	
	SetEventMask(ENM_CHANGE | ENM_SELCHANGE | ENM_PROTECTED);
}
void CHTRichEditCtrl::ApplySkin()
{
	if (!m_strSkinKey.IsEmpty())
	{
		// Use the 'ScrollInfo' only, if there is a scrollbar available, otherwise we would
		// use a scrollinfo which points to the top and we would thus stay at the top.
		bool bAtEndOfScroll;
		SCROLLINFO si;
		si.cbSize = sizeof si;
		si.fMask = SIF_ALL;
		if ((GetStyle() & WS_VSCROLL) && GetScrollInfo(SB_VERT, &si))
			bAtEndOfScroll = (si.nPos >= (int)(si.nMax - si.nPage));
		else
			bAtEndOfScroll = true;

		COLORREF cr;
		if (theApp.LoadSkinColor(m_strSkinKey + _T("Fg"), cr)) {
			m_bDfltForeground = false;
			m_crForeground = cr;
		}
		else {
			m_bDfltForeground = m_crDfltForeground == CLR_DEFAULT;
			m_crForeground = m_bDfltForeground ? GetSysColor(COLOR_WINDOWTEXT) : m_crDfltForeground;
		}

		bool bSetCharFormat = false;
		CHARFORMAT cf;
		GetDefaultCharFormat(cf);
		if (!m_bDfltForeground && (cf.dwEffects & CFE_AUTOCOLOR)) {
			cf.dwEffects &= ~CFE_AUTOCOLOR;
			bSetCharFormat = true;
		}
		else if (m_bDfltForeground && !(cf.dwEffects & CFE_AUTOCOLOR)) {
			cf.dwEffects |= CFE_AUTOCOLOR;
			bSetCharFormat = true;
		}
		if (bSetCharFormat) {
			cf.dwMask |= CFM_COLOR;
			cf.crTextColor = m_crForeground;
			VERIFY( SetDefaultCharFormat(cf) );
			VERIFY( GetSelectionCharFormat(m_cfDefault) );
		}

		if (theApp.LoadSkinColor(m_strSkinKey + _T("Bk"), cr)) {
			m_bDfltBackground = false;
			m_crBackground = cr;
			SetBackgroundColor(FALSE, m_crBackground);
		}
		else {
			m_bDfltBackground = m_crDfltBackground == CLR_DEFAULT;
			m_crBackground = m_bDfltBackground ? GetSysColor(COLOR_WINDOW) : m_crDfltBackground;
			SetBackgroundColor(m_bDfltBackground, m_crBackground);
		}

		if (bAtEndOfScroll)
			ScrollToLastLine();
	}
	else
	{
		m_bDfltForeground = m_crDfltForeground == CLR_DEFAULT;
		m_crForeground = m_bDfltForeground ? GetSysColor(COLOR_WINDOWTEXT) : m_crDfltForeground;

		m_bDfltBackground = m_crDfltBackground == CLR_DEFAULT;
		m_crBackground = m_bDfltBackground ? GetSysColor(COLOR_WINDOW) : m_crDfltBackground;

		VERIFY( GetSelectionCharFormat(m_cfDefault) );
	}
	PurgeSmileyCaches();
}
void CHTRichEditCtrl::SetFont(CFont* pFont, BOOL bRedraw)
{
	// Use the 'ScrollInfo' only, if there is a scrollbar available, otherwise we would
	// use a scrollinfo which points to the top and we would thus stay at the top.
	bool bAtEndOfScroll;
	SCROLLINFO si;
	si.cbSize = sizeof si;
	si.fMask = SIF_ALL;
	if ((GetStyle() & WS_VSCROLL) && GetScrollInfo(SB_VERT, &si))
		bAtEndOfScroll = (si.nPos >= (int)(si.nMax - si.nPage));
	else
		bAtEndOfScroll = true;

	LOGFONT lf = {0};
	pFont->GetLogFont(&lf);

	CHARFORMAT cf = {0};
	cf.cbSize = sizeof cf;

	cf.dwMask |= CFM_BOLD;
	cf.dwEffects |= (lf.lfWeight == FW_BOLD) ? CFE_BOLD : 0;

	cf.dwMask |= CFM_ITALIC;
	cf.dwEffects |= (lf.lfItalic) ? CFE_ITALIC : 0;

	cf.dwMask |= CFM_UNDERLINE;
	cf.dwEffects |= (lf.lfUnderline) ? CFE_UNDERLINE : 0;

	cf.dwMask |= CFM_STRIKEOUT;
	cf.dwEffects |= (lf.lfStrikeOut) ? CFE_STRIKEOUT : 0;

	cf.dwMask |= CFM_SIZE;
	HDC hDC = ::GetDC(HWND_DESKTOP);
	int iPointSize = -MulDiv(lf.lfHeight, 72, GetDeviceCaps(hDC, LOGPIXELSY));
	cf.yHeight = iPointSize * 20;
	::ReleaseDC(NULL, hDC);

	cf.dwMask |= CFM_FACE;
	cf.bPitchAndFamily = lf.lfPitchAndFamily;
	_tcsncpy(cf.szFaceName, lf.lfFaceName, _countof(cf.szFaceName));
	cf.szFaceName[_countof(cf.szFaceName) - 1] = _T('\0');

	// although this should work correctly (according SDK) it may give false results (e.g. the "click here..." text
	// which is shown in the server info window may not be entirely used as a hyperlink???)
	//	cf.dwMask |= CFM_CHARSET;
	//	cf.bCharSet = lf.lfCharSet;

	cf.yOffset = 0;
	VERIFY( SetDefaultCharFormat(cf) );

	// copy everything except the color
	m_cfDefault.dwMask = (cf.dwMask & ~CFM_COLOR) | (m_cfDefault.dwMask & CFM_COLOR);
	m_cfDefault.dwEffects = cf.dwEffects;
	m_cfDefault.yHeight = cf.yHeight;
	m_cfDefault.yOffset = cf.yOffset;
	//m_cfDefault.crTextColor = cf.crTextColor;
	m_cfDefault.bCharSet = cf.bCharSet;
	m_cfDefault.bPitchAndFamily = cf.bPitchAndFamily;
	memcpy(m_cfDefault.szFaceName, cf.szFaceName, sizeof(m_cfDefault.szFaceName));

	PurgeSmileyCaches();

	if (bAtEndOfScroll)
		ScrollToLastLine();

	if (bRedraw)
	{
		Invalidate();
		UpdateWindow();
	}
}
/*
================
CSyntaxRichEditCtrl::InitFont
================
*/
void CSyntaxRichEditCtrl::InitFont(void)
{
	LOGFONT lf;
	CFont font;
	PARAFORMAT pf;
	int logx, tabSize;

	// set the font
	memset(&lf, 0, sizeof(lf));
	lf.lfHeight = FONT_HEIGHT * 10;
	lf.lfWidth = FONT_WIDTH * 10;
	lf.lfCharSet = ANSI_CHARSET;
	lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
	strcpy(lf.lfFaceName, FONT_NAME);
	font.CreatePointFontIndirect(&lf);

	SetFont(&font);

	// get the tab size in twips
	logx = ::GetDeviceCaps(GetDC()->GetSafeHdc(), LOGPIXELSX);
	tabSize = TAB_SIZE * FONT_WIDTH * 1440 / logx;

	// set the tabs
	memset(&pf, 0, sizeof(PARAFORMAT));
	pf.cbSize = sizeof(PARAFORMAT);
	pf.dwMask = PFM_TABSTOPS;

	for (pf.cTabCount = 0; pf.cTabCount < MAX_TAB_STOPS; pf.cTabCount++) {
		pf.rgxTabs[pf.cTabCount] = pf.cTabCount * tabSize;
	}

	SetParaFormat(pf);

	memset(&defaultCharFormat, 0, sizeof(defaultCharFormat));
	defaultCharFormat.dwMask = CFM_CHARSET | CFM_FACE | CFM_SIZE | CFM_BOLD | CFM_COLOR | CFM_PROTECTED | CFM_BACKCOLOR;
	defaultCharFormat.yHeight = FONT_HEIGHT * 20;
	defaultCharFormat.bCharSet = ANSI_CHARSET;
	defaultCharFormat.bPitchAndFamily = FIXED_PITCH | FF_MODERN;
	defaultCharFormat.crTextColor = SRE_COLOR_BLACK;
	defaultCharFormat.crBackColor = DEFAULT_BACK_COLOR;
	defaultCharFormat.dwEffects = CFE_PROTECTED;
	strcpy(defaultCharFormat.szFaceName, FONT_NAME);
	defaultCharFormat.cbSize = sizeof(defaultCharFormat);

	SetDefaultCharFormat(defaultCharFormat);

	defaultColor = SRE_COLOR_BLACK;
	singleLineCommentColor = SRE_COLOR_DARK_GREEN;
	multiLineCommentColor = SRE_COLOR_DARK_GREEN;
	stringColor[0] = stringColor[1] = SRE_COLOR_DARK_CYAN;
	literalColor = SRE_COLOR_GREY;
	braceHighlightColor = SRE_COLOR_RED;

	// get the default tom::ITextFont
	tom::ITextRange *irange;
	tom::ITextFont *ifont;

	m_TextDoc->Range(0, 0, &irange);
	irange->get_Font(&ifont);

	ifont->get_Duplicate(&m_DefaultFont);

	ifont->Release();
	irange->Release();
}