Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
1.00/5 (1 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
Comments
[no name] 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 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 16-Aug-12 1:10am    
I'm using rich edit control! but i'm unable use it with the multiple edit boxes!!

This can't be done. Stop asking.
 
Share this answer
 
Comments
Christian Graus 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 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 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 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
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...
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900