<?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[Window in Klassen Kapseln]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich packe grad die WinAPI Funktionen für ein Grundfenster in eine Klasse, und wollt Fragen, ob etwas dagegen spricht, und ob es schonmal jemand gemacht hat.<br />
Denn ich hab Probleme die WndProc einzubinden.</p>
<p>Ich hab die WinMain so gestaltet (bei Borland abgeguggt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> )<br />
<strong>main.cpp:</strong></p>
<pre><code class="language-cpp">#include &quot;globals.h&quot;

// Entrypoint
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				    LPSTR lpszCmdLine, int CmdShow )
{
         WPARAM exitcode = 0;
         WinApp application( hInstance );
	try
	{
		// Initialize
		application.init();
		// Run
		exitcode = application.run();
	}
	catch (...)
	{
		// TODO: exitcode = ( Exception ID )
                  // Show Message( Exception Text )

	}
         // Finalize
	application.clear();
	return exitcode;
}
</code></pre>
<p>die Globalen defines und includes..<br />
<strong>globals.h</strong></p>
<pre><code class="language-cpp">#pragma once

#define STRICT
#define WIN32_LEAN_AND_MEAN

#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;
</code></pre>
<p>und meine Fensterklasse<br />
<strong>winapp.h</strong></p>
<pre><code class="language-cpp">#include &quot;globals.h&quot;

class WinApp
{
public:
	 WinApp( HINSTANCE hInst );
	~WinApp();
    LRESULT CALLBACK  WndProc( HWND hWnd_, UINT msg_, WPARAM wParam_, LPARAM lParam_ );
	void		init();
	WPARAM		run();
	void		clear();
	HINSTANCE    	hinstance;
	HWND		hwnd;
	MSG		msg;
	WNDCLASSEX	window;
	LPCTSTR		classname;
};
</code></pre>
<p><strong>winapp.cpp</strong></p>
<pre><code class="language-cpp">WinApp::WinApp( HINSTANCE hInst )
{
	hinstance = hInst;
	hwnd = 0;
	ZeroMemory( &amp;msg, sizeof(msg) );
	ZeroMemory( &amp;window, sizeof(window) );
	classname = _T(&quot;classname does not matter&quot;);
}

WinApp::~WinApp(void)
{
	clear();
}

LRESULT CALLBACK WinApp::WndProc( HWND hWnd_, UINT msg_, WPARAM wParam_, LPARAM lParam_ )
{
    switch( msg_ ) {
         case WM_DESTROY: {
		PostQuitMessage( 0 );
		return 0;
		}
	default:
		return DefWindowProc( hWnd_, msg_, wParam_, lParam_ );
	}
}

void WinApp::init()
{
	window.cbSize		= sizeof( WNDCLASSEX );
	window.style		= CS_CLASSDC;
	window.lpfnWndProc	= WndProc;  // &lt;---HIER!!!
//	window.cbClsExtra	= 0;
//	window.cbWndExtra	= 0;
	window.hInstance	= hinstance;
//	window.hIcon		= 0;
//	window.hCursor		= 0;
	window.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH);
//	window.lpszMenuName	= 0;
	window.lpszClassName= classname;
//	window.hIconSm		= 0;
	if( !RegisterClassEx( &amp;window ) )
		// TODO Throw
		return;
	hwnd = CreateWindowEx( 0, classname, _T(&quot;&quot;), 
							WS_POPUPWINDOW | WS_VISIBLE,
							10, 10, 400, 400,
							GetDesktopWindow(), 0, hinstance, 0 );
	if( !hwnd )
		// TODO Throw
		return;
	ShowWindow( hwnd, SW_SHOWDEFAULT );
	UpdateWindow( hwnd );
	return;
}

WPARAM WinApp::run()
{
	while( msg.message != WM_QUIT ) {
		if( PeekMessage( &amp;msg, 0, 0, 0, PM_REMOVE ) ) {
			TranslateMessage( &amp;msg );
			DispatchMessage( &amp;msg );
		}
		else {
			// TODO Application Goes Here
		}
	}
	return msg.wParam;
}

void WinApp::clear()
{
	if( GetClassInfoEx( hinstance, classname, &amp;window ) )
		UnregisterClass( classname, hinstance );
}
</code></pre>
<p>Das ergibt folgende Fehler:</p>
<blockquote>
<p>...error C3867: 'WinApp::WndProc': function call missing argument list; use '&amp;WinApp::WndProc' to create a pointer to member<br />
...error C2440: '=' : cannot convert from 'LRESULT (__stdcall WinApp::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'<br />
There is no context in which this conversion is possible</p>
</blockquote>
<p>Hab nun allso ein &amp; vor WndProc gesetzt, dann kam dies:</p>
<blockquote>
<p>...error C2276: '&amp;' : illegal operation on bound member function expression</p>
</blockquote>
<p>Kann die WndProc demzufolge keine Memberfunktion sein?<br />
Ich probiers nun schon den zweiten Abend in Folge, <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> und wär um jede Hilfe froh</p>
<p>Danke im voraus..</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/149120/window-in-klassen-kapseln</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 00:39:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/149120.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 02 Jun 2006 16:17:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 16:17:37 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Ich packe grad die WinAPI Funktionen für ein Grundfenster in eine Klasse, und wollt Fragen, ob etwas dagegen spricht, und ob es schonmal jemand gemacht hat.<br />
Denn ich hab Probleme die WndProc einzubinden.</p>
<p>Ich hab die WinMain so gestaltet (bei Borland abgeguggt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f576.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--sunglasses"
      title=":sunglasses:"
      alt="🕶"
    /> )<br />
<strong>main.cpp:</strong></p>
<pre><code class="language-cpp">#include &quot;globals.h&quot;

// Entrypoint
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				    LPSTR lpszCmdLine, int CmdShow )
{
         WPARAM exitcode = 0;
         WinApp application( hInstance );
	try
	{
		// Initialize
		application.init();
		// Run
		exitcode = application.run();
	}
	catch (...)
	{
		// TODO: exitcode = ( Exception ID )
                  // Show Message( Exception Text )

	}
         // Finalize
	application.clear();
	return exitcode;
}
</code></pre>
<p>die Globalen defines und includes..<br />
<strong>globals.h</strong></p>
<pre><code class="language-cpp">#pragma once

#define STRICT
#define WIN32_LEAN_AND_MEAN

#include &lt;windows.h&gt;
#include &lt;tchar.h&gt;
</code></pre>
<p>und meine Fensterklasse<br />
<strong>winapp.h</strong></p>
<pre><code class="language-cpp">#include &quot;globals.h&quot;

class WinApp
{
public:
	 WinApp( HINSTANCE hInst );
	~WinApp();
    LRESULT CALLBACK  WndProc( HWND hWnd_, UINT msg_, WPARAM wParam_, LPARAM lParam_ );
	void		init();
	WPARAM		run();
	void		clear();
	HINSTANCE    	hinstance;
	HWND		hwnd;
	MSG		msg;
	WNDCLASSEX	window;
	LPCTSTR		classname;
};
</code></pre>
<p><strong>winapp.cpp</strong></p>
<pre><code class="language-cpp">WinApp::WinApp( HINSTANCE hInst )
{
	hinstance = hInst;
	hwnd = 0;
	ZeroMemory( &amp;msg, sizeof(msg) );
	ZeroMemory( &amp;window, sizeof(window) );
	classname = _T(&quot;classname does not matter&quot;);
}

WinApp::~WinApp(void)
{
	clear();
}

LRESULT CALLBACK WinApp::WndProc( HWND hWnd_, UINT msg_, WPARAM wParam_, LPARAM lParam_ )
{
    switch( msg_ ) {
         case WM_DESTROY: {
		PostQuitMessage( 0 );
		return 0;
		}
	default:
		return DefWindowProc( hWnd_, msg_, wParam_, lParam_ );
	}
}

void WinApp::init()
{
	window.cbSize		= sizeof( WNDCLASSEX );
	window.style		= CS_CLASSDC;
	window.lpfnWndProc	= WndProc;  // &lt;---HIER!!!
//	window.cbClsExtra	= 0;
//	window.cbWndExtra	= 0;
	window.hInstance	= hinstance;
//	window.hIcon		= 0;
//	window.hCursor		= 0;
	window.hbrBackground= (HBRUSH)GetStockObject(WHITE_BRUSH);
//	window.lpszMenuName	= 0;
	window.lpszClassName= classname;
//	window.hIconSm		= 0;
	if( !RegisterClassEx( &amp;window ) )
		// TODO Throw
		return;
	hwnd = CreateWindowEx( 0, classname, _T(&quot;&quot;), 
							WS_POPUPWINDOW | WS_VISIBLE,
							10, 10, 400, 400,
							GetDesktopWindow(), 0, hinstance, 0 );
	if( !hwnd )
		// TODO Throw
		return;
	ShowWindow( hwnd, SW_SHOWDEFAULT );
	UpdateWindow( hwnd );
	return;
}

WPARAM WinApp::run()
{
	while( msg.message != WM_QUIT ) {
		if( PeekMessage( &amp;msg, 0, 0, 0, PM_REMOVE ) ) {
			TranslateMessage( &amp;msg );
			DispatchMessage( &amp;msg );
		}
		else {
			// TODO Application Goes Here
		}
	}
	return msg.wParam;
}

void WinApp::clear()
{
	if( GetClassInfoEx( hinstance, classname, &amp;window ) )
		UnregisterClass( classname, hinstance );
}
</code></pre>
<p>Das ergibt folgende Fehler:</p>
<blockquote>
<p>...error C3867: 'WinApp::WndProc': function call missing argument list; use '&amp;WinApp::WndProc' to create a pointer to member<br />
...error C2440: '=' : cannot convert from 'LRESULT (__stdcall WinApp::* )(HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC'<br />
There is no context in which this conversion is possible</p>
</blockquote>
<p>Hab nun allso ein &amp; vor WndProc gesetzt, dann kam dies:</p>
<blockquote>
<p>...error C2276: '&amp;' : illegal operation on bound member function expression</p>
</blockquote>
<p>Kann die WndProc demzufolge keine Memberfunktion sein?<br />
Ich probiers nun schon den zweiten Abend in Folge, <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> und wär um jede Hilfe froh</p>
<p>Danke im voraus..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070185</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Fri, 02 Jun 2006 16:17:37 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 16:19:47 GMT]]></title><description><![CDATA[<p>this pointer -&gt; etc etc</p>
<p>wenn du näheres wissen willst winapi faq lesen</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070186</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070186</guid><dc:creator><![CDATA[frequently asked error]]></dc:creator><pubDate>Fri, 02 Jun 2006 16:19:47 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 16:43:07 GMT]]></title><description><![CDATA[<p>danke für die links, die forensuche ergab irgendwie nichts.</p>
<p>also wenn ichs static mach gehts.<br />
und da es das hauptfenster ist, brauch ich nur eins.<br />
sollt ich dann ein singleton draus machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070197</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070197</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Fri, 02 Jun 2006 16:43:07 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 18:04:32 GMT]]></title><description><![CDATA[<p>Hmm ich find Vertexwahns umsetzung nicht sooo schlecht. d.h. : <a href="http://turing.fh-landshut.de/~jamann/IMB/IMB.html" rel="nofollow">http://turing.fh-landshut.de/~jamann/IMB/IMB.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070250</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070250</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Fri, 02 Jun 2006 18:04:32 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 18:09:43 GMT]]></title><description><![CDATA[<p>hmm auf der Seite find ich nichts, was hier helfen könnte <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070256</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070256</guid><dc:creator><![CDATA[Windows_User]]></dc:creator><pubDate>Fri, 02 Jun 2006 18:09:43 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 18:49:13 GMT]]></title><description><![CDATA[<p>(D)Evil schrieb:</p>
<blockquote>
<p>Hmm ich find Vertexwahns umsetzung nicht sooo schlecht. d.h. : <a href="http://turing.fh-landshut.de/~jamann/IMB/IMB.html" rel="nofollow">http://turing.fh-landshut.de/~jamann/IMB/IMB.html</a></p>
</blockquote>
<p>ist für seine zwecke vollkommen überzogen und bei dem ganzen overhead da krieg ich kopfschmerzen da wird für eine winow message das ganze durch 10 funktionen durchgereicht die ganzen jmps machen das auch ned gerade schneller...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070296</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070296</guid><dc:creator><![CDATA[frequently asked error]]></dc:creator><pubDate>Fri, 02 Jun 2006 18:49:13 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 18:49:25 GMT]]></title><description><![CDATA[<p>Lol... du sollst dir einfach nur mal angucken wie Vertex es gemacht hat... also die kapselung... mehr nciht... daran kannst du dein konzept evt. anpassen.. manman man</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070297</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070297</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Fri, 02 Jun 2006 18:49:25 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 18:50:39 GMT]]></title><description><![CDATA[<blockquote>
<p>this pointer -&gt; etc etc</p>
<p>wenn du näheres wissen willst winapi faq lesen</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410.html</a></p>
</blockquote>
<blockquote>
<p>this pointer -&gt; etc etc</p>
<p>wenn du näheres wissen willst winapi faq lesen</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410.html</a></p>
</blockquote>
<blockquote>
<p>this pointer -&gt; etc etc</p>
<p>wenn du näheres wissen willst winapi faq lesen</p>
<p><a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410.html</a></p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1070298</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070298</guid><dc:creator><![CDATA[frequently asked error]]></dc:creator><pubDate>Fri, 02 Jun 2006 18:50:39 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 19:25:05 GMT]]></title><description><![CDATA[<p>Warum verwendest Du nicht MFC oder sonstige &quot;Frameworks&quot;. Die haben genau das gemacht was Du auch machen willst...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070338</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070338</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Fri, 02 Jun 2006 19:25:05 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 19:29:53 GMT]]></title><description><![CDATA[<p>Weil ich ein armer Student und Hobbyprogrammierer bin und nur die Express Editition habe.<br />
Ausserdem brauch ich den ganzen Overhead nicht, sondern einfach eine simple Anwendung mit weissem Fenster ohne Titelleiste, Menu, Buttons, etc pp</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070346</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070346</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Fri, 02 Jun 2006 19:29:53 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 19:38:36 GMT]]></title><description><![CDATA[<p>Windows-User schrieb:</p>
<blockquote>
<p>Windows-User schrieb:</p>
<blockquote>
<p>danke für die links, die forensuche ergab irgendwie nichts.</p>
<p>also wenn ichs static mach gehts. //&lt;--- OK! Erledigt!<br />
und da es das hauptfenster ist, brauch ich nur eins.<br />
sollt ich dann ein singleton draus machen? ??? ??? ???</p>
</blockquote>
<p>@fae: fast so hilfsbereit wie tggc <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
</blockquote>
<p>hm komm ja vergleich mich nicht mit irgendeinem dummen forum troll...meine antwort war doch hilfreich...bot 1 gute lösunghsmöglichkeit zum direkten copy &amp; paste an und einen link z ueiner 4 seitigen diskussion mit mehreren anderen lösungsmöglichkeiten an....aber wenn dir noch was unklar ist kannst du ja gerne fragen <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070354</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070354</guid><dc:creator><![CDATA[frequently asked error]]></dc:creator><pubDate>Fri, 02 Jun 2006 19:38:36 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 19:45:48 GMT]]></title><description><![CDATA[<p>Ok sorry, war unfair dich mit dem grössenwahnsinnigen spiele progger zu vergleichen</p>
<p>Also, wenn ich nur <strong>ein</strong> Grundfenster hab..brauch ich dann die Methode mit den this Zeigern?<br />
Oder kann ich ein Singleton machen?<br />
Oder wie mach ichs am &quot;besten&quot;, nicht im Sinn von elegannt. Es soll ja nicht auf die Performance drücken..<br />
Sonst mach ich einfach eine lokale Proc ohne Scope, so wie ich das Problem am Anfang umging.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070361</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070361</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Fri, 02 Jun 2006 19:45:48 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 20:20:09 GMT]]></title><description><![CDATA[<p>ok danke<br />
ich habs jetzt abgetippt, und sogar geschnallt, mit dem this, pointer GetWindowLongPtr etc.<br />
Funzt auch!</p>
<p>Aber ich bin sicher, TGGC hat in seinen brillianten Codes eine elegantere Lösung!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070411</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070411</guid><dc:creator><![CDATA[hWINDOWS_USER]]></dc:creator><pubDate>Fri, 02 Jun 2006 20:20:09 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Fri, 02 Jun 2006 21:57:50 GMT]]></title><description><![CDATA[<p>Back2Topic: PLEAZZZE HELP MEEE!!!!¨¨¨</p>
<p>Ok ich hab gedacht es geht, aber falsch gedacht.<br />
folgendes geht ned:</p>
<pre><code class="language-cpp">LRESULT CALLBACK mainwin::WndProc( HWND hWnd_, UINT msg_, 
								  WPARAM wParam_, LPARAM lParam_ )
{
	mainwin* this_ = (mainwin*) GetWindowLongPtr( hWnd_, GWL_USERDATA );
	switch( msg_ ) {
		case WM_CREATE: {
			this_ = (mainwin*) ( (LPCREATESTRUCT)lParam_)-&gt;lpCreateParams;
			SetWindowLongPtr( hWnd_, GWL_USERDATA, (LONG)this_ );
			break;
		}
		case WM_PAINT: {
			PAINTSTRUCT	ps;
			HDC			hDC;
                           LPCWSTR text = &quot;blabla&quot;;
			if( hDC = BeginPaint( this_-&gt;hwnd, &amp;ps ) ) {   ///&lt;---Hier
				//TextOut( hDC, 0, 0, text, sizeof(text) );	
				EndPaint( this_-&gt;hwnd, &amp;ps );
			}
</code></pre>
<p>es kompiliert zwar einwandfrei, aber steigt aus mit</p>
<blockquote>
<p>Unhandled exception at 0x00411914 in WinApp.exe: 0xC0000005: Access violation reading location 0x0000003c.</p>
</blockquote>
<p>und zwar beim ersten EInsatz von <em>this_</em><br />
[emotionen]<strong>Je m'enerve! Püree!!</strong>[/emotionen]<br />
Vorhin gings, was mach ich falsch???<br />
*zwerveifel*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070505</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070505</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Fri, 02 Jun 2006 21:57:50 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 10:56:56 GMT]]></title><description><![CDATA[<p>Windows-User schrieb:</p>
<blockquote>
<p>Weil ich ein armer Student und Hobbyprogrammierer bin und nur die Express Editition habe.</p>
</blockquote>
<p>Das ist ja kein Grund...<br />
1. Mit der Express-Version kann man WTL und sonstige Frameworks verwenden (wxWidgeds)<br />
2. Als Student bekommst Du von Deiner Uni/FH ein vollständiges VS Academic kostenlos gestellt (musst nur fragen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070603</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070603</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 03 Jun 2006 10:56:56 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 14:12:34 GMT]]></title><description><![CDATA[<p>Hast Du es mal durchdebuggt? Kommst Du durch WM_CREATE durch? Was soll den das viele casten?<br />
Warum willst Du das Rad neu erfinden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070712</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070712</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 03 Jun 2006 14:12:34 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 14:37:12 GMT]]></title><description><![CDATA[<p>Ja, die WM_CREATE wird aufgerufen. Die Variblen sind aber alle unused=??? Auch hWnd_ . <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> <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>Hab das casten abgetippt von da: <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410-and-start-is-0-and-postdays-is-0-and-postorder-is-asc-and-highlight-is-.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-148410-and-start-is-0-and-postdays-is-0-and-postorder-is-asc-and-highlight-is-.html</a> Mein VS motzt auch deswegen.</p>
<p>Wieso Rad neu erfinden? Ich will doch nur mein eintes einzigstes Fenster auslagern, damit ich es wiederverwenden kann, und die WinMain aufgeräumter aussieht. Und jetzt ist es auch eine Frage des Ehrgeizes, dass ich das schaffen möcht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070725</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Sat, 03 Jun 2006 14:37:12 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 17:20:04 GMT]]></title><description><![CDATA[<p>Hast Du das Beispiel dort verstanden??? Wie sieht DEIN CreateWindow(Ex) aus??? In Deinem ersten Beispiel hast Du da was komplett falsch gemacht (this fehlt)...<br />
Aber wie gesagt, wenn Du das (simple) Beispiel nicht verstanden hast, dann solltest Du dich da mal zuerst reindenken, bevor Du was eigenes machst...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070812</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070812</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 03 Jun 2006 17:20:04 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 17:36:39 GMT]]></title><description><![CDATA[<p>Huch</p>
<p>ich hab inzwischen folgendes in der MSDN rausgefunden</p>
<p>bei GetWindowLongPtr:</p>
<blockquote>
<p>Remarks</p>
<p>Reserve extra window memory by specifying a nonzero value in the cbWndExtra member of the WNDCLASSEX structure used with the RegisterClassEx function.</p>
</blockquote>
<p>also bei cbWndExtra sollte man bytes reservieren, geht aber auch ohne (?)</p>
<p>bei CreateWindowEx:</p>
<blockquote>
<p>lpParam<br />
[in] <strong>Pointer to a value</strong> to be passed to the window through the CREATESTRUCT structure <strong>passed in the lParam member of the WM_CREATE message</strong> sent to the created window by this function before it returns. May be NULL if no additional data is needed.</p>
</blockquote>
<p>also das this im Beispiel hab ich nun zugefügt. jetzt geht es!</p>
<p>Ich habs jetzt geschnallt.<br />
Ich hab mich doch auch gewundert, woher der Pointer im lParam des WM_CREATE kommen sollte. *kling* der Groschen ist nun gefallen.<br />
Wenn ich nun noch die Casts wegkriege, bin ich glücklich.<br />
Danke vielmals, du hast mir sehr geholfen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070815</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070815</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Sat, 03 Jun 2006 17:36:39 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 17:54:19 GMT]]></title><description><![CDATA[<p>Windows-User schrieb:</p>
<blockquote>
<p>Wenn ich nun noch die Casts wegkriege, bin ich glücklich.</p>
</blockquote>
<p>DIe bekommst Du nicht weg... sollten aber auch alle korrekt sein...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070822</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 03 Jun 2006 17:54:19 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 17:58:37 GMT]]></title><description><![CDATA[<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>Was soll den das viele casten?</p>
</blockquote>
<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>Windows-User schrieb:</p>
<blockquote>
<p>Wenn ich nun noch die Casts wegkriege, bin ich glücklich.</p>
</blockquote>
<p>DIe bekommst Du nicht weg... sollten aber auch alle korrekt sein...</p>
</blockquote>
<p><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="😕"
    /> <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="😕"
    /> <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>Folgende Warnungen bleiben aber:</p>
<blockquote>
<p>...mainwin.cpp(21) : warning C4312: 'type cast' : conversion from 'LONG' to 'mainwin *' of greater size<br />
...mainwin.cpp(27) : warning C4311: 'type cast' : pointer truncation from 'mainwin *' to 'LONG'</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1070824</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070824</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Sat, 03 Jun 2006 17:58:37 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 18:07:45 GMT]]></title><description><![CDATA[<p>Ok egal, Warnungen sind da, um ignoriert zu werden <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="😃"
    /><br />
Aber kann ich nicht C++ Casts verwenden?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070830</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070830</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Sat, 03 Jun 2006 18:07:45 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 18:29:08 GMT]]></title><description><![CDATA[<p>tja<br />
reinterpret_cast&lt;&gt;() geht zwar, aber die Warnungen bleiben natürlich die selben.<br />
also ich bin dann erstmal glücklich.<br />
Für weitere Kritik hab ich trotzdem noch ein offenes Ohr</p>
<p>Superdanke nochmal <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070844</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070844</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Sat, 03 Jun 2006 18:29:08 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 19:19:41 GMT]]></title><description><![CDATA[<p>Windows-User schrieb:</p>
<blockquote>
<p>Folgende Warnungen bleiben aber:</p>
<blockquote>
<p>...mainwin.cpp(21) : warning C4312: 'type cast' : conversion from 'LONG' to 'mainwin *' of greater size<br />
...mainwin.cpp(27) : warning C4311: 'type cast' : pointer truncation from 'mainwin *' to 'LONG'</p>
</blockquote>
</blockquote>
<p>Kannst Du die Codestellen dazu zeigen!?<br />
ENtweder hast Du einen alten Compiler (VC2002/2003) oder kein aktuelles PSDK... eigentlich dürften diese nicht kommen, da es in dem aktuellen PSDK auf Win64 schon angepasst wurde... aber vielleicht täusche ich mich auch...</p>
<p>Ach so... Du solltest natürlich auch &quot;SetWindowLongPtr&quot; und &quot;GetWindowLongPtr&quot; verwenden!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070870</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070870</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 03 Jun 2006 19:19:41 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 19:32:28 GMT]]></title><description><![CDATA[<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>Windows-User schrieb:</p>
<blockquote>
<p>Folgende Warnungen bleiben aber:</p>
<blockquote>
<p>...mainwin.cpp(21) : warning C4312: 'type cast' : conversion from 'LONG' to 'mainwin *' of greater size<br />
...mainwin.cpp(27) : warning C4311: 'type cast' : pointer truncation from 'mainwin *' to 'LONG'</p>
</blockquote>
</blockquote>
<p>Kannst Du die Codestellen dazu zeigen!?<br />
ENtweder hast Du einen alten Compiler (VC2002/2003) oder kein aktuelles PSDK... eigentlich dürften diese nicht kommen, da es in dem aktuellen PSDK auf Win64 schon angepasst wurde... aber vielleicht täusche ich mich auch...</p>
<p>Ach so... Du solltest natürlich auch &quot;SetWindowLongPtr&quot; und &quot;GetWindowLongPtr&quot; verwenden!!!</p>
</blockquote>
<p>Sorry hab grad beef mit der Schmalzlocke</p>
<p>Ne hab:<br />
VSC++2005EE<br />
PSDK R2 3790.2075 im Mai 2006 installiert<br />
WinXP SP2, AMDAthlonXP ein 32bitter</p>
<p>Hab die Get/SetWindowLongPtr() von Anfang an drin, so genau hab ich den anderen Thread noch gelesen.<br />
äehm eventuell liegts dran, dass ich <em>#define STRICT</em> drin hab?<br />
Hier die Codestellen:</p>
<pre><code class="language-cpp">mainwin* this_ = reinterpret_cast&lt;mainwin*&gt;(GetWindowLongPtr( hWnd_, GWL_USERDATA ));
//..
SetWindowLongPtr( hWnd_, GWL_USERDATA, reinterpret_cast&lt;LONG&gt;(this_) );
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1070876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070876</guid><dc:creator><![CDATA[Windows-User]]></dc:creator><pubDate>Sat, 03 Jun 2006 19:32:28 GMT</pubDate></item><item><title><![CDATA[Reply to Window in Klassen Kapseln on Sat, 03 Jun 2006 19:41:59 GMT]]></title><description><![CDATA[<p>Windows-User schrieb:</p>
<blockquote>
<pre><code class="language-cpp">mainwin* this_ = reinterpret_cast&lt;mainwin*&gt;(GetWindowLongPtr( hWnd_, GWL_USERDATA ));
SetWindowLongPtr( hWnd_, GWL_USERDATA, reinterpret_cast&lt;LONG&gt;(this_) );
</code></pre>
</blockquote>
<p>Caste bitte korrekt nach &quot;LONG_PTR&quot; und nicht nach &quot;LONG&quot;!</p>
<p>PS: Könnt Ihr eigentlich das gefrotzel sein lassen? Sonst mach ich hier zu.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1070884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1070884</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sat, 03 Jun 2006 19:41:59 GMT</pubDate></item></channel></rss>