<?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[Openfilename]]></title><description><![CDATA[<p>Ich möchte sobald ich einen Button drücke, dass sich ein File Browser öffnet. Dazu habe ich folgenden Code gefunden:</p>
<pre><code>OPENFILENAME ofn;
	char szFile[260];       // buffer for filename
	              // owner window
	HANDLE hf; 

	ZeroMemory(&amp;ofn, sizeof(OPENFILENAME));
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = IDD_KODIERUNG_DIALOG; 
	ofn.lpstrFile = szFile;
	ofn.nMaxFile = sizeof(szFile);
	ofn.lpstrFilter = &quot;All\0*.*\0Text\0*.TXT\0&quot;;
	ofn.nFilterIndex = 1;
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = NULL;
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

	if (GetOpenFileName(&amp;ofn)==TRUE) 
       hf = CreateFile(ofn.lpstrFile, GENERIC_READ,
        0, (LPSECURITY_ATTRIBUTES) NULL,
        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
        (HANDLE) NULL);
</code></pre>
<p>Nun habe ich das Problem, dass ich nicht weiß was ich unter ofn.hwndOwner eingeben muß. Eigentlich muß dort doch der Handle vom aktuellen Fenster rein oder? Kann mir da vielleicht jemand weiterhelfen?</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/155619/openfilename</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Jul 2026 03:24:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/155619.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 08 Aug 2006 05:18:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Openfilename on Tue, 08 Aug 2006 05:18:58 GMT]]></title><description><![CDATA[<p>Ich möchte sobald ich einen Button drücke, dass sich ein File Browser öffnet. Dazu habe ich folgenden Code gefunden:</p>
<pre><code>OPENFILENAME ofn;
	char szFile[260];       // buffer for filename
	              // owner window
	HANDLE hf; 

	ZeroMemory(&amp;ofn, sizeof(OPENFILENAME));
	ofn.lStructSize = sizeof(OPENFILENAME);
	ofn.hwndOwner = IDD_KODIERUNG_DIALOG; 
	ofn.lpstrFile = szFile;
	ofn.nMaxFile = sizeof(szFile);
	ofn.lpstrFilter = &quot;All\0*.*\0Text\0*.TXT\0&quot;;
	ofn.nFilterIndex = 1;
	ofn.lpstrFileTitle = NULL;
	ofn.nMaxFileTitle = 0;
	ofn.lpstrInitialDir = NULL;
	ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

	if (GetOpenFileName(&amp;ofn)==TRUE) 
       hf = CreateFile(ofn.lpstrFile, GENERIC_READ,
        0, (LPSECURITY_ATTRIBUTES) NULL,
        OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
        (HANDLE) NULL);
</code></pre>
<p>Nun habe ich das Problem, dass ich nicht weiß was ich unter ofn.hwndOwner eingeben muß. Eigentlich muß dort doch der Handle vom aktuellen Fenster rein oder? Kann mir da vielleicht jemand weiterhelfen?</p>
<p>Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1112667</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1112667</guid><dc:creator><![CDATA[Bruschnik]]></dc:creator><pubDate>Tue, 08 Aug 2006 05:18:58 GMT</pubDate></item><item><title><![CDATA[Reply to Openfilename on Tue, 08 Aug 2006 05:54:43 GMT]]></title><description><![CDATA[<p>Jo, mit einem Zeiger auf's parent müsste das gehen. Versuch's doch einfach mal mit &quot;this&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1112676</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1112676</guid><dc:creator><![CDATA[Neron17]]></dc:creator><pubDate>Tue, 08 Aug 2006 05:54:43 GMT</pubDate></item><item><title><![CDATA[Reply to Openfilename on Tue, 08 Aug 2006 06:26:16 GMT]]></title><description><![CDATA[<p>Was ist wenn ich m_hWnd benutze? Ist das korrekt oder falsch?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1112690</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1112690</guid><dc:creator><![CDATA[Bruschnik]]></dc:creator><pubDate>Tue, 08 Aug 2006 06:26:16 GMT</pubDate></item><item><title><![CDATA[Reply to Openfilename on Tue, 08 Aug 2006 06:45:16 GMT]]></title><description><![CDATA[<p>Wenn du in einer CWnd abgeleiteten Klasse bist... geht das auch...</p>
<p>ABER: Wir sind hier in MFC... da wird sowas nicht so gemacht!</p>
<pre><code class="language-cpp">HANDLE      hFile       = NULL;
const char  szFilters[] = &quot;Textdatei (*.txt)|*.txt|Alle Dateien (*.*)|*.*||&quot;;
CFileDialog dlgFile(TRUE, &quot;txt&quot;, &quot;*.txt&quot;, OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST, szFilters, this);

if (dlgFile.DoModal() == IDOK)
    ::CreateFile(dlgFile.GetFileName(), GENERIC_READ, 0, (LPSECURITY_ATTRIBUTES)NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL); 

if (!hFile)
    return false;
</code></pre>
<p>So in etwa ist es besser <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><strong>Referenzen:</strong><br />
<a href="http://msdn2.microsoft.com/en-us/library/dk77e5e7.aspx" rel="nofollow">CFileDialog Class</a><br />
<a href="http://msdn2.microsoft.com/en-us/library/3xb6dhth.aspx" rel="nofollow">CFileDialog::DoModal</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1112700</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1112700</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Tue, 08 Aug 2006 06:45:16 GMT</pubDate></item><item><title><![CDATA[Reply to Openfilename on Tue, 08 Aug 2006 07:23:00 GMT]]></title><description><![CDATA[<p>Ok! SUPER Vielen Dank! Es geht <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/1112725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1112725</guid><dc:creator><![CDATA[Bruschnik]]></dc:creator><pubDate>Tue, 08 Aug 2006 07:23:00 GMT</pubDate></item></channel></rss>