<?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[übergabe hInstance]]></title><description><![CDATA[<p>Hi Leuts,.. icke wieder</p>
<p>Wenn ich ein Childwindow so erstelle:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static RECT rect;
static HWND hCheckBox;
switch(message)
    {
    case WM_CREATE:
        {
         hCheckBox = CreateWindowEx(WS_EX_TRANSPARENT,
                                   &quot;button&quot;,
                                   NULL,    
                                   WS_CHILD | WS_VISIBLE |BS_AUTOCHECKBOX ,
                                   0, 0, 13, 13,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);

...
</code></pre>
<p>wir das Instance Handle per</p>
<pre><code class="language-cpp">((LPCREATESTRUCT) lParam) -&gt; hInstance
</code></pre>
<p>übergeben, nun da ich mehrere checkboxen brauche habe ich mir eine kleine klasse geschrieben, als ich das instance handle übergeben wollte á la</p>
<pre><code class="language-cpp">checkbox box1(120,120,((LPCREATESTRUCT) lParam) -&gt; hInstance,wParam,lParam,hWnd);
</code></pre>
<p>(bzw. im constructor aus lparam)<br />
bekamm ich immer ne nette fehlermeldung</p>
<blockquote>
<p>IC.EXE hat ein Problem festgestellt und muss beendet werden.<br />
AppName: ic.exe AppVer: 0.0.0.0 ModName: ic.exe<br />
ModVer: 0.0.0.0 Offset: 000014c1</p>
</blockquote>
<p>Kopiere ich hingegen in der Winmain die winclass instance in eine globale variable und rufe</p>
<pre><code class="language-cpp">checkbox box1(120,120,hGlobalInst,wParam,lParam,hWnd);
</code></pre>
<p>auf, funktioniert es einwandfrei.</p>
<p>Anscheinend habe ich da irgendetwas nicht richtig verstanden.</p>
<p>Kann mich mal jemand bitte aufklären!!</p>
<p>P.S.: bitte nicht folgendes zitieren:<br />
<strong>Instance Handle</strong></p>
<p>*Every window class requires an instance handle to identify the application or .dll that registered the class. The system requires instance handles to keep track of all of modules. The system assigns a handle to each copy of a running executable or .dll.</p>
<p>The system passes an instance handle to the entry-point function of each executable (see WinMain) and .dll (see DllMain). The executable or .dll assigns this instance handle to the class by copying it to the hInstance member of the WNDCLASSEX structure.</p>
<p>Windows 95/Windows 98/Windows Me: Multiple instances of the same application or .dll use the same code segment, but each has its own data segment. The system uses an instance handle to identify the data segment that corresponds to a particular instance of an application or .dll.<br />
*</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/227325/übergabe-hinstance</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 07:21:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/227325.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 13 Nov 2008 19:29:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to übergabe hInstance on Thu, 13 Nov 2008 19:29:07 GMT]]></title><description><![CDATA[<p>Hi Leuts,.. icke wieder</p>
<p>Wenn ich ein Childwindow so erstelle:</p>
<pre><code class="language-cpp">LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static RECT rect;
static HWND hCheckBox;
switch(message)
    {
    case WM_CREATE:
        {
         hCheckBox = CreateWindowEx(WS_EX_TRANSPARENT,
                                   &quot;button&quot;,
                                   NULL,    
                                   WS_CHILD | WS_VISIBLE |BS_AUTOCHECKBOX ,
                                   0, 0, 13, 13,
                                   hWnd,
                                   NULL,
                                   ((LPCREATESTRUCT) lParam) -&gt; hInstance,
                                   NULL);

...
</code></pre>
<p>wir das Instance Handle per</p>
<pre><code class="language-cpp">((LPCREATESTRUCT) lParam) -&gt; hInstance
</code></pre>
<p>übergeben, nun da ich mehrere checkboxen brauche habe ich mir eine kleine klasse geschrieben, als ich das instance handle übergeben wollte á la</p>
<pre><code class="language-cpp">checkbox box1(120,120,((LPCREATESTRUCT) lParam) -&gt; hInstance,wParam,lParam,hWnd);
</code></pre>
<p>(bzw. im constructor aus lparam)<br />
bekamm ich immer ne nette fehlermeldung</p>
<blockquote>
<p>IC.EXE hat ein Problem festgestellt und muss beendet werden.<br />
AppName: ic.exe AppVer: 0.0.0.0 ModName: ic.exe<br />
ModVer: 0.0.0.0 Offset: 000014c1</p>
</blockquote>
<p>Kopiere ich hingegen in der Winmain die winclass instance in eine globale variable und rufe</p>
<pre><code class="language-cpp">checkbox box1(120,120,hGlobalInst,wParam,lParam,hWnd);
</code></pre>
<p>auf, funktioniert es einwandfrei.</p>
<p>Anscheinend habe ich da irgendetwas nicht richtig verstanden.</p>
<p>Kann mich mal jemand bitte aufklären!!</p>
<p>P.S.: bitte nicht folgendes zitieren:<br />
<strong>Instance Handle</strong></p>
<p>*Every window class requires an instance handle to identify the application or .dll that registered the class. The system requires instance handles to keep track of all of modules. The system assigns a handle to each copy of a running executable or .dll.</p>
<p>The system passes an instance handle to the entry-point function of each executable (see WinMain) and .dll (see DllMain). The executable or .dll assigns this instance handle to the class by copying it to the hInstance member of the WNDCLASSEX structure.</p>
<p>Windows 95/Windows 98/Windows Me: Multiple instances of the same application or .dll use the same code segment, but each has its own data segment. The system uses an instance handle to identify the data segment that corresponds to a particular instance of an application or .dll.<br />
*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1614343</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1614343</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Thu, 13 Nov 2008 19:29:07 GMT</pubDate></item><item><title><![CDATA[Reply to übergabe hInstance on Thu, 13 Nov 2008 20:13:18 GMT]]></title><description><![CDATA[<p>ja lParam is nurn pointer auf CREATESTRUCT in WM_CREATE du scherznase. denn du ((LPCREATESTRUCT) 0) -&gt; hInstance machst isses klar daß es kracht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1614362</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1614362</guid><dc:creator><![CDATA[ascda]]></dc:creator><pubDate>Thu, 13 Nov 2008 20:13:18 GMT</pubDate></item><item><title><![CDATA[Reply to übergabe hInstance on Thu, 13 Nov 2008 20:17:38 GMT]]></title><description><![CDATA[<p>ok,.</p>
<p>wie würde es richtig sein wenn ich die instance ohne globale variable an meinen constructor übergeben will?</p>
<p>gruß und dank</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1614368</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1614368</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Thu, 13 Nov 2008 20:17:38 GMT</pubDate></item><item><title><![CDATA[Reply to übergabe hInstance on Thu, 13 Nov 2008 20:27:06 GMT]]></title><description><![CDATA[<p>Was für ein Problem hast Du mit einer globalen Variable? Es ist korrekt den Wert zu übergeben, denn Du bei WinMain oder DLLMain mitbekommen hast.</p>
<p>Ansonsten<br />
<a href="http://blog.m-ri.de/index.php/2007/12/12/die-unsitte-immer-getmodulehandlenull-fuer-hinstance-in-createwindow-und-registerclass-zu-verwenden/" rel="nofollow">http://blog.m-ri.de/index.php/2007/12/12/die-unsitte-immer-getmodulehandlenull-fuer-hinstance-in-createwindow-und-registerclass-zu-verwenden/</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1614373</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1614373</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Thu, 13 Nov 2008 20:27:06 GMT</pubDate></item><item><title><![CDATA[Reply to übergabe hInstance on Thu, 13 Nov 2008 20:40:32 GMT]]></title><description><![CDATA[<p>Die globale variable ist böse <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>,... hm ok passt schon,.. danke für den hinweis !</p>
<p><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>
]]></description><link>https://www.c-plusplus.net/forum/post/1614382</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1614382</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Thu, 13 Nov 2008 20:40:32 GMT</pubDate></item><item><title><![CDATA[Reply to übergabe hInstance on Wed, 03 Dec 2008 12:45:37 GMT]]></title><description><![CDATA[<p>Hi,<br />
jetzt habe ich ein linker prob mit der globalen hGlobalInst,</p>
<p>denn ich wollte ich die CALLBACK fkt's auslagern, und habe die global variable<br />
so</p>
<pre><code class="language-cpp">#ifndef GLOBAL_INSTANCE
#define GLOBAL_INSTANCE
HINSTANCE hGlobalInst;
#endif
</code></pre>
<p>eingebunden, damit der kompiler net meckert,<br />
jetzt hat aber der linker ein problem und gibt aus:</p>
<blockquote>
<p>wndproc.o: In function <code>ZSt3minIjERKT\_S2\_S2_': .../wndproc.cpp:(.bss+0x0): multiple definition of</code>hGlobalInst'<br />
main.o:C:/Dev-Cpp/include/c++/3.4.2/bits/locale_facets.tcc:2493: first defined here<br />
settingsproc.o: In function <code>ZSt3minIjERKT\_S2\_S2_': .../settingsproc.cpp:(.bss+0x0): multiple definition of</code>hGlobalInst'<br />
main.o:C:/Dev-Cpp/include/c++/3.4.2/bits/locale_facets.tcc:2493: first defined here<br />
collect2: ld returned 1 exit status</p>
</blockquote>
<p>ich habe jetzt gerade keine idee wie ich das umgehen kann,...</p>
<p>ich nutze mingw 3.4.2<br />
seid gegrüßt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1624905</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1624905</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Wed, 03 Dec 2008 12:45:37 GMT</pubDate></item><item><title><![CDATA[Reply to übergabe hInstance on Wed, 03 Dec 2008 14:36:19 GMT]]></title><description><![CDATA[<p>Ich kenne Mingw nicht, aber hast Du dasim Header definiert? Dann musst Du extern davor setzen. Und in einer CPP datei die Variable ohne xtern.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1624967</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1624967</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Wed, 03 Dec 2008 14:36:19 GMT</pubDate></item><item><title><![CDATA[Reply to übergabe hInstance on Fri, 12 Dec 2008 19:43:44 GMT]]></title><description><![CDATA[<p>Ahh, siehste Martin ich hatte noch garnet geantwortet,</p>
<p>jo hat funktioniert, danke <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/1629679</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1629679</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Fri, 12 Dec 2008 19:43:44 GMT</pubDate></item></channel></rss>