<?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[Probleme mit GetOpenFileName]]></title><description><![CDATA[<pre><code class="language-cpp">void OpenFileBox(HWND hwnd)
{
   OPENFILENAME ofn;
   char szFileName[MAX_PATH] = &quot;&quot;;

   ZeroMemory(&amp;ofn, sizeof(ofn));

   ofn.lStructSize = sizeof(ofn);
   ofn.hwndOwner = hwnd;
   ofn.lpstrFilter = &quot;Bitmap (*.bmp)\0*.bmp\0&quot;
                     &quot;Alle Dateien (*.*)\0*.*\0&quot;;
   ofn.lpstrFile = szFileName;
   ofn.nMaxFile = MAX_PATH;
   ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |
               OFN_HIDEREADONLY;
   ofn.lpstrDefExt = &quot;bmp&quot;;

   if(GetOpenFileName(&amp;ofn))
      {
		 PAINTSTRUCT ps;
		 char str[200];
		 strcpy(str,ofn.lpstrInitialDir);
         HDC hDC;
		 hDC = BeginPaint(hwnd,&amp;ps);
		 SetTextColor(hDC,RGB(255,255,255));
		 TextOut(hDC,50,50,str,200);
		 EndPaint(hwnd,&amp;ps);
		 ReleaseDC(hwnd,hDC);
      }
}
</code></pre>
<p>Mein Ziel ist es hier eine Datei auszuwählen und dann ihren Pfad auf dem Bildschirm anzeigen zu lassen.<br />
Datei auswählen funktioniert, aber wenn ich sie ausgewählt habe,dann stürzt das Programm ab.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/162628/probleme-mit-getopenfilename</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 21:01:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/162628.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 20 Oct 2006 15:57:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit GetOpenFileName on Fri, 20 Oct 2006 15:57:48 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">void OpenFileBox(HWND hwnd)
{
   OPENFILENAME ofn;
   char szFileName[MAX_PATH] = &quot;&quot;;

   ZeroMemory(&amp;ofn, sizeof(ofn));

   ofn.lStructSize = sizeof(ofn);
   ofn.hwndOwner = hwnd;
   ofn.lpstrFilter = &quot;Bitmap (*.bmp)\0*.bmp\0&quot;
                     &quot;Alle Dateien (*.*)\0*.*\0&quot;;
   ofn.lpstrFile = szFileName;
   ofn.nMaxFile = MAX_PATH;
   ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |
               OFN_HIDEREADONLY;
   ofn.lpstrDefExt = &quot;bmp&quot;;

   if(GetOpenFileName(&amp;ofn))
      {
		 PAINTSTRUCT ps;
		 char str[200];
		 strcpy(str,ofn.lpstrInitialDir);
         HDC hDC;
		 hDC = BeginPaint(hwnd,&amp;ps);
		 SetTextColor(hDC,RGB(255,255,255));
		 TextOut(hDC,50,50,str,200);
		 EndPaint(hwnd,&amp;ps);
		 ReleaseDC(hwnd,hDC);
      }
}
</code></pre>
<p>Mein Ziel ist es hier eine Datei auszuwählen und dann ihren Pfad auf dem Bildschirm anzeigen zu lassen.<br />
Datei auswählen funktioniert, aber wenn ich sie ausgewählt habe,dann stürzt das Programm ab.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158451</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158451</guid><dc:creator><![CDATA[Tobi3000]]></dc:creator><pubDate>Fri, 20 Oct 2006 15:57:48 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetOpenFileName on Fri, 20 Oct 2006 17:24:40 GMT]]></title><description><![CDATA[<p>Hi,<br />
Das</p>
<blockquote>
<p>ofn.lpstrFilter = &quot;Bitmap (<em>.bmp)\0</em>.bmp\0&quot;<br />
&quot;Alle Dateien (<em>.</em>)\0*.*\0&quot;;</p>
</blockquote>
<p>muss so heisen</p>
<pre><code>ofn.lpstrFilter = &quot;Bitmap (*.bmp)\0*.bmp\0&quot;
                     &quot;Alle Dateien (*.*)\0*.*\0\0&quot;;
</code></pre>
<p>Die letzte Zeile musst du doppelt &quot;Nullen&quot;.<br />
Und das</p>
<blockquote>
<p>char str[200];<br />
strcpy(str,ofn.lpstrInitialDir);</p>
</blockquote>
<p>würde ich mir auch noch mal angucken. Oben nimmst du &quot;MAX_PATH&quot; und jetzt &quot;nur&quot; 200<br />
und lpstrInitialDir dafür hast du garkein speicher reserviert du kannst höchstens ofn.lpstrFile nehmen.<br />
Hoffe hab jetz kein mist erzählt <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>MfG schirrmie</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158462</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158462</guid><dc:creator><![CDATA[schirrmie]]></dc:creator><pubDate>Fri, 20 Oct 2006 17:24:40 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetOpenFileName on Fri, 20 Oct 2006 18:05:52 GMT]]></title><description><![CDATA[<p>schirrmie: String-Literale werden schon automatisch einmal null terminiert. Das hatten wir doch schon im anderen aktuellen Thread zu OFN.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158471</guid><dc:creator><![CDATA[2000]]></dc:creator><pubDate>Fri, 20 Oct 2006 18:05:52 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetOpenFileName on Fri, 20 Oct 2006 22:32:05 GMT]]></title><description><![CDATA[<p>Den Teil außerhalb der if-Schleife hab ich aus einem Tutorial kopiert und den Teil innerhalb der if-Schleife hab ich selbst geschrieben.<br />
Darum einmal MAX_PATH und einmal 200.</p>
<p>Ich hab jetzt statt</p>
<pre><code class="language-cpp">ofn.lpstrInitialDir
</code></pre>
<p>jetzt</p>
<pre><code class="language-cpp">ofn.lpstrFile
</code></pre>
<p>geschrieben und der Text wird angezeigt.</p>
<p>ofn.lpstrFile ist eh das was ich eigentlich gesucht habe also hat sich das Problem jetzt ganz erledigt. ^^</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1158490</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1158490</guid><dc:creator><![CDATA[Tobi3000]]></dc:creator><pubDate>Fri, 20 Oct 2006 22:32:05 GMT</pubDate></item></channel></rss>