<?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[WndProc]]></title><description><![CDATA[<p>Ich hab ein Problemo:</p>
<p>Ich schaffe es absolut nicht meine WndProc objektorientiert zu Kappseln. (bastle gerade an einem Game)<br />
Kann mal bitte jemand ein Beispiel schreiben, wie ich das machen könnte???</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/122106/wndproc</link><generator>RSS for Node</generator><lastBuildDate>Mon, 06 Jul 2026 03:51:40 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/122106.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Sep 2005 13:34:24 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 13:34:24 GMT]]></title><description><![CDATA[<p>Ich hab ein Problemo:</p>
<p>Ich schaffe es absolut nicht meine WndProc objektorientiert zu Kappseln. (bastle gerade an einem Game)<br />
Kann mal bitte jemand ein Beispiel schreiben, wie ich das machen könnte???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883654</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883654</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Fri, 30 Sep 2005 13:34:24 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 13:37:20 GMT]]></title><description><![CDATA[<p>WinAPI-FAQ: <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39356.html" rel="nofollow">WndProc in eine Klasse bekommen...</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/883658</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883658</guid><dc:creator><![CDATA[flenders]]></dc:creator><pubDate>Fri, 30 Sep 2005 13:37:20 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 18:47:47 GMT]]></title><description><![CDATA[<p>Ich kann dir vielleicht helfen, hab das nämlich vor Kurzem erst selber gemacht...</p>
<p>Wenn ich dich richtig verstehe willst du eine Klasse die eine klasseneigene Windowprozedur hat.</p>
<p>Ich würde das dann so machen:</p>
<pre><code>//Definition in der Klasse am besten als private
LRESULT CALLBACK (*pfWndProc)(HWND, UINT, WPARAM, LPARAM);
</code></pre>
<p>Dann machst du dir noch Kapselungsfunktionen:</p>
<pre><code>// Setmethode
void SetWndProc(LRESULT CALLBACK (*_pfWndProc)(HWND, UINT, WPARAM, LPARAM))
{
    pfWndProc = _pfWndProc;
}

// Getmethode
LRESULT CALLBACK (*GetWndProc())(HWND, UINT, WPARAM, LPARAM)
{
    return pfWndProc;
}
</code></pre>
<p>So kannst du jetzt eine jeder Klasse eine eigene Windowprozedur verpassen</p>
<pre><code>// Instanz der Klasse
TheClass FirstInstance;
TheClass SecondInstance;

// WndProc-Definieren
LRESULT CALLBACK FirstWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    //...
}

LRESULT CALLBACK SecondWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    //...
}

// Jetzt kannst du jedem Object eine andere WndProc geben
FirstInstance.SetWndProc(FirstWndProc);
SecondInstance.SetWndProc(SecondWndProc);

// ... der Rest sollte dann ja klar sein!
</code></pre>
<p>Ich hoffe das war jetzt das was du wissen wolltest.</p>
<p>Mfg Nico</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883857</guid><dc:creator><![CDATA[_Ocin_]]></dc:creator><pubDate>Fri, 30 Sep 2005 18:47:47 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 19:05:49 GMT]]></title><description><![CDATA[<p>nur wie kommt der Instanzzeiger (this) in die WndProc ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883867</guid><dc:creator><![CDATA[könnte funktionieren]]></dc:creator><pubDate>Fri, 30 Sep 2005 19:05:49 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 19:49:50 GMT]]></title><description><![CDATA[<p>Hmm ...</p>
<p>Also ich würde einfach eine eigene Nachricht definieren</p>
<pre><code>// Eigene Nachricht definieren
#define WM_THISPOINTER (WM_USER + 1)
</code></pre>
<p>In die WndProc reagierst du dann auf deine Message (z.B. so):</p>
<pre><code>LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    // Zeiger auf die zugehörige Instanz (also this-Zeiger)
    static TheClass* pInstance;

    switch(msg)
    {
    //...

    case WM_THISPOINTER:
        pInstance = (TheClass*)wParam;
        break;

    //...
    }

    //...

}
</code></pre>
<p>Und jetzt musst du dir nur noch, nachdem du die Prozedur deiner Instanz übergeben hast der Prozedur eine Nachricht schicken.<br />
Z.B. kannste dafür ne Funktion schreiben oder das gleich bei der Set-Funktion der WndProc (oben hatte ich sie SetWndProc() genannt) erledigen</p>
<pre><code>// Setmethode
void SetWndProc(LRESULT CALLBACK (*_pfWndProc)(HWND, UINT, WPARAM, LPARAM))
{
    pfWndProc = _pfWndProc;

    // Nachricht an die Fenster-Prozedur schicken
    // Den Fensterhandle brauchste halt noch aber den kannste ja irgendwo 
    // speichern... aber das bekommste ja sicher hin!

    SendMessage(hwnd, WM_THISPOINTER, (WPARAM)this, 0);
}
</code></pre>
<p>Dann haste den this-Zeiger in der WndProc drinne!</p>
<p>Mfg Nico</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883894</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883894</guid><dc:creator><![CDATA[_Ocin_]]></dc:creator><pubDate>Fri, 30 Sep 2005 19:49:50 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 21:01:00 GMT]]></title><description><![CDATA[<p>wie wäre es den This-Zeiger bei WM_CREATE zu übergeben<br />
und ihn mit SetWindowLong im User-Bereich zu speichern ...</p>
<p>Aber hast recht, da könnte man sich auch an das Tut der FAQ halten, das wäre zu einfach aber <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f621.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--pouting_face"
      title=":rage:"
      alt="😡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/883908</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883908</guid><dc:creator><![CDATA[Hm...]]></dc:creator><pubDate>Fri, 30 Sep 2005 21:01:00 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 22:55:40 GMT]]></title><description><![CDATA[<p>Klar das wäre generell auch möglich.<br />
Das Problem ist halt dann nur das du das Fenster innerhalb der Klasse erstellen musst...<br />
Da gibts wahrscheinlich undendlich viele Möglichkeiten...<br />
Man könnte eine globale Variable definieren.<br />
Den this-Zeiger über eine Nachricht reinschicken (so würde ich es machen)<br />
Du kannst den Zeiger theoretisch in eine Datei oder die Zwischenablage schreiben und innerhalb der WndProc als Reaktion auf WM_CREATE oder eine andere Nachricht wieder auslesen...</p>
<p>Doch was dann wirklich sinnvoll ist wird wohl sehr schnell klar!<br />
Ich würds mit ner Nachricht machen aber das bleibt natürlich jedem selbst überlassen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883929</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883929</guid><dc:creator><![CDATA[_Ocin_]]></dc:creator><pubDate>Fri, 30 Sep 2005 22:55:40 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 23:06:38 GMT]]></title><description><![CDATA[<p>Sehr sinnfrei das Ganze. Funktioniert doch eh nur für ein einziges Fenster wie du es gemacht hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883937</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883937</guid><dc:creator><![CDATA[sinn...]]></dc:creator><pubDate>Fri, 30 Sep 2005 23:06:38 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 23:09:12 GMT]]></title><description><![CDATA[<p>Ja sag ich ja das das meiste Blödsinn ist.</p>
<p>Aber wieso soll das nur für ein Fenster funktionieren ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883940</guid><dc:creator><![CDATA[_Ocin_]]></dc:creator><pubDate>Fri, 30 Sep 2005 23:09:12 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 23:27:03 GMT]]></title><description><![CDATA[<p>Alle GUI-Frameworks benutzen die Moeglichkeit, die schon erwaehnt wurde, naemlich bei CreateWindow() den Parameter &quot;lpParam&quot; zu setzen und in WM_CREATE wieder abzufragen, und anschliessend z.B. mit SetWindowLongPtr( ... GWL_USERDATA ... ) zu speichern und bei anderen Messages mit GetWindowLongPtr( ... GWL_USERDATA ... ) wieder auszulesen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883946</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883946</guid><dc:creator><![CDATA[Power Off]]></dc:creator><pubDate>Fri, 30 Sep 2005 23:27:03 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 23:31:58 GMT]]></title><description><![CDATA[<p><em>Ocin</em> schrieb:</p>
<blockquote>
<p>Ja sag ich ja das das meiste Blödsinn ist.</p>
<p>Aber wieso soll das nur für ein Fenster funktionieren ?</p>
</blockquote>
<p><strong>static</strong> TheClass* pInstance;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883948</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883948</guid><dc:creator><![CDATA[sinn...]]></dc:creator><pubDate>Fri, 30 Sep 2005 23:31:58 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 23:35:03 GMT]]></title><description><![CDATA[<p>Power Off schrieb:</p>
<blockquote>
<p>Alle GUI-Frameworks benutzen die Moeglichkeit, die schon erwaehnt wurde, naemlich bei CreateWindow() den Parameter &quot;lpParam&quot; zu setzen und in WM_CREATE wieder abzufragen, und anschliessend z.B. mit SetWindowLongPtr( ... GWL_USERDATA ... ) zu speichern und bei anderen Messages mit GetWindowLongPtr( ... GWL_USERDATA ... ) wieder auszulesen.</p>
</blockquote>
<p>Alle außer die die es anders machen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883949</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883949</guid><dc:creator><![CDATA[lpParam]]></dc:creator><pubDate>Fri, 30 Sep 2005 23:35:03 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 23:38:21 GMT]]></title><description><![CDATA[<p>lpParam schrieb:</p>
<blockquote>
<p>Alle außer die die es anders machen.</p>
</blockquote>
<p>Genau! <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>
<p>(haette vielleicht &quot;so gut wie alle&quot; schreiben sollen! <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/883952</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883952</guid><dc:creator><![CDATA[Power Off]]></dc:creator><pubDate>Fri, 30 Sep 2005 23:38:21 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 23:42:44 GMT]]></title><description><![CDATA[<p>Aso wegen dem static.<br />
Gut aber er hat ja gesagt das er eine WndProc in einer Klasse haben will.<br />
Wenn ich dann jeder Instanz der Klasse eine eigene WndProc geben, dann geht das problemlos. Erst wenn man dann mehreren Instanzen eine gemeinsame WndProc gibt, dann wirds wieder nichtmehr funktionieren das stimmt.</p>
<p>Ich weis ja net ob er das überhaupt braucht (mehrere die eine WndProc gemeinsam haben), aber wenn das so ist müsste man es wieder anders lösen.<br />
Dann stellt sich wieder die Frage ob jede Klasse/WndProc ihr eigenes Fenster hat oder welche gemeinsam nutzt....</p>
<p>Ich finde wir sollten aufhören uns hier irgendwelche Dinge auszudenken. Der soll mal genau sagen was er braucht dann bekommt er die beste Lösung! <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/883953</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883953</guid><dc:creator><![CDATA[_Ocin_]]></dc:creator><pubDate>Fri, 30 Sep 2005 23:42:44 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 23:45:07 GMT]]></title><description><![CDATA[<p>falsch!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883954</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883954</guid><dc:creator><![CDATA[°°]]></dc:creator><pubDate>Fri, 30 Sep 2005 23:45:07 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Fri, 30 Sep 2005 23:46:18 GMT]]></title><description><![CDATA[<p>°° schrieb:</p>
<blockquote>
<p>falsch!</p>
</blockquote>
<p>ok <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f60b.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_savoring_food"
      title=":yum:"
      alt="😋"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/883955</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883955</guid><dc:creator><![CDATA[richtig]]></dc:creator><pubDate>Fri, 30 Sep 2005 23:46:18 GMT</pubDate></item><item><title><![CDATA[Reply to WndProc on Sat, 01 Oct 2005 09:04:05 GMT]]></title><description><![CDATA[<p>Nagut, ich werd mal alles probieren.</p>
<p>Aber erstmal Danke, falls es auch nicht funktioniert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/883987</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/883987</guid><dc:creator><![CDATA[Tc++H]]></dc:creator><pubDate>Sat, 01 Oct 2005 09:04:05 GMT</pubDate></item></channel></rss>