   Problem with SCF_ASSOCIATEFONT
  Hi,I want to override the default font for each script in rich edit. I'm having a problem with EM_SETCHARFORMAT. It returns 0 instead of non-zero (success). In the character format, I'm setting the following fields :yHeight, szFaceName, bCharSet ( to DEFAULT_CHARSET for testing purpose ) and bPitchAndFamily ( to DEFAULT_PITCH|FF_DONTCARE for testing ).The default font doesn't get set. Find any error?Thanks,M   
  From my own code (Subclassed RichEdit control, assumes fixed pitch font):void CDruinkEdit::SetFont(const std::string& strFont, int nSize){// Setup char formatCHARFORMAT cfFormat;memset(&cfFormat, 0, sizeof(cfFormat));cfFormat.cbSize = sizeof(cfFormat);cfFormat.dwMask = CFM_CHARSET | CFM_FACE | CFM_SIZE;cfFormat.bCharSet = ANSI_CHARSET;cfFormat.bPitchAndFamily = FIXED_PITCH | FF_DONTCARE;cfFormat.yHeight = (nSize*1440)/72;strcpy(cfFormat.szFaceName, strFont.c_str());// Set char format and goto end of textCHARRANGE cr;cr.cpMin = INT_MAX;cr.cpMax = INT_MAX;SendMessage(m_hWnd, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cfFormat);SendMessage(m_hWnd, EM_EXSETSEL, 0, (LPARAM)&cr);}Does that work?   ;  Hi,Nope. It doesn't. I'm trying to set it to Arial Black. The text comes in Segoe UI. I guess it is getting overridden somewhere. When all does TxSendMessage return an lresult of 0?M   ;Quote:Original post by HellzGodHi,Nope. It doesn't. I'm trying to set it to Arial Black. The text comes in Segoe UI. I guess it is getting overridden somewhere. When all does TxSendMessage return an lresult of 0?MI'm guessing "Segoe UI" is the closest match the system can find, given the parameters you specified. What if you use DEFAULT_PITCH instead of FIXED_PITCH?SendMessage() returns whatever the window proc returns, which depends on the message sent. From the Docs: "If the operation fails, the return value is zero". You could try using GetLastError() to see if it's set at all (Call SetLastError(0); first to make sure there's no old error message left in the buffer), and then plug that into the error lookup tool.   ;  Hi,I should have mentioned- already tried GetLastError. This returns 0 for me. I tried setting FIXED_PITCH. That didn't work either. And there is no over writing by mistake. EM_SETCHARFORMAT gets called exactly once. So it cud not be coz of some other call's effects.-M   ;  Found the problem. I was not setting the cbSize value of rich edit.-M   