<?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[Problem beim ändern der Farbe des Fenster]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich bin daran, eine DLL zu schreiben. Nun bin ich auf ein Problem gestossen. Ich will die Farbe des Fensters durch eine Funktion ändern.</p>
<p>Hier ist der Code meiner DLL:</p>
<pre><code class="language-cpp">// Dark3DCubeEnginedll.h
//
// Definitions of the functions
//
#ifndef DARK_HPP
#define DARK_HPP

#include &lt;windows.h&gt;
#include &quot;Structures.h&quot;
#include &quot;Enumerations.h&quot;
#include &quot;Definitions.h&quot;

// create a namespace, called DCE
//
namespace DCE
{
	// Create a class, called Dark3DCubeEngine
	//
	class Dark3DCubeEngine
	{
	public:

		static __declspec(dllexport) void Initialize (DCE::Dark3DCubeEngineProperties &amp; props);
		static __declspec(dllexport) void SetWindowProperties (const int WindowWidth, const int WindowHeight,
															   const int WindowDepth);
		static __declspec(dllexport) void SetWindowColor (int R, int G, int B);
		static __declspec(dllexport) HWND OpenWindow (HINSTANCE hInstance);
		static __declspec(dllexport) LRESULT WINAPI MsgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

	private:

		static int m_WindowWidth;
		static int m_WindowHeight;
		static int m_WindowDepth;
		static int m_R;
		static int m_G;
		static int m_B;

	}; // End of the class

} // End of the namespace

#endif

// Dark3DCubeEnginedll.cpp
//
// Definitions of the functions
//
#include &quot;Dark3DCubeEnginedll.h&quot;

// Create a namespace, called DCE
//
namespace DCE
{
	Dark3DCubeEngineProperties * props = new Dark3DCubeEngineProperties();
	int Dark3DCubeEngine::m_WindowDepth;  // = 0
	int Dark3DCubeEngine::m_WindowHeight; // = 0
	int Dark3DCubeEngine::m_WindowWidth;  // = 0
	int Dark3DCubeEngine::m_R;			  // = 0
	int Dark3DCubeEngine::m_G;			  // = 0
	int Dark3DCubeEngine::m_B;			  // = 0

	void Dark3DCubeEngine::Initialize(DCE::Dark3DCubeEngineProperties &amp; props)
	{
		props.WindowWidth = m_WindowWidth;
		props.WindowHeight = m_WindowHeight;
		props.WindowDepth = m_WindowDepth;
	}

	void Dark3DCubeEngine::SetWindowProperties(const int WindowWidth, const int WindowHeight,
											   const int WindowDepth)
	{
		m_WindowWidth = WindowWidth;
		m_WindowHeight = WindowHeight;
		m_WindowDepth = WindowDepth;
	}

	void Dark3DCubeEngine::SetWindowColor(int R, int G, int B)
	{
		m_R = R;
		m_G = G;
		m_B = B;
	}

	HWND Dark3DCubeEngine::OpenWindow(HINSTANCE hInstance)
	{
		WNDCLASSEX wc;

		wc.style			= CS_HREDRAW | CS_VREDRAW;
		wc.cbSize			= sizeof (wc);
		wc.lpfnWndProc		= MsgProc;
		wc.cbClsExtra		= 0;
		wc.cbWndExtra		= 0;
		wc.hInstance		= hInstance;
		wc.hIcon			= LoadIcon (NULL, IDI_APPLICATION);
		wc.hCursor			= LoadCursor (NULL, IDC_ARROW);
		wc.hbrBackground	= (HBRUSH)CreateSolidBrush(RGB(m_R, m_G, m_B));
		wc.lpszMenuName		= NULL;
		wc.lpszClassName	= TEXT (&quot;Dark3DCubeEngine&quot;);
		wc.hIconSm			= LoadIcon (NULL, IDI_APPLICATION);

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

		return CreateWindowEx (NULL, TEXT(&quot;Dark3DCubeEngine&quot;), &quot;Dark3DCubeEngine&quot;,
							   WS_OVERLAPPEDWINDOW | WS_VISIBLE,
							   GetSystemMetrics(SM_CXSCREEN)/2 - 250,
							   GetSystemMetrics(SM_CYSCREEN)/2 - 187,
							   m_WindowWidth, m_WindowHeight, NULL,
							   NULL, hInstance, NULL);
	}

	LRESULT WINAPI Dark3DCubeEngine::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
	{
		switch (msg)
		{
			// key was pressed
			//
		case WM_KEYDOWN:
			{
				switch (wParam)
				{
				case VK_ESCAPE:
					{
						PostMessage (hwnd, WM_CLOSE, 0, 0);
						return 0;
					} break;
				default: break;
				}
			} break;

		case WM_DESTROY:
			{
				PostQuitMessage (0);
				return 0;
			}
		default: break;
		}

		return DefWindowProc(hwnd, msg, wParam, lParam);
	}
} // End of the namespace
</code></pre>
<p>Doch wenn ich nun eine Farbe bei der .exe mit der Funktion SetWindowColor angebe, kommt immer nur ein schwarzes Fenster heraus.</p>
<p>Hier der Code der .exe:</p>
<pre><code class="language-cpp">// main.h
//
#include &lt;windows.h&gt;
#include &lt;Dark3DCubeEnginedll.h&gt;
#pragma comment(lib, &quot;Dark3DCubeEngine.lib&quot;)

// Create a class, called MyApplication
//
class MyApplication : public DCE::Dark3DCubeEngine
{
public:

	MyApplication () {}
	virtual ~MyApplication () {}

};

// main.cpp
//
#include &quot;main.h&quot;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
					LPSTR lpCmdLine, int nShowCmd)
{
	MSG msg;
	HWND hwnd;
	bool bDone = false;
	MyApplication * pApp = new MyApplication ();
	DCE::Dark3DCubeEngineProperties props;

	pApp-&gt;Initialize(props);
	pApp-&gt;SetWindowProperties(1200, 1000, 32);
	pApp-&gt;SetWindowColor(100, 250, 100);
	hwnd = pApp-&gt;OpenWindow(hInstance);

	if (hwnd)
	{
		MessageBox(NULL, &quot;Fehler beim Initialisieren!&quot;, &quot;Fehler aufgetreten&quot;,
				   MB_OK | MB_ICONEXCLAMATION);
	}

	while (!bDone)
	{
		while (PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&amp;msg);
			DispatchMessage(&amp;msg);
		}
	}

	delete pApp;

	return 0;
}
</code></pre>
<p>Kann mir hier jemand helfen?</p>
<p>Gruss Patrick</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/242746/problem-beim-ändern-der-farbe-des-fenster</link><generator>RSS for Node</generator><lastBuildDate>Sat, 04 Apr 2026 17:34:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/242746.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 07 Jun 2009 17:40:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem beim ändern der Farbe des Fenster on Sun, 07 Jun 2009 17:40:56 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich bin daran, eine DLL zu schreiben. Nun bin ich auf ein Problem gestossen. Ich will die Farbe des Fensters durch eine Funktion ändern.</p>
<p>Hier ist der Code meiner DLL:</p>
<pre><code class="language-cpp">// Dark3DCubeEnginedll.h
//
// Definitions of the functions
//
#ifndef DARK_HPP
#define DARK_HPP

#include &lt;windows.h&gt;
#include &quot;Structures.h&quot;
#include &quot;Enumerations.h&quot;
#include &quot;Definitions.h&quot;

// create a namespace, called DCE
//
namespace DCE
{
	// Create a class, called Dark3DCubeEngine
	//
	class Dark3DCubeEngine
	{
	public:

		static __declspec(dllexport) void Initialize (DCE::Dark3DCubeEngineProperties &amp; props);
		static __declspec(dllexport) void SetWindowProperties (const int WindowWidth, const int WindowHeight,
															   const int WindowDepth);
		static __declspec(dllexport) void SetWindowColor (int R, int G, int B);
		static __declspec(dllexport) HWND OpenWindow (HINSTANCE hInstance);
		static __declspec(dllexport) LRESULT WINAPI MsgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

	private:

		static int m_WindowWidth;
		static int m_WindowHeight;
		static int m_WindowDepth;
		static int m_R;
		static int m_G;
		static int m_B;

	}; // End of the class

} // End of the namespace

#endif

// Dark3DCubeEnginedll.cpp
//
// Definitions of the functions
//
#include &quot;Dark3DCubeEnginedll.h&quot;

// Create a namespace, called DCE
//
namespace DCE
{
	Dark3DCubeEngineProperties * props = new Dark3DCubeEngineProperties();
	int Dark3DCubeEngine::m_WindowDepth;  // = 0
	int Dark3DCubeEngine::m_WindowHeight; // = 0
	int Dark3DCubeEngine::m_WindowWidth;  // = 0
	int Dark3DCubeEngine::m_R;			  // = 0
	int Dark3DCubeEngine::m_G;			  // = 0
	int Dark3DCubeEngine::m_B;			  // = 0

	void Dark3DCubeEngine::Initialize(DCE::Dark3DCubeEngineProperties &amp; props)
	{
		props.WindowWidth = m_WindowWidth;
		props.WindowHeight = m_WindowHeight;
		props.WindowDepth = m_WindowDepth;
	}

	void Dark3DCubeEngine::SetWindowProperties(const int WindowWidth, const int WindowHeight,
											   const int WindowDepth)
	{
		m_WindowWidth = WindowWidth;
		m_WindowHeight = WindowHeight;
		m_WindowDepth = WindowDepth;
	}

	void Dark3DCubeEngine::SetWindowColor(int R, int G, int B)
	{
		m_R = R;
		m_G = G;
		m_B = B;
	}

	HWND Dark3DCubeEngine::OpenWindow(HINSTANCE hInstance)
	{
		WNDCLASSEX wc;

		wc.style			= CS_HREDRAW | CS_VREDRAW;
		wc.cbSize			= sizeof (wc);
		wc.lpfnWndProc		= MsgProc;
		wc.cbClsExtra		= 0;
		wc.cbWndExtra		= 0;
		wc.hInstance		= hInstance;
		wc.hIcon			= LoadIcon (NULL, IDI_APPLICATION);
		wc.hCursor			= LoadCursor (NULL, IDC_ARROW);
		wc.hbrBackground	= (HBRUSH)CreateSolidBrush(RGB(m_R, m_G, m_B));
		wc.lpszMenuName		= NULL;
		wc.lpszClassName	= TEXT (&quot;Dark3DCubeEngine&quot;);
		wc.hIconSm			= LoadIcon (NULL, IDI_APPLICATION);

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

		return CreateWindowEx (NULL, TEXT(&quot;Dark3DCubeEngine&quot;), &quot;Dark3DCubeEngine&quot;,
							   WS_OVERLAPPEDWINDOW | WS_VISIBLE,
							   GetSystemMetrics(SM_CXSCREEN)/2 - 250,
							   GetSystemMetrics(SM_CYSCREEN)/2 - 187,
							   m_WindowWidth, m_WindowHeight, NULL,
							   NULL, hInstance, NULL);
	}

	LRESULT WINAPI Dark3DCubeEngine::MsgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
	{
		switch (msg)
		{
			// key was pressed
			//
		case WM_KEYDOWN:
			{
				switch (wParam)
				{
				case VK_ESCAPE:
					{
						PostMessage (hwnd, WM_CLOSE, 0, 0);
						return 0;
					} break;
				default: break;
				}
			} break;

		case WM_DESTROY:
			{
				PostQuitMessage (0);
				return 0;
			}
		default: break;
		}

		return DefWindowProc(hwnd, msg, wParam, lParam);
	}
} // End of the namespace
</code></pre>
<p>Doch wenn ich nun eine Farbe bei der .exe mit der Funktion SetWindowColor angebe, kommt immer nur ein schwarzes Fenster heraus.</p>
<p>Hier der Code der .exe:</p>
<pre><code class="language-cpp">// main.h
//
#include &lt;windows.h&gt;
#include &lt;Dark3DCubeEnginedll.h&gt;
#pragma comment(lib, &quot;Dark3DCubeEngine.lib&quot;)

// Create a class, called MyApplication
//
class MyApplication : public DCE::Dark3DCubeEngine
{
public:

	MyApplication () {}
	virtual ~MyApplication () {}

};

// main.cpp
//
#include &quot;main.h&quot;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
					LPSTR lpCmdLine, int nShowCmd)
{
	MSG msg;
	HWND hwnd;
	bool bDone = false;
	MyApplication * pApp = new MyApplication ();
	DCE::Dark3DCubeEngineProperties props;

	pApp-&gt;Initialize(props);
	pApp-&gt;SetWindowProperties(1200, 1000, 32);
	pApp-&gt;SetWindowColor(100, 250, 100);
	hwnd = pApp-&gt;OpenWindow(hInstance);

	if (hwnd)
	{
		MessageBox(NULL, &quot;Fehler beim Initialisieren!&quot;, &quot;Fehler aufgetreten&quot;,
				   MB_OK | MB_ICONEXCLAMATION);
	}

	while (!bDone)
	{
		while (PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))
		{
			TranslateMessage(&amp;msg);
			DispatchMessage(&amp;msg);
		}
	}

	delete pApp;

	return 0;
}
</code></pre>
<p>Kann mir hier jemand helfen?</p>
<p>Gruss Patrick</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1722878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1722878</guid><dc:creator><![CDATA[Eglifisch1]]></dc:creator><pubDate>Sun, 07 Jun 2009 17:40:56 GMT</pubDate></item></channel></rss>