<?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[LoadImage liefert bei mir immer NULL zurück?]]></title><description><![CDATA[<p>Hallo liebe Forum-Mitglieder,</p>
<p>ich habe zurzeit ein Problem mit der Funktion LoadImage.</p>
<p>Hierzu hier ein Wenig Code:</p>
<pre><code class="language-cpp">CFile file;
	CFileException err;

	if (!file.Open(bitmap, CFile::modeRead, &amp;err))
	{
		FileNotFoundException* fErr = new FileNotFoundException(L&quot;Could not locate file!&quot;, bitmap);
		throw fErr;
	}

	HBITMAP test = (HBITMAP) LoadImage(AfxGetResourceHandle(), bitmap, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);

	if (test == NULL)
	{
		DWORD error = GetLastError();
	}

	m_pictureBox.SetBitmap(test);
</code></pre>
<p>Also das File existiert, wird auch vom Benutzer ausgewählt, und wirklich auf Bitmaps beschränkt. (Mal das Schließen der OpenFileDialogBox, ohne Auswählen eines Files ausgenommen).</p>
<p>Warum liefert mir die Funktion LoadImage hier NULL? An anderer Stelle lade ich erfolgreich ein Icon File, mit analoger Herangehensweise.</p>
<p>Der Fehlercode der rauskommt lautet numerisch 2, was bedeutet das, und vor allem, wo kann ich denn eine Fehlertabelle hierzu finden?</p>
<p>Für Hilfe wäre ich sehr dankbar.</p>
<p>Gruß<br />
Norman-Timo</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/150098/loadimage-liefert-bei-mir-immer-null-zurück</link><generator>RSS for Node</generator><lastBuildDate>Mon, 20 Jul 2026 11:15:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/150098.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 13 Jun 2006 07:35:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to LoadImage liefert bei mir immer NULL zurück? on Tue, 13 Jun 2006 07:35:11 GMT]]></title><description><![CDATA[<p>Hallo liebe Forum-Mitglieder,</p>
<p>ich habe zurzeit ein Problem mit der Funktion LoadImage.</p>
<p>Hierzu hier ein Wenig Code:</p>
<pre><code class="language-cpp">CFile file;
	CFileException err;

	if (!file.Open(bitmap, CFile::modeRead, &amp;err))
	{
		FileNotFoundException* fErr = new FileNotFoundException(L&quot;Could not locate file!&quot;, bitmap);
		throw fErr;
	}

	HBITMAP test = (HBITMAP) LoadImage(AfxGetResourceHandle(), bitmap, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);

	if (test == NULL)
	{
		DWORD error = GetLastError();
	}

	m_pictureBox.SetBitmap(test);
</code></pre>
<p>Also das File existiert, wird auch vom Benutzer ausgewählt, und wirklich auf Bitmaps beschränkt. (Mal das Schließen der OpenFileDialogBox, ohne Auswählen eines Files ausgenommen).</p>
<p>Warum liefert mir die Funktion LoadImage hier NULL? An anderer Stelle lade ich erfolgreich ein Icon File, mit analoger Herangehensweise.</p>
<p>Der Fehlercode der rauskommt lautet numerisch 2, was bedeutet das, und vor allem, wo kann ich denn eine Fehlertabelle hierzu finden?</p>
<p>Für Hilfe wäre ich sehr dankbar.</p>
<p>Gruß<br />
Norman-Timo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1076679</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1076679</guid><dc:creator><![CDATA[norman_timo]]></dc:creator><pubDate>Tue, 13 Jun 2006 07:35:11 GMT</pubDate></item><item><title><![CDATA[Reply to LoadImage liefert bei mir immer NULL zurück? on Tue, 13 Jun 2006 08:14:39 GMT]]></title><description><![CDATA[<p><a href="https://www.google.de/search?&amp;q=site%3Amsdn.microsoft.com%20LoadImage" rel="nofollow">Google: site:msdn.microsoft.com LoadImage</a></p>
<p>Da scheint etwas mit deinen Parametern nicht zu stimmen:</p>
<blockquote>
<p>hinst:<br />
To load a stand-alone resource (icon, cursor, or bitmap file)Â—for example, c:\myimage.bmpÂ—set this parameter to NULL.</p>
</blockquote>
<p>Ansonsten könntest du den Fehlercode auch durch FormatMessage() jagen, um eine Textversion dazu zu bekommen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1076700</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1076700</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Tue, 13 Jun 2006 08:14:39 GMT</pubDate></item><item><title><![CDATA[Reply to LoadImage liefert bei mir immer NULL zurück? on Tue, 13 Jun 2006 08:33:13 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=4" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1076713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1076713</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Tue, 13 Jun 2006 08:33:13 GMT</pubDate></item><item><title><![CDATA[Reply to LoadImage liefert bei mir immer NULL zurück? on Tue, 13 Jun 2006 08:41:26 GMT]]></title><description><![CDATA[<p>Hallo CStoll,</p>
<p>zunächst vielen Dank, aber es brachte mir nicht die Lösung, durch die Änderung des hInst auf 0 änderte sich leider überhaupt nichts.</p>
<p>Trotzdem hatte ich das in der MSDN Hilfe übersehen.</p>
<p>Jetzt würd ich doch zu gerne wissen, wie ich mit einem DWORD und FormatMessage an eine Textform des Errors kommen soll?</p>
<p>Vielen Dank,<br />
Norman-Timo</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1076719</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1076719</guid><dc:creator><![CDATA[norman_timo]]></dc:creator><pubDate>Tue, 13 Jun 2006 08:41:26 GMT</pubDate></item><item><title><![CDATA[Reply to LoadImage liefert bei mir immer NULL zurück? on Tue, 13 Jun 2006 08:57:18 GMT]]></title><description><![CDATA[<p>so zum Beispiel:</p>
<pre><code class="language-cpp">#include &lt;string&gt;

#include &lt;windows.h&gt;

using namespace std;

string get_errmsg( unsigned long error )
{
    void *buffer;
    FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
        0,
        error,
        MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
        reinterpret_cast&lt; char* &gt;( &amp;buffer ),
        0,
        0
    );

    string errmsg = string( reinterpret_cast&lt; char* &gt;( buffer ) );
    LocalFree( buffer );
    return errmsg;
}

int WinMain( HINSTANCE instance, HINSTANCE prev_instance, char *cmd_line, int show_state )
{
    if( !SomeWinAPIFunctionWhichResultsInAnError( ) ) {
        string errmsg = get_errmsg( GetLastError( ) );
        MessageBox( 0, errmsg.c_str(), &quot;Error:&quot;, MB_OK );
    }
}
</code></pre>
<p>Greetz, Swordfish</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1076736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1076736</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Tue, 13 Jun 2006 08:57:18 GMT</pubDate></item><item><title><![CDATA[Reply to LoadImage liefert bei mir immer NULL zurück? on Tue, 13 Jun 2006 11:47:31 GMT]]></title><description><![CDATA[<p>Vielen Dank an Dich Swordfish,</p>
<p>ich benutze zwar eine UNICODE Umgebung, aber den cast entsprechend anzupassen, das war kein Problem.</p>
<p>Mit Hilfe des Errortexts kam mir auch gleich die Lösung zugeflogen:<br />
&quot;Der Prozess kann nicht auf die Datei zugreifen, da sie von einem anderen Prozess verwendet wird.&quot;</p>
<p>-&gt; Warum?<br />
WEIL: ich vergessen hatte das CFile vor dem LoadImage zu schließen *HandAufDieStirnKlatsch* <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>Also gut, Ende gut, alles gut...</p>
<p>Norman-Timo</p>
<p>P.S.: Gibt es eine elegantere Möglichkeit, zu überprüfen, ob ein File vorhanden ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1076832</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1076832</guid><dc:creator><![CDATA[norman_timo]]></dc:creator><pubDate>Tue, 13 Jun 2006 11:47:31 GMT</pubDate></item><item><title><![CDATA[Reply to LoadImage liefert bei mir immer NULL zurück? on Tue, 13 Jun 2006 14:34:13 GMT]]></title><description><![CDATA[<p>norman_timo schrieb:</p>
<blockquote>
<p>P.S.: Gibt es eine elegantere Möglichkeit, zu überprüfen, ob ein File vorhanden ist?</p>
</blockquote>
<p>GetFileAttributes</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1076934</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1076934</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Tue, 13 Jun 2006 14:34:13 GMT</pubDate></item></channel></rss>