Click here to Skip to main content
16,011,779 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: Off-Hijacking : Welcome in the THHB, Code-o-mat! Pin
CPallini8-Jan-09 7:43
mveCPallini8-Jan-09 7:43 
GeneralRe: help me ! Pin
Hamid_RT7-Jan-09 23:26
Hamid_RT7-Jan-09 23:26 
GeneralRe: help me ! Pin
CPallini7-Jan-09 23:27
mveCPallini7-Jan-09 23:27 
GeneralRe: help me ! Pin
Hamid_RT7-Jan-09 23:52
Hamid_RT7-Jan-09 23:52 
AnswerRe: help me ! Pin
Michael Schubert8-Jan-09 1:36
Michael Schubert8-Jan-09 1:36 
QuestionRe: help me ! Pin
David Crow8-Jan-09 3:05
David Crow8-Jan-09 3:05 
AnswerRe: help me ! Pin
Lutosław21-Jan-09 1:15
Lutosław21-Jan-09 1:15 
QuestionSetSelectionCharFormat difficulties when selection contains different charset Pin
JJeffrey7-Jan-09 13:14
JJeffrey7-Jan-09 13:14 
I am using SetSelectionCharFormat in a RichEditCtrl object on my dialog box to allow a user to change the font/bold/etc text he is typing in the rich edit box.
Basically the function should change the character formatting as needed; the code is as follows:

void CRichEditProjDlg::OnSelchangeFontsize() 
{
	DWORD Selection=0, FontSize=0;
	CString SelFontSize;
	Selection = m_FontSize.GetCurSel();              //Get the current Selection

	m_FontSize.GetLBText(Selection, SelFontSize);    //Get the requested Font Size from a drop down box
	FontSize = _ttoi(SelFontSize);

	CHARFORMAT Cfm;
        Cfm.cbSize = sizeof(CHARFORMAT);
	m_RichCatch.GetSelectionCharFormat(Cfm);        //Get the char set of the selection

	Cfm.yHeight = FontSize*20;                      //Calculate the new font size

	m_RichCatch.SetSelectionCharFormat(Cfm);        //Set the new font size
	m_RichCatch.SetFocus();                         //Update the Rich Edit Box
	UpdateData(TRUE);
	
}

void CRichEditProjDlg::OnBold() 
{
	CHARFORMAT Cfm;
	Cfm.cbSize = sizeof(CHARFORMAT);

	m_RichCatch.GetSelectionCharFormat(Cfm);       //Get the char set of selection

	Cfm.dwMask = CFM_BOLD;                         //Apply "boldness"
	Cfm.dwEffects ^= CFE_BOLD; 

	m_RichCatch.SetSelectionCharFormat(Cfm);       //Set the char set
	m_RichCatch.SetFocus();
	
}


This bold-ing function works fine, but the Font size one only works when the selected text are all of the same font size.
For example, if all of the selected text are of font size 10, I selected all of them and chose Font size 20, they would all change to font size 20. But if the selected text was of differing font sizes, say the first few words were font size 10 and the rest font size 11, the code does not change the font size of any of the selelcted text.
Am I approaching the function in the wrong way? Or must I do an internal check for different font sizes and change them all separately somehow?

Please feel free to ask for more information if needed.

Thank you.
AnswerRe: SetSelectionCharFormat difficulties when selection contains different charset Pin
Stuart Dootson7-Jan-09 22:55
professionalStuart Dootson7-Jan-09 22:55 
GeneralRe: SetSelectionCharFormat difficulties when selection contains different charset Pin
JJeffrey8-Jan-09 13:16
JJeffrey8-Jan-09 13:16 
QuestionFax Application Pin
Pete Framar7-Jan-09 11:56
Pete Framar7-Jan-09 11:56 
AnswerRe: Fax Application Pin
Garth J Lancaster7-Jan-09 12:20
professionalGarth J Lancaster7-Jan-09 12:20 
AnswerRe: Fax Application Pin
Randor 7-Jan-09 12:31
professional Randor 7-Jan-09 12:31 
AnswerRe: Fax Application Pin
Hamid_RT7-Jan-09 23:41
Hamid_RT7-Jan-09 23:41 
GeneralRe: Fax Application Pin
Pete Framar4-Feb-09 11:19
Pete Framar4-Feb-09 11:19 
QuestionHow to scroll the controls within a dialog box or a window? Pin
Joseph Marzbani7-Jan-09 7:46
Joseph Marzbani7-Jan-09 7:46 
AnswerRe: How to scroll the controls within a dialog box or a window? Pin
Code-o-mat7-Jan-09 8:33
Code-o-mat7-Jan-09 8:33 
AnswerRe: How to scroll the controls within a dialog box or a window? Pin
CPallini7-Jan-09 9:30
mveCPallini7-Jan-09 9:30 
JokeRe: How to scroll the controls within a dialog box or a window? Pin
Mark Salsbery7-Jan-09 9:53
Mark Salsbery7-Jan-09 9:53 
JokeRe: How to scroll the controls within a dialog box or a window? Pin
CPallini7-Jan-09 10:08
mveCPallini7-Jan-09 10:08 
QuestionRe: How to scroll the controls within a dialog box or a window? Pin
Luc Pattyn7-Jan-09 10:44
sitebuilderLuc Pattyn7-Jan-09 10:44 
AnswerRe: How to scroll the controls within a dialog box or a window? Pin
Mark Salsbery7-Jan-09 10:59
Mark Salsbery7-Jan-09 10:59 
AnswerRe: How to scroll the controls within a dialog box or a window? Pin
Sarath C7-Jan-09 16:38
Sarath C7-Jan-09 16:38 
GeneralRe: How to scroll the controls within a dialog box or a window? Pin
Joseph Marzbani7-Jan-09 18:50
Joseph Marzbani7-Jan-09 18:50 
QuestionHow to save the content of an "Rich Edit Control" As IT IS? Pin
Joseph Marzbani7-Jan-09 7:15
Joseph Marzbani7-Jan-09 7:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.