<?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[Vierecke, Kreise ...]]></title><description><![CDATA[<p>Hi @ All.</p>
<p>ich wollte jetzt ein Viereck/Kreis... (is egal) zeichnen.</p>
<pre><code class="language-cpp">Rectangle(hdc,left,top,right,bottom)
</code></pre>
<p>so. wie kann ich die Farbe bestimmen?</p>
<p>und wie kann ich die maximale breite/höhe (pixeln) des bildschirm s ermitteln?</p>
<p>mein code: (funktioniert nicht.)</p>
<pre><code class="language-cpp">// At first define for including the windows headers
#define _WIN32_WINNT 0x0500
#include &lt;windows.h&gt;

// C RunTime Header Files
#include &lt;stdlib.h&gt;
#include &lt;malloc.h&gt;
#include &lt;memory.h&gt;
#include &lt;tchar.h&gt;

// Local Header Files

#include &lt;commdlg.h&gt;
#include &lt;ocidl.h&gt;
#include &lt;olectl.h&gt;
#include &lt;crtdbg.h&gt;

// The Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	switch (msg)
	{
	case WM_CREATE:
		break;
	case WM_PAINT:
		hdc = GetDC(hwnd);
		Rectangle(hdc,0,0,500,500);
		break;
	case WM_CLOSE:
		DestroyWindow(hwnd);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
					LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASSEX wc;
	HWND hwnd;
	MSG Msg;
	static char appName[] = &quot;Your Application&quot;;

	// Registering the Window Class
	wc.cbSize		 = sizeof(WNDCLASSEX);
	wc.style		 = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc	 = WndProc;
	wc.cbClsExtra	 = 0;
	wc.cbWndExtra	 = 0;
	wc.hInstance	 = hInstance;
	wc.hIcon		 = LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = appName;
	wc.hIconSm		 = LoadIcon(NULL, IDI_APPLICATION);

	if (!RegisterClassEx(&amp;wc))
	{
		MessageBox(NULL, &quot;Window Registration Failed!&quot;, &quot;Error!&quot;,
			MB_ICONERROR | MB_OK);
		return 0;
	}
	// Creating the Window
	hwnd = CreateWindowEx(
		WS_EX_CLIENTEDGE | WS_EX_LAYERED,
		appName,
		&quot;Your Window Title&quot;,
		WS_BORDER,
		CW_USEDEFAULT, CW_USEDEFAULT, 400, 400,
		NULL, NULL, hInstance, NULL);

	if (hwnd == NULL)
	{
		MessageBox(NULL, &quot;Window Creation Failed!&quot;, &quot;Error&quot;,
			MB_ICONERROR | MB_OK);
		return 0;
	}

	ShowWindow(hwnd, nCmdShow);

	UpdateWindow(hwnd);

	// The Message Loop
	while (GetMessage(&amp;Msg, NULL, 0, 0) &gt; 0)
	{
		TranslateMessage(&amp;Msg);
		DispatchMessage(&amp;Msg);
	}
	return int(Msg.wParam);
}
</code></pre>
<p>danke..</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/188262/vierecke-kreise</link><generator>RSS for Node</generator><lastBuildDate>Fri, 03 Jul 2026 18:29:48 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/188262.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 29 Jul 2007 18:44:45 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Vierecke, Kreise ... on Sun, 29 Jul 2007 18:51:15 GMT]]></title><description><![CDATA[<p>Hi @ All.</p>
<p>ich wollte jetzt ein Viereck/Kreis... (is egal) zeichnen.</p>
<pre><code class="language-cpp">Rectangle(hdc,left,top,right,bottom)
</code></pre>
<p>so. wie kann ich die Farbe bestimmen?</p>
<p>und wie kann ich die maximale breite/höhe (pixeln) des bildschirm s ermitteln?</p>
<p>mein code: (funktioniert nicht.)</p>
<pre><code class="language-cpp">// At first define for including the windows headers
#define _WIN32_WINNT 0x0500
#include &lt;windows.h&gt;

// C RunTime Header Files
#include &lt;stdlib.h&gt;
#include &lt;malloc.h&gt;
#include &lt;memory.h&gt;
#include &lt;tchar.h&gt;

// Local Header Files

#include &lt;commdlg.h&gt;
#include &lt;ocidl.h&gt;
#include &lt;olectl.h&gt;
#include &lt;crtdbg.h&gt;

// The Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	HDC hdc;
	switch (msg)
	{
	case WM_CREATE:
		break;
	case WM_PAINT:
		hdc = GetDC(hwnd);
		Rectangle(hdc,0,0,500,500);
		break;
	case WM_CLOSE:
		DestroyWindow(hwnd);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hwnd, msg, wParam, lParam);
	}
	return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
					LPSTR lpCmdLine, int nCmdShow)
{
	WNDCLASSEX wc;
	HWND hwnd;
	MSG Msg;
	static char appName[] = &quot;Your Application&quot;;

	// Registering the Window Class
	wc.cbSize		 = sizeof(WNDCLASSEX);
	wc.style		 = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc	 = WndProc;
	wc.cbClsExtra	 = 0;
	wc.cbWndExtra	 = 0;
	wc.hInstance	 = hInstance;
	wc.hIcon		 = LoadIcon(NULL, IDI_APPLICATION);
	wc.hCursor		 = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wc.lpszMenuName  = NULL;
	wc.lpszClassName = appName;
	wc.hIconSm		 = LoadIcon(NULL, IDI_APPLICATION);

	if (!RegisterClassEx(&amp;wc))
	{
		MessageBox(NULL, &quot;Window Registration Failed!&quot;, &quot;Error!&quot;,
			MB_ICONERROR | MB_OK);
		return 0;
	}
	// Creating the Window
	hwnd = CreateWindowEx(
		WS_EX_CLIENTEDGE | WS_EX_LAYERED,
		appName,
		&quot;Your Window Title&quot;,
		WS_BORDER,
		CW_USEDEFAULT, CW_USEDEFAULT, 400, 400,
		NULL, NULL, hInstance, NULL);

	if (hwnd == NULL)
	{
		MessageBox(NULL, &quot;Window Creation Failed!&quot;, &quot;Error&quot;,
			MB_ICONERROR | MB_OK);
		return 0;
	}

	ShowWindow(hwnd, nCmdShow);

	UpdateWindow(hwnd);

	// The Message Loop
	while (GetMessage(&amp;Msg, NULL, 0, 0) &gt; 0)
	{
		TranslateMessage(&amp;Msg);
		DispatchMessage(&amp;Msg);
	}
	return int(Msg.wParam);
}
</code></pre>
<p>danke..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1334526</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334526</guid><dc:creator><![CDATA[Script-Styler]]></dc:creator><pubDate>Sun, 29 Jul 2007 18:51:15 GMT</pubDate></item><item><title><![CDATA[Reply to Vierecke, Kreise ... on Sun, 29 Jul 2007 19:44:47 GMT]]></title><description><![CDATA[<p>Script-Styler schrieb:</p>
<blockquote>
<p>so. wie kann ich die Farbe bestimmen?</p>
</blockquote>
<p>bestimmen oder vielmehr die zu zeichnende Farbe festlegen?</p>
<pre><code class="language-cpp">SelectObject(hdc, hpen);
SelectObject(hdc, hbrush);
Rectangle(...);
</code></pre>
<p>Script-Styler schrieb:</p>
<blockquote>
<p>und wie kann ich die maximale breite/höhe (pixeln) des bildschirm s ermitteln?</p>
</blockquote>
<p>So wie es in deinem Code aussieht, meinst du sicherlich die Dimensionen des Clientbereichs des Fensters</p>
<pre><code class="language-cpp">GetClientRect(hwnd, &amp;rc);
</code></pre>
<p>Beispiel:</p>
<pre><code class="language-cpp">case WM_PAINT:
  RECT rc;
  PAINTSTRUCT ps;
  HDC hdc;
  HPEN hpen;
  HBRUSH hbrush;
  GetClientRect(hwnd, &amp;rc);
  hdc = BeginPaint(hwnd, &amp;ps);
  hpen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
  hbrush = CreateSolidBrush(RGB(0, 0, 255));
  SelectObject(hdc, hpen);
  SelectObject(hdc, hbrush);
  Rectangle(hdc, rc.left + 10, rc.top + 10, rc.right - 10, rc.bottom - 10);
  EndPaint(hwnd, &amp;ps);
  DeleteObject(hbrush);
  DeleteObject(hpen);
  break;
}
</code></pre>
<p>Nicht vergessen bei Bearbeitung der Message WM_PAINT, BeginPaint und EndPaint verwenden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1334575</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334575</guid><dc:creator><![CDATA[Analog Bit]]></dc:creator><pubDate>Sun, 29 Jul 2007 19:44:47 GMT</pubDate></item><item><title><![CDATA[Reply to Vierecke, Kreise ... on Sun, 29 Jul 2007 23:37:42 GMT]]></title><description><![CDATA[<p>Nicht vergessen: Alle Objekte, die in ein HDC via SelectObject eingesetzt werden, müssen nicht nur gelöscht werden..., sondern der alte Inhalt muss (oder besser 'sollte' - eben guter Programmierstil) für den jeweiligen Objekttyp auch wieder hergestellt werden <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> . Siehe MSDN zu SelectObject.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1334683</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1334683</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 29 Jul 2007 23:37:42 GMT</pubDate></item></channel></rss>