c++ - MFC SDI read from an INI and update view string while changing attributes -


first time post, forgive improper etiquette may bring.

my title briefly describes problem have. have school project start mfc application single document view , need display simple text onto view text comes simple ini file.

lpctstr path = _t("c:\\users\\steve\\documents\\wheredatais.ini"); tchar inivalue[256]; getprivateprofilestring(_t("setup"), _t("introduction"), _t("file not found"), inivalue, 256, path); 

okay ini file contains this...

[setup]  introduction = here data 

up point, going well. next step grab 'static text box' created in resource editor , change data ini 'here data'.

setdlgitemtext(stringtochange, inivalue); 

and works perfect. managed change wanted desired comes hard part. need bold entire string before using

setdlgitemtext(stringtochange, inivalue); 

i have run many problems in last 5 days. have tried have run across on google , stack overflow. ran trying use rtf control? trying convert html bolding , coming back? issues 8bit or 16bit? unicode or along lines. i've ran macros _t("some string") apparently doesn't take variable of type string. nothing has worked me. use kind of example, doesn't have relate mine @ all. can work base from. , before link me website or previous post - guarantee i've looked @ , tried it. i'd post small part of code me started.

you need use font bold style achieve need:

 m_font.createfont(16, 0, 0, 0, fw_bold, false, false, 0, default_charset,  out_default_precis, clip_default_precis, default_quality,   default_pitch | ff_swiss, _t("ms sans serif"));  m_yourstaticcontrol.setfont(&m_font);  

make cfont m_font; member of class (put in header file).

if want more flexibility use richedit control. here helper function appends text using different styles:

void addtorichtext(cricheditctrl &redit, const cstring& snewtext, colorref color, bool bbold, bool bunderline, bool bitalic) {     int itotaltextlength = redit.getwindowtextlength();      redit.setsel(itotaltextlength, itotaltextlength);      charformat cf;     cf.cbsize = sizeof(charformat);     cf.dwmask = cfm_color | cfm_underline | cfm_bold | cfm_italic;      dword dweffects = cfe_autocolor;     if (!bbold)         dweffects |= cfe_bold;      if (!bunderline)         dweffects |= cfe_underline;      if (!bitalic)         dweffects |= cfe_italic;      cf.dweffects = (unsigned long)~dweffects;      cf.crtextcolor = color;     redit.setselectioncharformat(cf);      redit.replacesel(snewtext);     redit.hideselection(true, false); } 

Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -