MCPcopy Create free account
hub / github.com/cinience/RedisStudio / InitDefaultCharFormat

Function InitDefaultCharFormat

DuiLib/Control/UIRichEdit.cpp:172–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172HRESULT InitDefaultCharFormat(CRichEditUI* re, CHARFORMAT2W* pcf, HFONT hfont)
173{
174 memset(pcf, 0, sizeof(CHARFORMAT2W));
175 LOGFONT lf;
176 if( !hfont )
177 hfont = re->GetManager()->GetFont(re->GetFont());
178 ::GetObject(hfont, sizeof(LOGFONT), &lf);
179
180 DWORD dwColor = re->GetTextColor();
181 pcf->cbSize = sizeof(CHARFORMAT2W);
182 pcf->crTextColor = RGB(GetBValue(dwColor), GetGValue(dwColor), GetRValue(dwColor));
183 LONG yPixPerInch = GetDeviceCaps(re->GetManager()->GetPaintDC(), LOGPIXELSY);
184 pcf->yHeight = -lf.lfHeight * LY_PER_INCH / yPixPerInch;
185 pcf->yOffset = 0;
186 pcf->dwEffects = 0;
187 pcf->dwMask = CFM_SIZE | CFM_OFFSET | CFM_FACE | CFM_CHARSET | CFM_COLOR | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE;
188 if(lf.lfWeight >= FW_BOLD)
189 pcf->dwEffects |= CFE_BOLD;
190 if(lf.lfItalic)
191 pcf->dwEffects |= CFE_ITALIC;
192 if(lf.lfUnderline)
193 pcf->dwEffects |= CFE_UNDERLINE;
194 pcf->bCharSet = lf.lfCharSet;
195 pcf->bPitchAndFamily = lf.lfPitchAndFamily;
196#ifdef _UNICODE
197 _tcscpy(pcf->szFaceName, lf.lfFaceName);
198#else
199 //need to thunk pcf->szFaceName to a standard char string.in this case it's easy because our thunk is also our copy
200 MultiByteToWideChar(CP_ACP, 0, lf.lfFaceName, LF_FACESIZE, pcf->szFaceName, LF_FACESIZE) ;
201#endif
202
203 return S_OK;
204}
205
206HRESULT InitDefaultParaFormat(CRichEditUI* re, PARAFORMAT2* ppf)
207{

Callers 1

InitMethod · 0.85

Calls 4

GetManagerMethod · 0.80
GetPaintDCMethod · 0.80
GetFontMethod · 0.45
GetTextColorMethod · 0.45

Tested by

no test coverage detected