Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I need to insert 2 different kinds of fonts onto the text in a single edit box..
But as a beginner i could able to set only one kind of font to the text in the edit box i have attached my code below please help me modify..!!
void CTrail3Dlg::OnBnClickedButton1()
{
	UpdateData(TRUE);
	CFontDialog dlg;
	// get font for current dialog, just to fill in LOGFONT
	LOGFONT lf;
	CFont *pFont = GetFont();
	pFont->GetLogFont(&lf);
 
	if (dlg.DoModal()== IDOK)
	{
		dlg.GetCurrentFont(&lf);
		m_font.DeleteObject();
		m_font.CreateFontIndirect(&lf);
		GetDlgItem(IDC_EDIT1)->SetFont(&m_font);
         }
}
Posted 9-Aug-12 21:29pm
Comments
Wes Aday at 10-Aug-12 7:37am
   
As you have already been told for this question, you can't. You can only use one font in a standard text box.
AspDotNetDev at 13-Aug-12 19:40pm
   
I don't know much about the environment you are using, but is there such a thing as a rich text box? If not, then I'm afraid you probably can't use two different fonts in a single standard textbox.
Sharath2790 at 16-Aug-12 1:10am
   
I'm using rich edit control! but i'm unable use it with the multiple edit boxes!!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

This can't be done. Stop asking.
  Permalink  
Comments
Christian Graus at 17-Aug-12 3:59am
   
You have asked this over and over. I was a Microsoft MVP in C++/MFC for several years, a fact I don't like to bring up for fear of sounding like I am boasting, but, I sure as hell know how to program windows in C++, and what a text box can and cannot do. A rich text box has fonts, a text box only has one font, ever. As a beginner, C++ is a dumb thing to learn, people use C# nowadays, it's more powerful for Windows at least, and easier to use.
Espen Harlinn at 17-Aug-12 4:27am
   
>> As a beginner, C++ is a dumb
It may seem harder, but you usually end up as a better developer - or, if you can't do it, find an other line of work.
Christian Graus at 17-Aug-12 4:36am
   
I love C++. But do you think the guy who had to be told several times that a text box is not multi font and then abused me for telling the truth, is going to do better learning something harder ?
Espen Harlinn at 17-Aug-12 4:47am
   
>> is going to do better learning something harder ?
My point exactly, I'm sure you've found that there really is a large number of people in this business that should pick another line of work :-D
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

You've received some answers on that, you can't, using MFC, put two different fonts at the same time in the same CEdit so it has no sense that you continue asking that, you could:
 
A) Try to follow people's advice:
A.1) use a rich edit control instead of a CEdit.
A.2) create a derived and owner-drawn CEdit on your own (I pointed you to several resources in your last question).
 
B) Stop asking the same question in the same way, who knows, probably:
B.1) we don't understand what you are asking so asking it in the same way is a bad approach.
B.2) you don't understand what we are saying so asking it again and again won't help. In this case you should try to understand it, read books, get information, ask us about a more detailed information on a specific issue...
 
You should know that CP is a great community that likes to help, it is plenty of people like Christian Graus who currently is the one who stands the major reputation points here in CP, and others who like to help. Telling somebody like him that has not worked on that platform... well it is completely wrong... so we all have got bad days and problems, so we are understanding almost everything, but please, before being fired of CP (which would be a pity) try to get what you need: either it is A or B (previous options given) I'm sure you'll find a way to get your job done.
 
Good luck, and be cool...
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 354
1 Richard MacCutchan 310
2 OriginalGriff 275
3 Vinay Mistry 163
4 Jared Sanow 145
0 Sergey Alexandrovich Kryukov 5,939
1 OriginalGriff 4,885
2 CPallini 2,473
3 Abhinav S 1,507
4 Richard MacCutchan 1,437


Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 17 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100