<?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[Fonts]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte ein Ausgabetext in einem bestimmten Font dargestellt haben in weiss auf<br />
schwarzen Hintergrund.</p>
<p>Auf der Seite : <a href="http://www.winprog.net/tutorial/fonts.html" rel="nofollow">http://www.winprog.net/tutorial/fonts.html</a><br />
wird beschrieben wie Fonts geladen werden. Der Variable vom Typ HDC wird die<br />
Funktion &quot;GetDC(NULL);&quot; zugewiesen.</p>
<p>Wie ist dann eine Ausgabe möglich wenn bereits die BeginPaint()-Funktion für<br />
HDC genutzt wird ? (Zeile 85 und 86)</p>
<pre><code class="language-cpp">// include the basic windows header file
#include &lt;windows.h&gt;
#include &lt;windowsx.h&gt;

// the WindowProc function prototype
LRESULT CALLBACK WindowProc(HWND hWnd,
                         UINT message,
                         WPARAM wParam,
                         LPARAM lParam);

// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
    // the handle for the window, filled by a function
    HWND hWnd;
    // this struct holds information for the window class
    WNDCLASSEX wc;

    // clear out the window class for use
    ZeroMemory(&amp;wc, sizeof(WNDCLASSEX));

    // fill in the struct with the needed information
    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = (WNDPROC)WindowProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
    wc.lpszClassName = L&quot;WindowClass1&quot;;

    // register the window class
    RegisterClassEx(&amp;wc);

    // create the window and use the result as the handle
    hWnd = CreateWindowEx(NULL,
                          L&quot;WindowClass1&quot;,    // name of the window class
                          L&quot;Our First Windowed Program&quot;,   // title of the window
                          WS_OVERLAPPEDWINDOW,    // window style
                          300,    // x-position of the window
                          300,    // y-position of the window
                          500,    // width of the window
                          400,    // height of the window
                          NULL,    // we have no parent window, NULL
                          NULL,    // we aren't using menus, NULL
                          hInstance,    // application handle
                          NULL);    // used with multiple windows, NULL

    // display the window on the screen
    ShowWindow(hWnd, nCmdShow);

    // enter the main loop:

    // this struct holds Windows event messages
    MSG msg;

    // wait for the next message in the queue, store the result in 'msg'
    while(GetMessage(&amp;msg, NULL, 0, 0))
    {
        // translate keystroke messages into the right format
        TranslateMessage(&amp;msg);

        // send the message to the WindowProc function
        DispatchMessage(&amp;msg);
    }

    // return this part of the WM_QUIT message to Windows
    return msg.wParam;
}

// this is the main message handler for the program
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

    // sort through and find what code to run for the message given
    switch(message)
    {
		case WM_PAINT:
		{
		const wchar_t  szText[] = L&quot;Dies ist der Text.\n&quot;; //const char [20]
		PAINTSTRUCT ps;
		HDC         hDC;
		hDC = BeginPaint(hWnd, &amp;ps);
		TextOut(hDC, 50, 50,szText , sizeof(szText) - 22);
		EndPaint(hWnd, &amp;ps);
		return 0;		
		}

		case WM_LBUTTONDOWN:
        {
			//exe-Datei-Pfadanzeige
            char szFileName[MAX_PATH];
            HINSTANCE hInstance = GetModuleHandle(NULL);

            GetModuleFileName(hInstance, (LPWCH)szFileName, MAX_PATH);
            MessageBox(hWnd, (LPCWSTR)szFileName, L&quot;This program is:&quot;, MB_OK | MB_ICONINFORMATION);
        }

        // this message is read when the window is closed
        case WM_DESTROY:
            {
                // close the application entirely
                PostQuitMessage(0);
                return 0;
            } break;
    }

    // Handle any messages the switch statement didn't
    return DefWindowProc (hWnd, message, wParam, lParam);
}
</code></pre>
<p>VIELEN DANK im Voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/237964/fonts</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 05:39:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/237964.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 04 Apr 2009 10:26:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Fonts on Sat, 04 Apr 2009 10:26:00 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich möchte ein Ausgabetext in einem bestimmten Font dargestellt haben in weiss auf<br />
schwarzen Hintergrund.</p>
<p>Auf der Seite : <a href="http://www.winprog.net/tutorial/fonts.html" rel="nofollow">http://www.winprog.net/tutorial/fonts.html</a><br />
wird beschrieben wie Fonts geladen werden. Der Variable vom Typ HDC wird die<br />
Funktion &quot;GetDC(NULL);&quot; zugewiesen.</p>
<p>Wie ist dann eine Ausgabe möglich wenn bereits die BeginPaint()-Funktion für<br />
HDC genutzt wird ? (Zeile 85 und 86)</p>
<pre><code class="language-cpp">// include the basic windows header file
#include &lt;windows.h&gt;
#include &lt;windowsx.h&gt;

// the WindowProc function prototype
LRESULT CALLBACK WindowProc(HWND hWnd,
                         UINT message,
                         WPARAM wParam,
                         LPARAM lParam);

// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
    // the handle for the window, filled by a function
    HWND hWnd;
    // this struct holds information for the window class
    WNDCLASSEX wc;

    // clear out the window class for use
    ZeroMemory(&amp;wc, sizeof(WNDCLASSEX));

    // fill in the struct with the needed information
    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = (WNDPROC)WindowProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
    wc.lpszClassName = L&quot;WindowClass1&quot;;

    // register the window class
    RegisterClassEx(&amp;wc);

    // create the window and use the result as the handle
    hWnd = CreateWindowEx(NULL,
                          L&quot;WindowClass1&quot;,    // name of the window class
                          L&quot;Our First Windowed Program&quot;,   // title of the window
                          WS_OVERLAPPEDWINDOW,    // window style
                          300,    // x-position of the window
                          300,    // y-position of the window
                          500,    // width of the window
                          400,    // height of the window
                          NULL,    // we have no parent window, NULL
                          NULL,    // we aren't using menus, NULL
                          hInstance,    // application handle
                          NULL);    // used with multiple windows, NULL

    // display the window on the screen
    ShowWindow(hWnd, nCmdShow);

    // enter the main loop:

    // this struct holds Windows event messages
    MSG msg;

    // wait for the next message in the queue, store the result in 'msg'
    while(GetMessage(&amp;msg, NULL, 0, 0))
    {
        // translate keystroke messages into the right format
        TranslateMessage(&amp;msg);

        // send the message to the WindowProc function
        DispatchMessage(&amp;msg);
    }

    // return this part of the WM_QUIT message to Windows
    return msg.wParam;
}

// this is the main message handler for the program
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{

    // sort through and find what code to run for the message given
    switch(message)
    {
		case WM_PAINT:
		{
		const wchar_t  szText[] = L&quot;Dies ist der Text.\n&quot;; //const char [20]
		PAINTSTRUCT ps;
		HDC         hDC;
		hDC = BeginPaint(hWnd, &amp;ps);
		TextOut(hDC, 50, 50,szText , sizeof(szText) - 22);
		EndPaint(hWnd, &amp;ps);
		return 0;		
		}

		case WM_LBUTTONDOWN:
        {
			//exe-Datei-Pfadanzeige
            char szFileName[MAX_PATH];
            HINSTANCE hInstance = GetModuleHandle(NULL);

            GetModuleFileName(hInstance, (LPWCH)szFileName, MAX_PATH);
            MessageBox(hWnd, (LPCWSTR)szFileName, L&quot;This program is:&quot;, MB_OK | MB_ICONINFORMATION);
        }

        // this message is read when the window is closed
        case WM_DESTROY:
            {
                // close the application entirely
                PostQuitMessage(0);
                return 0;
            } break;
    }

    // Handle any messages the switch statement didn't
    return DefWindowProc (hWnd, message, wParam, lParam);
}
</code></pre>
<p>VIELEN DANK im Voraus</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1690757</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1690757</guid><dc:creator><![CDATA[Consideration]]></dc:creator><pubDate>Sat, 04 Apr 2009 10:26:00 GMT</pubDate></item><item><title><![CDATA[Reply to Fonts on Sat, 04 Apr 2009 10:43:02 GMT]]></title><description><![CDATA[<p>Consideration schrieb:</p>
<blockquote>
<p>Auf der Seite : <a href="http://www.winprog.net/tutorial/fonts.html" rel="nofollow">http://www.winprog.net/tutorial/fonts.html</a><br />
wird beschrieben wie Fonts geladen werden. Der Variable vom Typ HDC wird die<br />
Funktion &quot;GetDC(NULL);&quot; zugewiesen.</p>
</blockquote>
<p>Nene <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /> Guck dir den Artikel nochmal an, <code>GetDC(NULL)</code> wird nur verwendet, um die &quot;Auflösung&quot; des Desktop-DCs zu bestimmen (und damit afaik die Auflösung aller DCs). Mit der &quot;Auflösung&quot; wird dann die Schriftgröße berechnet und das Schrift-Objekt erstellt. Das alles hat noch nichts mit zeichnen zu tun!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1690770</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1690770</guid><dc:creator><![CDATA[Badestrand]]></dc:creator><pubDate>Sat, 04 Apr 2009 10:43:02 GMT</pubDate></item><item><title><![CDATA[Reply to Fonts on Sat, 04 Apr 2009 17:22:45 GMT]]></title><description><![CDATA[<p>Also ich würde den Font schon mal beim Erstellen des Fensters setzten (WM_CREATE abfangen).</p>
<p>hier mal eine Funktion um farbigen Text auszugeben, so könnte es aussehen:</p>
<pre><code class="language-cpp">/*
==============================================
WinApi_DrawText

gibt einen Text aus
==============================================
*/
void WinApi_DrawText(HDC hDC, RECT rc, int x, int y, char *Text, int Textlen, COLORREF cText, COLORREF cTextBk){

	HBRUSH		hBrush;
	COLORREF		oldcText, oldcTextBk;

	hBrush = CreateSolidBrush(cTextBk);
	FillRect(hDC, &amp;rc, hBrush);
	DeleteObject(hBrush);
	oldcText = SetTextColor(hDC, cText);
	oldcTextBk = SetBkColor(hDC, cTextBk);
	rc.left += x;
	rc.top += y;
	DrawText(hDC, Text, -1, &amp;rc, DT_SINGLELINE);
	SetTextColor(hDC, oldcText);
	SetBkColor(hDC, oldcTextBk);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1690962</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1690962</guid><dc:creator><![CDATA[*guggstdu*]]></dc:creator><pubDate>Sat, 04 Apr 2009 17:22:45 GMT</pubDate></item></channel></rss>