<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Schriftart in RichEditControl lässt sich nicht ändern!]]></title><description><![CDATA[<p>Hallo,<br />
ich versuche die Schriftart in einem RichEditControl zu ändern. Ich weiß nicht, warum das nicht klappt:</p>
<pre><code class="language-cpp">CHARFORMAT chfmt ={0};
CHOOSEFONT cf = {0};
HFONT hfont; 
//...
ChooseFont(&amp;cf);
hfont = CreateFontIndirect( cf.lpLogFont );
// Bis hier ok, member von cf haben Inhalt bekommen, wenn Schrift gewählt und hfont != NULL.
chfmt.cbSize = sizeof(CHARFORMAT); 
			chfmt.dwMask = CFM_FACE|CFM_CHARSET|CFM_SIZE; 
			chfmt.bPitchAndFamily = lf.lfPitchAndFamily;
			chfmt.bCharSet = lf.lfCharSet;
			chfmt.dwEffects = CFE_AUTOCOLOR; 
			chfmt.yHeight = lf.lfHeight;
			strcpy(chfmt.szFaceName, lf.lfFaceName);
SendMessage( hTop, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &amp;chfmt);
//...
</code></pre>
<p>Der Rückgabewert von SendMessage und von GetLastError ist 0.<br />
Was mache ich falsch?<br />
Eine Webseite mit einem funktionierenden Beispiel habe ich leider auch nicht finden können.<br />
Gruß,<br />
mr. problem</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/234703/schriftart-in-richeditcontrol-lässt-sich-nicht-ändern</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Apr 2026 14:42:38 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/234703.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 21 Feb 2009 10:50:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Schriftart in RichEditControl lässt sich nicht ändern! on Sat, 21 Feb 2009 10:50:47 GMT]]></title><description><![CDATA[<p>Hallo,<br />
ich versuche die Schriftart in einem RichEditControl zu ändern. Ich weiß nicht, warum das nicht klappt:</p>
<pre><code class="language-cpp">CHARFORMAT chfmt ={0};
CHOOSEFONT cf = {0};
HFONT hfont; 
//...
ChooseFont(&amp;cf);
hfont = CreateFontIndirect( cf.lpLogFont );
// Bis hier ok, member von cf haben Inhalt bekommen, wenn Schrift gewählt und hfont != NULL.
chfmt.cbSize = sizeof(CHARFORMAT); 
			chfmt.dwMask = CFM_FACE|CFM_CHARSET|CFM_SIZE; 
			chfmt.bPitchAndFamily = lf.lfPitchAndFamily;
			chfmt.bCharSet = lf.lfCharSet;
			chfmt.dwEffects = CFE_AUTOCOLOR; 
			chfmt.yHeight = lf.lfHeight;
			strcpy(chfmt.szFaceName, lf.lfFaceName);
SendMessage( hTop, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &amp;chfmt);
//...
</code></pre>
<p>Der Rückgabewert von SendMessage und von GetLastError ist 0.<br />
Was mache ich falsch?<br />
Eine Webseite mit einem funktionierenden Beispiel habe ich leider auch nicht finden können.<br />
Gruß,<br />
mr. problem</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1667484</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1667484</guid><dc:creator><![CDATA[mr. problem]]></dc:creator><pubDate>Sat, 21 Feb 2009 10:50:47 GMT</pubDate></item><item><title><![CDATA[Reply to Schriftart in RichEditControl lässt sich nicht ändern! on Sat, 21 Feb 2009 10:55:05 GMT]]></title><description><![CDATA[<p>Du musst <strong>cf</strong> erstmal mit Werten füllen, danach kann CreateFontIndirect erst einen Handle zu einer Schriftart liefern die ungefähr oder genau der Schriftart entspricht, die du in <strong>cf</strong> angegeben hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1667486</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1667486</guid><dc:creator><![CDATA[*Helmut*]]></dc:creator><pubDate>Sat, 21 Feb 2009 10:55:05 GMT</pubDate></item><item><title><![CDATA[Reply to Schriftart in RichEditControl lässt sich nicht ändern! on Sat, 21 Feb 2009 11:08:16 GMT]]></title><description><![CDATA[<p><em>Helmut</em> schrieb:</p>
<blockquote>
<p>Du musst <strong>cf</strong> erstmal mit Werten füllen, danach kann CreateFontIndirect erst einen Handle zu einer Schriftart liefern die ungefähr oder genau der Schriftart entspricht, die du in <strong>cf</strong> angegeben hast.</p>
</blockquote>
<p>cf ist doch mit Werten gefüllt, wenn man eine Schrift im Dialog gewählt hat.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1667492</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1667492</guid><dc:creator><![CDATA[mr. problem]]></dc:creator><pubDate>Sat, 21 Feb 2009 11:08:16 GMT</pubDate></item><item><title><![CDATA[Reply to Schriftart in RichEditControl lässt sich nicht ändern! on Sat, 21 Feb 2009 11:09:17 GMT]]></title><description><![CDATA[<p>p.s.<br />
siehe auch kommentar in zeile 7.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1667493</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1667493</guid><dc:creator><![CDATA[mr. problem]]></dc:creator><pubDate>Sat, 21 Feb 2009 11:09:17 GMT</pubDate></item><item><title><![CDATA[Reply to Schriftart in RichEditControl lässt sich nicht ändern! on Sat, 21 Feb 2009 13:32:14 GMT]]></title><description><![CDATA[<p>Win32 FAQ,<br />
siehe in der fortgeschrittenen Gruppe win32<br />
news://nntp.aioe.org/comp.os.ms-windows.programmer.win32</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1667541</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1667541</guid><dc:creator><![CDATA[fred100]]></dc:creator><pubDate>Sat, 21 Feb 2009 13:32:14 GMT</pubDate></item><item><title><![CDATA[Reply to Schriftart in RichEditControl lässt sich nicht ändern! on Sat, 21 Feb 2009 14:31:36 GMT]]></title><description><![CDATA[<p>fred100 schrieb:</p>
<blockquote>
<p>Win32 FAQ,<br />
siehe in der fortgeschrittenen Gruppe win32<br />
news://nntp.aioe.org/comp.os.ms-windows.programmer.win32</p>
</blockquote>
<p>da kann ich auch nichts anderes finden, als was ich schon gemacht habe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1667567</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1667567</guid><dc:creator><![CDATA[mr. problem]]></dc:creator><pubDate>Sat, 21 Feb 2009 14:31:36 GMT</pubDate></item><item><title><![CDATA[Reply to Schriftart in RichEditControl lässt sich nicht ändern! on Sat, 21 Feb 2009 14:46:14 GMT]]></title><description><![CDATA[<p>ich poste jetzt einfach mal das komplette programm. vielleicht hat ja jemand lust und zeit es durch seinen compiler zu jagen und mir meinen fehler zu zeigen.</p>
<p>es ist ein einfaches fenster mit zwei RichEditControl.<br />
wenn das programm gestartet ist, erscheint der FontDialog, nachdem man die Taste 'a' gedrückt hat. Dann soll es möglich sein, dem oberen RichEdit eine Schriftart zuzuweisen.</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;richedit.h&gt;
#include &lt;tchar.h&gt;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

LPCSTR lpszAppName = &quot;AppName&quot;;
LPCSTR lpszTitle   = &quot;Meine erste Applikation&quot;;
HWND hTop = NULL, hBottom = NULL;
CHOOSEFONT cf = {0};
LOGFONT lf = {0};
int border=3;

void ErrExit ( TCHAR* msg )
{
	if (msg)
		MessageBox ( NULL, msg, &quot;Error&quot;, MB_OK );
	exit(1);
}

void InitFontStruct ()
{
	 // Initialisation
   cf.lStructSize	= sizeof( CHOOSEFONT );
   cf.lpLogFont = &amp;lf;
   cf.Flags	= CF_EFFECTS | CF_BOTH |  CF_INITTOLOGFONTSTRUCT ;	// If not set, no dialog appears ! :-(

}

int APIENTRY WinMain(HINSTANCE hInstance,
           HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{

   HWND       hWnd;
   MSG        msg;
   WNDCLASSEX   wc;

   wc.cbSize        =  sizeof(WNDCLASSEX);
   wc.style         =  CS_HREDRAW | CS_VREDRAW;
   wc.lpfnWndProc   =  WndProc;
   wc.cbClsExtra    =  0;
   wc.cbWndExtra    =  0;
   wc.hInstance     =  hInstance;
   wc.hCursor       =  LoadCursor(NULL,IDC_ARROW);
   wc.hIcon         =  LoadIcon(NULL, IDI_APPLICATION);
   wc.hbrBackground =  (HBRUSH)GetStockObject(WHITE_BRUSH);
   wc.lpszClassName =  lpszAppName;
   wc.lpszMenuName  =  lpszAppName;//MAKEINTRESOURCE(IDR_MENU1);
   wc.hIconSm       =  LoadIcon(NULL, IDI_APPLICATION);

   if( RegisterClassEx(&amp;wc) == 0)
      return 0;

   hWnd = CreateWindowEx(NULL,
                         lpszAppName,
                         lpszTitle,
                         WS_OVERLAPPEDWINDOW,
                         0,
                         0,
                         CW_USEDEFAULT,
                         CW_USEDEFAULT,
                         NULL,
                         NULL,
                         hInstance,
                         NULL);

   if( hWnd == NULL)
      return 0;

   InitFontStruct ();

   ShowWindow(hWnd, iCmdShow);
   UpdateWindow(hWnd);

   while (GetMessage(&amp;msg, NULL, 0, 0) &gt; 0)
   {
      TranslateMessage(&amp;msg);
      DispatchMessage(&amp;msg);
   }
   return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hWnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
	TCHAR  tbuf[256];
    static RECT r;
	int mouse_y_prev=-1,mouse_y_now=0;
   GetClientRect (hWnd,&amp;r);

   switch (umsg)
   { 
	   	case WM_CHAR:
		{
			switch(wParam)
			{	
	 			HFONT hfont; 
			 	CHARFORMAT chfmt ={0};

				/*
				LRESULT lres = SendMessage(hTop, EM_GETLANGOPTIONS, 0, 0);
				lres &amp;= ~IMF_AUTOFONT;
				SendMessage(hTop, EM_SETLANGOPTIONS, 0, lres);
				*/

				case 'a':

					ChooseFont(&amp;cf);
					if ( *cf.lpLogFont-&gt;lfFaceName == 0 ) // Keine Schrift gewählt.
						break;

					if ( NULL == ( hfont = CreateFontIndirect( cf.lpLogFont ))) // Create the chosen font.
							ErrExit( &quot;CreateFontIndirect failed.&quot; );

			chfmt.cbSize = sizeof(CHARFORMAT); 
			chfmt.dwMask = CFM_FACE|CFM_CHARSET|CFM_SIZE; 
			chfmt.bPitchAndFamily = lf.lfPitchAndFamily;
			chfmt.bCharSet = lf.lfCharSet;
			chfmt.yHeight = lf.lfHeight;
			_tcscpy (chfmt.szFaceName, lf.lfFaceName);

			if ( 0 == SendMessage( hTop, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &amp;chfmt))
			{
				_stprintf(tbuf,&quot;Can't set font %s. LastError: %d\n&quot;, lf.lfFaceName, GetLastError());
				ErrExit(tbuf);
			}

			} // 	switch(wParam)
			return 0;
		} // 	case WM_CHAR:

		case WM_LBUTTONDOWN:
		{
			mouse_y_prev = HIWORD(lParam);
			// HIWORD(lParam) +3 &gt; topRect.bottom )
		 //	MessageBox(hWnd,&quot;KLICK 1&quot;, NULL, MB_OK );
			return 0;

		}

		case WM_MOUSEMOVE:
		{
			mouse_y_now = HIWORD(lParam);
			 if (wParam==MK_LBUTTON){
 		//	 MessageBox(NULL,&quot;KLICK 2&quot;, NULL, MB_OK );

				MoveWindow( hTop, 0, 0, r.right, mouse_y_now-border, 1 );
				MoveWindow( hBottom,0, mouse_y_now+border, r.right, r.bottom-mouse_y_now, 1 );

			//	SetWindowPos( hTop, hWnd, 0, 0, r.right, mouse_y_now-border, SWP_SHOWWINDOW );
			//	SetWindowPos( hBottom,hWnd, 0, mouse_y_now+border, r.right, r.bottom-mouse_y_now, SWP_SHOWWINDOW );

			}

			mouse_y_prev = -1;
			// HIWORD(lParam) +3 &gt; topRect.bottom )
			//	MessageBox(NULL,&quot;KLICK&quot;, NULL, MB_OK );

			return 0;

		}

   	  case WM_CREATE:
      {  
		  hTop = CreateWindowExW(WS_EX_CLIENTEDGE,
                                   L&quot;edit&quot;,
                                  L&quot;Top&quot;,    // &lt;- das ist der Inhalt der Editfelds
                                   WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE |
                                              ES_AUTOVSCROLL,
                                   0, 0, r.right, r.bottom/2-border,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);

		  hBottom = CreateWindowExW(WS_EX_CLIENTEDGE,
                                   L&quot;edit&quot;,
                                   L&quot;Bottom&quot;,    // &lt;- das ist der Inhalt der Editfelds
                                   WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE |
                                              ES_AUTOVSCROLL,
                                   0, r.bottom/2+border, r.right, r.bottom/2,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);

		  if ( hBottom==NULL||hTop==NULL )
			ErrExit ( &quot;CreateWindowExW failed.&quot; );
		 return 0;
      }

	  case WM_SIZE:
      {
			MoveWindow( hTop, 0, 0, r.right, r.bottom/2-border, 1 );
			MoveWindow( hBottom,0, r.bottom/2+border, r.right, r.bottom/2, 1 );

         return 0;
      }

	  case WM_DESTROY:
      {
         PostQuitMessage(0);
         return 0;
      }
   } //  switch (umsg)
   return DefWindowProc(hWnd, umsg, wParam, lParam);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1667581</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1667581</guid><dc:creator><![CDATA[mr.problem]]></dc:creator><pubDate>Sat, 21 Feb 2009 14:46:14 GMT</pubDate></item><item><title><![CDATA[Reply to Schriftart in RichEditControl lässt sich nicht ändern! on Sun, 22 Feb 2009 11:17:28 GMT]]></title><description><![CDATA[<p>Hat sich erledigt, danke.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1667956</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1667956</guid><dc:creator><![CDATA[mr. problem]]></dc:creator><pubDate>Sun, 22 Feb 2009 11:17:28 GMT</pubDate></item></channel></rss>