<?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[WinApi - OOP]]></title><description><![CDATA[<p>Hey leute ich habe mal versucht mir eine Klasse zu schreiben um es zu vereinfachen ein WinApi Fenster zu erstellen. Aber bei der Registrierung der Window Class und/oder bei der Fenster Erstellung (hWnd = CreateWindow(...)) geht scheinbar irgendwas schief</p>
<p>Hier die Dateien:<br />
WinAPI_TEST.cpp:</p>
<pre><code class="language-cpp">// WinAPI_TEST.cpp : Definiert den Einstiegspunkt für die Anwendung.
//

#include &quot;stdafx.h&quot;
#include &quot;Application.h&quot;

bool done = false;

int WINAPI WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{

 	CApplication app(&quot;WinAPI&quot;, hInstance, nCmdShow);
	app.SetSize(800, 600);
	app.Init();
	app.Show();

	while(!app.isDone()) {
		app.MessageHandling();
	}

	return 0;
}
</code></pre>
<p>Application.h:</p>
<pre><code class="language-cpp">#pragma once

class CApplication
{
public:
	CApplication(void);
	CApplication(LPCSTR n, HINSTANCE hInstance, int nCmdShow);
	~CApplication(void);

	bool Init();
	void Show();

	// Setters for the Window Properties
	void SetTitle(char* title);
	void SetSize(int width, int height);
	void SetPosition(int x, int y);
	void MessageHandling();
	bool isDone() { return done; }

private:
	LPCSTR WndTitle;
	int iWndWidth;
	int iWndHeight;
	int xPos;
	int yPos;
	bool done;

	HWND hWnd;
	HINSTANCE hInstance;
	MSG msg;
	WNDCLASSEX wndClassEX;
	int nCmdShow;

	HWND Create();
	void RegisterWndClass();

protected:
	static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

};
</code></pre>
<p>Application.cpp:</p>
<pre><code class="language-cpp">#include &quot;StdAfx.h&quot;
#include &quot;Application.h&quot;

CApplication::CApplication(LPCSTR n, HINSTANCE hInstance, int cCmdShow) 
{
	this-&gt;WndTitle = n;
	this-&gt;hInstance = hInstance;
	this-&gt;nCmdShow = nCmdShow;
}

CApplication::~CApplication(void)
{
}

bool CApplication::Init()
{
	RegisterWndClass();

	hWnd = Create();
	if(!IsWindow(hWnd)) {
		return false;
	}

	return true;
}

HWND CApplication::Create()
{

	HWND temp = CreateWindow(&quot;API_TEST&quot;, &quot;API_TEST&quot;, WS_OVERLAPPEDWINDOW, 100, 100, 800, 600, NULL, NULL, hInstance, NULL); 

	return temp;

}

void CApplication::Show() 
{
	ShowWindow(hWnd, SW_NORMAL);
	UpdateWindow(hWnd);
}

void CApplication::MessageHandling() 
{
	while(PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE)) {
			if(msg.message == WM_QUIT) 
			{
				done= true;
				break;
			}

			TranslateMessage(&amp;msg);
			DispatchMessage(&amp;msg);

		}
}

void CApplication::RegisterWndClass()
{

	wndClassEX.cbSize 			= sizeof(WNDCLASSEX);
	wndClassEX.style			= CS_HREDRAW | CS_VREDRAW;
	wndClassEX.lpfnWndProc		= WndProc;
	wndClassEX.cbClsExtra		= 0;
	wndClassEX.cbWndExtra		= 0;
	wndClassEX.hInstance		= hInstance;
	wndClassEX.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	wndClassEX.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wndClassEX.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
	wndClassEX.lpszMenuName		= NULL;
	wndClassEX.lpszClassName	= &quot;API_TEST&quot;;

	RegisterClassEx(&amp;wndClassEX);

}

void CApplication::SetSize(int width, int height) 
{
	iWndWidth = width;
	iWndHeight = height;
}

LRESULT CALLBACK CApplication::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 
{
	switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hWnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>und stdafx.h:</p>
<pre><code class="language-cpp">// stdafx.h : Includedatei für Standardsystem-Includedateien
// oder häufig verwendete projektspezifische Includedateien,
// die nur in unregelmäßigen Abständen geändert werden.
//

#pragma once

#define WIN32_LEAN_AND_MEAN             // Selten verwendete Teile der Windows-Header nicht einbinden.
// Windows-Headerdateien:
#include &lt;windows.h&gt;

// C RunTime-Headerdateien
#include &lt;stdlib.h&gt;
#include &lt;malloc.h&gt;
#include &lt;memory.h&gt;
#include &lt;tchar.h&gt;

#include &lt;string&gt;
#include &lt;sstream&gt;

// OpenGL-Headerdateien
#include &lt;gl/GL.h&gt;
#include &lt;gl/GLU.h&gt;
</code></pre>
<p>wär cool wenn mir jemand helfen könnte.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/308019/winapi-oop</link><generator>RSS for Node</generator><lastBuildDate>Wed, 05 Aug 2026 21:59:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/308019.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 12 Sep 2012 11:22:53 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to WinApi - OOP on Wed, 12 Sep 2012 11:22:53 GMT]]></title><description><![CDATA[<p>Hey leute ich habe mal versucht mir eine Klasse zu schreiben um es zu vereinfachen ein WinApi Fenster zu erstellen. Aber bei der Registrierung der Window Class und/oder bei der Fenster Erstellung (hWnd = CreateWindow(...)) geht scheinbar irgendwas schief</p>
<p>Hier die Dateien:<br />
WinAPI_TEST.cpp:</p>
<pre><code class="language-cpp">// WinAPI_TEST.cpp : Definiert den Einstiegspunkt für die Anwendung.
//

#include &quot;stdafx.h&quot;
#include &quot;Application.h&quot;

bool done = false;

int WINAPI WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{

 	CApplication app(&quot;WinAPI&quot;, hInstance, nCmdShow);
	app.SetSize(800, 600);
	app.Init();
	app.Show();

	while(!app.isDone()) {
		app.MessageHandling();
	}

	return 0;
}
</code></pre>
<p>Application.h:</p>
<pre><code class="language-cpp">#pragma once

class CApplication
{
public:
	CApplication(void);
	CApplication(LPCSTR n, HINSTANCE hInstance, int nCmdShow);
	~CApplication(void);

	bool Init();
	void Show();

	// Setters for the Window Properties
	void SetTitle(char* title);
	void SetSize(int width, int height);
	void SetPosition(int x, int y);
	void MessageHandling();
	bool isDone() { return done; }

private:
	LPCSTR WndTitle;
	int iWndWidth;
	int iWndHeight;
	int xPos;
	int yPos;
	bool done;

	HWND hWnd;
	HINSTANCE hInstance;
	MSG msg;
	WNDCLASSEX wndClassEX;
	int nCmdShow;

	HWND Create();
	void RegisterWndClass();

protected:
	static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

};
</code></pre>
<p>Application.cpp:</p>
<pre><code class="language-cpp">#include &quot;StdAfx.h&quot;
#include &quot;Application.h&quot;

CApplication::CApplication(LPCSTR n, HINSTANCE hInstance, int cCmdShow) 
{
	this-&gt;WndTitle = n;
	this-&gt;hInstance = hInstance;
	this-&gt;nCmdShow = nCmdShow;
}

CApplication::~CApplication(void)
{
}

bool CApplication::Init()
{
	RegisterWndClass();

	hWnd = Create();
	if(!IsWindow(hWnd)) {
		return false;
	}

	return true;
}

HWND CApplication::Create()
{

	HWND temp = CreateWindow(&quot;API_TEST&quot;, &quot;API_TEST&quot;, WS_OVERLAPPEDWINDOW, 100, 100, 800, 600, NULL, NULL, hInstance, NULL); 

	return temp;

}

void CApplication::Show() 
{
	ShowWindow(hWnd, SW_NORMAL);
	UpdateWindow(hWnd);
}

void CApplication::MessageHandling() 
{
	while(PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE)) {
			if(msg.message == WM_QUIT) 
			{
				done= true;
				break;
			}

			TranslateMessage(&amp;msg);
			DispatchMessage(&amp;msg);

		}
}

void CApplication::RegisterWndClass()
{

	wndClassEX.cbSize 			= sizeof(WNDCLASSEX);
	wndClassEX.style			= CS_HREDRAW | CS_VREDRAW;
	wndClassEX.lpfnWndProc		= WndProc;
	wndClassEX.cbClsExtra		= 0;
	wndClassEX.cbWndExtra		= 0;
	wndClassEX.hInstance		= hInstance;
	wndClassEX.hIcon			= LoadIcon(NULL, IDI_APPLICATION);
	wndClassEX.hCursor			= LoadCursor(NULL, IDC_ARROW);
	wndClassEX.hbrBackground	= (HBRUSH)GetStockObject(BLACK_BRUSH);
	wndClassEX.lpszMenuName		= NULL;
	wndClassEX.lpszClassName	= &quot;API_TEST&quot;;

	RegisterClassEx(&amp;wndClassEX);

}

void CApplication::SetSize(int width, int height) 
{
	iWndWidth = width;
	iWndHeight = height;
}

LRESULT CALLBACK CApplication::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 
{
	switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hWnd, message, wParam, lParam);
    }

    return 0;
}
</code></pre>
<p>und stdafx.h:</p>
<pre><code class="language-cpp">// stdafx.h : Includedatei für Standardsystem-Includedateien
// oder häufig verwendete projektspezifische Includedateien,
// die nur in unregelmäßigen Abständen geändert werden.
//

#pragma once

#define WIN32_LEAN_AND_MEAN             // Selten verwendete Teile der Windows-Header nicht einbinden.
// Windows-Headerdateien:
#include &lt;windows.h&gt;

// C RunTime-Headerdateien
#include &lt;stdlib.h&gt;
#include &lt;malloc.h&gt;
#include &lt;memory.h&gt;
#include &lt;tchar.h&gt;

#include &lt;string&gt;
#include &lt;sstream&gt;

// OpenGL-Headerdateien
#include &lt;gl/GL.h&gt;
#include &lt;gl/GLU.h&gt;
</code></pre>
<p>wär cool wenn mir jemand helfen könnte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2250599</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2250599</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Wed, 12 Sep 2012 11:22:53 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Wed, 12 Sep 2012 11:39:42 GMT]]></title><description><![CDATA[<p>Es geht also &quot;irgendwas schief&quot;. So, so. Lies dir bitte mal den ersten Link in meiner Signatur durch.</p>
<p>Gibt es einen bestimmten Grund, warum du diesen Thread im C++-Forum und nicht im Winapi-Forum erstellt hast? Geht etwas mit der Sprache &quot;schief&quot;? Oder soll das doch lieber nach Winapi verschoben werden, weil irgendetwas beim Erstellen des Fensters schiefgeht?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2250604</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2250604</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 12 Sep 2012 11:39:42 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Wed, 12 Sep 2012 12:08:04 GMT]]></title><description><![CDATA[<p>hIconSm der WNDCLASSEX-Struktur ist nicht initialisiert. Das hättest du aber mit einem Debugger leicht selber herausfinden können.<br />
Zum restlichen Design sag' ich jetzt mal nichts.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2250618</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2250618</guid><dc:creator><![CDATA[icon]]></dc:creator><pubDate>Wed, 12 Sep 2012 12:08:04 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Wed, 12 Sep 2012 13:57:31 GMT]]></title><description><![CDATA[<p>das war ja das problem, der Debugger hat gar nichts gesagt.<br />
Das Programm hat sich einfach wieder beendet.<br />
Ich probier das dann aber mal aus mit hIconSm<br />
Danke für die Hilfe.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2250668</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2250668</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Wed, 12 Sep 2012 13:57:31 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Wed, 12 Sep 2012 14:25:41 GMT]]></title><description><![CDATA[<p>darman96 schrieb:</p>
<blockquote>
<p>das war ja das problem, der Debugger hat gar nichts gesagt.<br />
Das Programm hat sich einfach wieder beendet.</p>
</blockquote>
<p>ROFL <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="😉"
    /> Mein Debugger spricht auch niemals mit mir (schluchz)...</p>
<p>Im Ernst: schon mal etwas von Breakpoints und Watch-Window gehört?</p>
<p>P.S. Deinen Ansatz gibt es schon und nennt sich MFC.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2250682</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2250682</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Wed, 12 Sep 2012 14:25:41 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Wed, 12 Sep 2012 14:33:01 GMT]]></title><description><![CDATA[<p>Da &quot;done&quot; ebenfalls nicht initialisiert ist, wird das Fenster vermutlich nur kurz eingeblendet.<br />
Und durch PeekMessage hat dein Programm ständig maximale Auslastung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2250686</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2250686</guid><dc:creator><![CDATA[icon]]></dc:creator><pubDate>Wed, 12 Sep 2012 14:33:01 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Wed, 12 Sep 2012 16:06:46 GMT]]></title><description><![CDATA[<p>ja das mit &quot;done&quot; hab ich selbst schon bemerkt und breakpoints hab ich benutzt so konnte ich den Fehler auf die Klassen registrierung und die CreateWindow funktion beschrenken. Aber von Watch-Window hab ich noch nie was gehört. was ist das denn?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2250722</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2250722</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Wed, 12 Sep 2012 16:06:46 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Wed, 12 Sep 2012 16:16:59 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/18594">@Th69</a> und ich weiß das es sowas schon gibt. ich möchte es aber selber machen.<br />
und ich will versuchen awesomium zu implementieren falls das hier jemand kennt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2250725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2250725</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Wed, 12 Sep 2012 16:16:59 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Thu, 13 Sep 2012 20:46:34 GMT]]></title><description><![CDATA[<p>kennt hier denn jemand awesomium?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2251130</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251130</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Thu, 13 Sep 2012 20:46:34 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Thu, 13 Sep 2012 22:23:45 GMT]]></title><description><![CDATA[<p>darman96 schrieb:</p>
<blockquote>
<p>[...] ich habe mal versucht mir eine Klasse zu schreiben um es zu vereinfachen ein WinApi Fenster zu erstellen. [...]</p>
</blockquote>
<p>Th69 schrieb:</p>
<blockquote>
<p>Deinen Ansatz gibt es schon und nennt sich MFC.</p>
</blockquote>
<p>btw: <a href="http://christopherhunt-software.blogspot.com/2011/09/application-developers-should-not-write.html" rel="nofollow">Application developers should not write frameworks and toolkits</a></p>
<p>darman96 schrieb:</p>
<blockquote>
<p>[...] ich will versuchen awesomium zu implementieren [...]</p>
</blockquote>
<p>Brauchst nicht - das machen schon die Typen auf <a href="http://awesomium.com" rel="nofollow">http://awesomium.com</a></p>
<p>darman96 schrieb:</p>
<blockquote>
<p>[...] breakpoints hab ich benutzt so konnte ich den Fehler auf [...] die CreateWindow funktion beschr<strong>ä</strong>nken. [...]</p>
</blockquote>
<p>. o O ( Rückgabewerte zu prüfen scheint total out zu sein <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /> )</p>
<p>darman96 schrieb:</p>
<blockquote>
<p>[...] Aber von Watch-Window hab ich noch nie was gehört. was ist das denn?</p>
</blockquote>
<ol>
<li>Breakpoint setzten</li>
<li>Programm mit <code>[F5]</code> debuggen</li>
<li>Menü <code>Debug</code> -&gt; <code>Windows</code> -&gt; <code>Watch</code> -&gt; ...</li>
<li>?</li>
<li>Profit!</li>
</ol>
]]></description><link>https://www.c-plusplus.net/forum/post/2251142</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251142</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Thu, 13 Sep 2012 22:23:45 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Fri, 14 Sep 2012 05:16:09 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8250">@Swordfish</a>:</p>
<p>Ich mach das mit der klasse auch nur zum spaß und um was zu lernen.<br />
Außerdem bin ich noch in der Schule und muss für niemanden irgendwelche anwendungen schreiben also hab ich genug zeit sowas mal auszuprobieren <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>zu Awesomium:<br />
ich will das SDK von <a href="http://Awesomium.com" rel="nofollow">Awesomium.com</a> benutzen um die GUI für meine Programme zu machen.</p>
<p>zu Watch-Windows:<br />
Ich werds mal ausprobieren danke.</p>
<p>Gruß darman96</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2251156</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251156</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Fri, 14 Sep 2012 05:16:09 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Sun, 16 Sep 2012 21:12:41 GMT]]></title><description><![CDATA[<p>hat jemand Vorschläge wie ich die Klasse noch verbessern könnte?</p>
<p>Gruß darman96</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2251735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251735</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Sun, 16 Sep 2012 21:12:41 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Sun, 16 Sep 2012 21:34:21 GMT]]></title><description><![CDATA[<p>Ja, löschen und neu schreiben. Ernsthaft. Guck dir mal RAII an. Insbesondere Konstruktoren und Destruktoren. Eine Methode Init() weist so gut wie immer darauf hin, dass man das Prinzip nicht verstanden hat. Eine Methode die man vor Init aufrufen muss noch mehr. Nutze Initialisierungslisten. Höre auf auf Membervariablen mit this-&gt; zuzugreifen wenn es nicht unbedingt nötig ist. Nimm Abstand von der ungarischen Notation. (Außer bei windowseigenen Typen vll.)<br />
WNDCLASS ist kein Member eines Fensterobjekts. msg, title, Größe etc. musst du auch nicht speichern, das macht die WinAPI doch schon. Der einzige Member den du brauchst ist das Handle. (HWND) Was zum Henker macht isDone()? auf const correctness achten. int ist nicht der richtige Typ für Bildschirmkoordinaten oder Größenangaben, oder hast du da schon mal negative Werte gesehen? (std::uint16_t wäre der richtige Typ.)<br />
Warum heißt deine Klasse überhaupt Application? Das ist so ziemlich der am wenigsten aussagekräftige Name den man sich vorstellen kann. Das ist eine Fensterklasse verdammt, nenn sie window oder so. Und so kannst du auch nicht mehrere Fenster erstellen. Guck dir mal den Beitrag von Shade Of Mine <a href="http://www.c-plusplus.net/forum/301786" rel="nofollow">hier</a> an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2251739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251739</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Sun, 16 Sep 2012 21:34:21 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Sun, 16 Sep 2012 21:36:09 GMT]]></title><description><![CDATA[<p>darman96 schrieb:</p>
<blockquote>
<p>hat jemand Vorschläge wie ich die Klasse noch verbessern könnte?</p>
</blockquote>
<ul>
<li>Auf <a href="http://www.c-plusplus.net/forum/p2005233#2005233" rel="nofollow">C-Präfix</a> und generell auf <a href="http://www.c-plusplus.net/forum/p1773551#1773551" rel="nofollow">UN</a> verzichten (bei <code>hWnd</code> kann man noch darüber streiten, aber &quot;i&quot; und &quot;n&quot; vor Integers ist fragwürdig)</li>
<li>Leere Parameterlisten ohne <code>void</code></li>
<li>Konstruktor-Initialisierungsliste verwenden</li>
<li>Const-Correctness bei Get-Methoden beachten</li>
<li>Keine leeren Destruktoren definieren</li>
<li><code>Init()</code> privat machen und direkt im Konstruktor aufrufen</li>
<li>Konsistente Namenskonvention ( <code>isDone</code> vs. <code>SetTitle</code> )</li>
<li>Konsistente Namen (&quot;Befehle&quot; wie <code>HandleMessages</code> statt <code>MessageHandling</code> )</li>
<li><code>static_cast</code> statt C-Casts verwenden</li>
<li>Sich überlegen, nach welchem Kriterium Funktionen inline sind (oder gleich alles in der .cpp-Datei definieren)</li>
</ul>
]]></description><link>https://www.c-plusplus.net/forum/post/2251740</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251740</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Sun, 16 Sep 2012 21:36:09 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 10:40:50 GMT]]></title><description><![CDATA[<p>cooky451 schrieb:</p>
<blockquote>
<p>... int ist nicht der richtige Typ für Bildschirmkoordinaten oder Größenangaben, oder hast du da schon mal negative Werte gesehen? (std::uint16_t wäre der richtige Typ.)</p>
</blockquote>
<p>Für Bildschirmangaben schon oder welchen Wert hat bei dir Top und Left, wenn du ein Fenster links bzw. oben teilweise außerhalb des sichtbaren Bereichs schiebst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2251855</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251855</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Mon, 17 Sep 2012 10:40:50 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 10:54:34 GMT]]></title><description><![CDATA[<p>Th69 schrieb:</p>
<blockquote>
<p>cooky451 schrieb:</p>
<blockquote>
<p>... int ist nicht der richtige Typ für Bildschirmkoordinaten oder Größenangaben, oder hast du da schon mal negative Werte gesehen? (std::uint16_t wäre der richtige Typ.)</p>
</blockquote>
<p>Für Bildschirmangaben schon oder welchen Wert hat bei dir Top und Left, wenn du ein Fenster links bzw. oben teilweise außerhalb des sichtbaren Bereichs schiebst?</p>
</blockquote>
<p>Dabei auch nicht zu vergessen: Multimonitorsysteme...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2251871</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251871</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Mon, 17 Sep 2012 10:54:34 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 11:42:00 GMT]]></title><description><![CDATA[<p>Könnte mir denn jemand mal ein Beispiel für so eine Klasse geben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2251901</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251901</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Mon, 17 Sep 2012 11:42:00 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 11:50:57 GMT]]></title><description><![CDATA[<p>Zum Beispiel <code>sf::Window</code> von SFML, da ist WinAPI komplett weggekapselt. Kommt halt drauf an, was du genau machen willst... Wofür brauchst du das Fenster?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2251905</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251905</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Mon, 17 Sep 2012 11:50:57 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 21:03:18 GMT]]></title><description><![CDATA[<p>Ich hatte mir gedacht damit opengl Anwendungen zu machen und für die GUI awesowmium zu benutzen.</p>
<p>Edit: Wo in den SFML dateien ist denn die WinMain funktion</p>
<p>Edit 2: Habs gefunden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2251906</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2251906</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Mon, 17 Sep 2012 21:03:18 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Tue, 18 Sep 2012 09:14:51 GMT]]></title><description><![CDATA[<p>So ein neuer Versuch:</p>
<p>main.cpp:</p>
<pre><code class="language-cpp">#include &quot;stdafx.h&quot;

int WINAPI WinMain(HWND Handle, HINSTANCE Instance, HINSTANCE PrevInstance, LPCSTR CmdLine, int CmdShow) 
{

	Window window(Handle, Instance, &quot;Test&quot;);

}
</code></pre>
<p>Window.h:</p>
<pre><code class="language-cpp">#pragma once
#pragma once

#include &quot;stdafx.h&quot;

class Window
{
public:
	Window();
	Window(HWND Handle, HINSTANCE hInstance, std::string title);
	~Window();
private:
	HWND Handle;
	HINSTANCE hInstance;

	void RegisterWindowClass();
	static LRESULT CALLBACK WndProc(HWND Handle, UINT Message, WPARAM wParam, LPARAM lParam);
};
</code></pre>
<p>Window.cpp:</p>
<pre><code class="language-cpp">#include &quot;Window.h&quot;

// static members
const char* className = &quot;MyClass&quot;;

Window::Window(HWND Handle, HINSTANCE Instance, std::string title) : Handle(Handle), Instance(Instance)
{

	RegisterWindowClass();

	Handle = CreateWindow(className, title.c_str(), WS_OVERLAPPEDWINDOW, 100, 100, 800, 600, NULL, NULL, Instance, NULL);

	ShowWindow(Handle, SW_NORMAL);
	UpdateWindow(Handle);

}

Window::~Window(void)
{
}

void Window::RegisterWindowClass() 
{
	WNDCLASSEX wcex;

	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.style = CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc = WndProc;
	wcex.cbClsExtra = 0;
	wcex.cbWndExtra = 0;
	wcex.hInstance = Instance;
	wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName = NULL;
	wcex.lpszClassName = className;
	wcex.hIconSm = NULL;

	RegisterClassEx(&amp;wcex);
}

LRESULT CALLBACK Window::WndProc(HWND Handle, UINT Message, WPARAM wParam, LPARAM lParam)
{

	if(Message == WM_CREATE) 
	{
		long This = reinterpret_cast&lt;long&gt;(reinterpret_cast&lt;CREATESTRUCT*&gt;(lParam)-&gt;lpCreateParams);
		SetWindowLongPtr(Handle, GWLP_USERDATA, This);
	}

	Window* window = reinterpret_cast&lt;Window*&gt;(GetWindowLongPtr(Handle, GWLP_USERDATA));

	return DefWindowProc(Handle, Message, wParam, lParam);

}
</code></pre>
<p>Jetzt bekomm ich aber immer diese fehlermeldung:</p>
<pre><code>Fehler	1	error C2731: 'WinMain': Überladen der Funktion nicht möglich
</code></pre>
<p>PS: ich weiß das da noch einiges fehlt vor allem was message handling angeht aber ich will das jetzt erst mal so ans laufen kriegen <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="😉"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2252135</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2252135</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Tue, 18 Sep 2012 09:14:51 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 21:48:23 GMT]]></title><description><![CDATA[<p>Das liegt daran, dass die Parameterliste deiner WinMain Mist ist...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2252136</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2252136</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Mon, 17 Sep 2012 21:48:23 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 21:49:21 GMT]]></title><description><![CDATA[<p>Oh stimmt habs grad gesehen o.o sorry.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2252137</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2252137</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Mon, 17 Sep 2012 21:49:21 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 21:51:05 GMT]]></title><description><![CDATA[<p>Btw: Ich kann nur sehr empfehlen, die englische Version von Visual Studio zu benutzen, allein schon weil google dir für deutsche Compilerfehler wesentlich weniger ausspucken wird...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2252138</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2252138</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Mon, 17 Sep 2012 21:51:05 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 21:56:06 GMT]]></title><description><![CDATA[<p>Ich hab grad vs 2012 getestet und das war auf deutsch. die 2010er version hab ich auf englisch und mal sehen obs die 2012 auch in englisch gibt.</p>
<p>Kann mir jemand nen Tipp geben wie ich das Message Handling machen könnte ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2252139</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2252139</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Mon, 17 Sep 2012 21:56:06 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 22:05:13 GMT]]></title><description><![CDATA[<p>Woran genau scheitert's?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2252141</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2252141</guid><dc:creator><![CDATA[dot]]></dc:creator><pubDate>Mon, 17 Sep 2012 22:05:13 GMT</pubDate></item><item><title><![CDATA[Reply to WinApi - OOP on Mon, 17 Sep 2012 22:20:48 GMT]]></title><description><![CDATA[<p>Also da ist einmal der Code in der wndproc, den hab ich aus der sfml Klasse &quot;geklaut&quot;. Den versteh ich nicht so ganz. Und dann würde ich das Event handlingalso Tastatur Eingaben und so gerne in einer eigenen Klasse machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2252143</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2252143</guid><dc:creator><![CDATA[darman96]]></dc:creator><pubDate>Mon, 17 Sep 2012 22:20:48 GMT</pubDate></item></channel></rss>