<?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[txt-File auslesen und in Listbox anzeigen?]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe heute folgendes Problemchen.<br />
Ich bin neu in der WinAPI Welt und muss mich für die Schule in die Materie einarbeiten (und das ganze in 5 Tagen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> )</p>
<p>Also ich habe bis jetzt folgendes Grundgerüst:</p>
<pre><code class="language-cpp">//----------------------------------------------------------
// Besondere Lernleistung - Physik/TeWi - Stephan Liebig
// Projekt: Digitaler Fahrtenschreiber
// Tool: Auslesen des Mikrokontrollers (Anzeige der IDs)
// Last Build: 23.03.2007   v.0.0.2
//----------------------------------------------------------

#include &lt;windows.h&gt;
#include &lt;exception&gt;

#define ID_ladedaten 1001 // Button: Lade Daten aus Mikrokontroller
#define ID_speichern 1002 // Button: Speicher geladene Daten 
#define ID_listbox 1003 // Ausgabeliste fuer die IDs, die vom mC aufgezeichnet wurden
#define ID_about 1004 // Button: about 

bool Running = true;

LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_CREATE:
		{

			CreateWindowA(&quot;button&quot;, &quot;Daten Laden&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 10, 10, 100, 40, hwnd, (HMENU)ID_ladedaten, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			CreateWindowA(&quot;button&quot;, &quot;Speichern&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 120, 10, 100, 40, hwnd, (HMENU)ID_speichern, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			CreateWindowA(&quot;button&quot;, &quot;Projekt&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 230, 10, 100, 40, hwnd, (HMENU)ID_about, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			CreateWindowA(&quot;listbox&quot;, NULL, WS_CHILD | WS_VISIBLE | LBS_STANDARD ^ LBS_SORT | LBS_HASSTRINGS, 10, 60, 300, 500, hwnd, (HMENU)ID_listbox, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL); 

		}
	case WM_KEYDOWN:
		switch(wParam)
		{
		case VK_ESCAPE:
			SendMessage(hwnd, WM_CLOSE, 0, 0);
			break;
		}
		case WM_COMMAND:
		{
			if (HIWORD(wParam) == BN_CLICKED)
			{
				switch(LOWORD(wParam))
				{
				case ID_ladedaten:
					//Eine Txt Laden
					break;

				case ID_speichern:
					//Daten in einer *.txt abspeichern
					SendMessage(hwnd, WM_CLOSE, 0, 0); //Für Testzwecke Fenster schließen
					break;

				case ID_\1:
					//Übers Projekt
					break;
				}
			}
		}
		break;

	case WM_CLOSE:
		{
			DestroyWindow(hwnd);
			return TRUE;
		}
		break;

	case WM_DESTROY:
		{
			Running = false;
			PostQuitMessage(0);
			return 0;
		}
		break;
	}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR szCmdLine, int nCmdShow)
{
	try
	{
		unsigned int hr;
		HWND hwnd;

		WNDCLASSEX winclass;
		memset(&amp;winclass, 0, sizeof(winclass));

		winclass.cbSize        = sizeof(winclass);
		winclass.style         = CS_HREDRAW | CS_VREDRAW;
		winclass.lpfnWndProc   = WindowProc;
		winclass.cbClsExtra    = 0;
		winclass.cbWndExtra    = 0;
		winclass.hInstance     = GetModuleHandle(NULL);
		winclass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
		winclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
		winclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
		winclass.lpszMenuName  = NULL;
		winclass.lpszClassName = L&quot;WindowClass&quot;;
		winclass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

		if(!(hr = ::RegisterClassEx(&amp;winclass)))
		{
			// error
		}

		hwnd = ::CreateWindow(L&quot;WindowClass&quot;, L&quot;Digitaler Fahrtenschreiber | Testtool&quot;, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 200, 300, 600, 700, GetDesktopWindow(), NULL, winclass.hInstance, NULL);
		if(!hwnd)
		{
			// error
		}

		MSG msg;
		memset(&amp;msg, 0, sizeof(msg));

		while(Running)
		{
			if(PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))
			{
				TranslateMessage(&amp;msg);
				DispatchMessage(&amp;msg);
			}
			else
			{
			}
		}
	}
	catch(const std::exception &amp;e)
	{
		MessageBoxA(0, &quot;exception&quot;, e.what(), MB_OK);
	}
	catch(...)
	{
		MessageBoxA(0, &quot;unknown exception&quot;, &quot;eroor&quot;, MB_OK);
	}

	return 0;
}
</code></pre>
<p>Die txt-File, die ausgelesen wird, liegt dabei immer an einer Stelle, die nicht verändert wird. Daher möchte ich diese schon im Programmcode festlegen.<br />
Die Datei enthält dabei 3 Informationen pro Zeile.<br />
Kann mir jemand helfen, wie ich solch eine Auslese und in meiner Listbox anzeige?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/176814/txt-file-auslesen-und-in-listbox-anzeigen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Jul 2026 16:25:55 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/176814.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Mar 2007 12:08:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 12:17:23 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe heute folgendes Problemchen.<br />
Ich bin neu in der WinAPI Welt und muss mich für die Schule in die Materie einarbeiten (und das ganze in 5 Tagen <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /> )</p>
<p>Also ich habe bis jetzt folgendes Grundgerüst:</p>
<pre><code class="language-cpp">//----------------------------------------------------------
// Besondere Lernleistung - Physik/TeWi - Stephan Liebig
// Projekt: Digitaler Fahrtenschreiber
// Tool: Auslesen des Mikrokontrollers (Anzeige der IDs)
// Last Build: 23.03.2007   v.0.0.2
//----------------------------------------------------------

#include &lt;windows.h&gt;
#include &lt;exception&gt;

#define ID_ladedaten 1001 // Button: Lade Daten aus Mikrokontroller
#define ID_speichern 1002 // Button: Speicher geladene Daten 
#define ID_listbox 1003 // Ausgabeliste fuer die IDs, die vom mC aufgezeichnet wurden
#define ID_about 1004 // Button: about 

bool Running = true;

LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch(msg)
	{
	case WM_CREATE:
		{

			CreateWindowA(&quot;button&quot;, &quot;Daten Laden&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 10, 10, 100, 40, hwnd, (HMENU)ID_ladedaten, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			CreateWindowA(&quot;button&quot;, &quot;Speichern&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 120, 10, 100, 40, hwnd, (HMENU)ID_speichern, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			CreateWindowA(&quot;button&quot;, &quot;Projekt&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 230, 10, 100, 40, hwnd, (HMENU)ID_about, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			CreateWindowA(&quot;listbox&quot;, NULL, WS_CHILD | WS_VISIBLE | LBS_STANDARD ^ LBS_SORT | LBS_HASSTRINGS, 10, 60, 300, 500, hwnd, (HMENU)ID_listbox, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL); 

		}
	case WM_KEYDOWN:
		switch(wParam)
		{
		case VK_ESCAPE:
			SendMessage(hwnd, WM_CLOSE, 0, 0);
			break;
		}
		case WM_COMMAND:
		{
			if (HIWORD(wParam) == BN_CLICKED)
			{
				switch(LOWORD(wParam))
				{
				case ID_ladedaten:
					//Eine Txt Laden
					break;

				case ID_speichern:
					//Daten in einer *.txt abspeichern
					SendMessage(hwnd, WM_CLOSE, 0, 0); //Für Testzwecke Fenster schließen
					break;

				case ID_\1:
					//Übers Projekt
					break;
				}
			}
		}
		break;

	case WM_CLOSE:
		{
			DestroyWindow(hwnd);
			return TRUE;
		}
		break;

	case WM_DESTROY:
		{
			Running = false;
			PostQuitMessage(0);
			return 0;
		}
		break;
	}

	return DefWindowProc(hwnd, msg, wParam, lParam);
}

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR szCmdLine, int nCmdShow)
{
	try
	{
		unsigned int hr;
		HWND hwnd;

		WNDCLASSEX winclass;
		memset(&amp;winclass, 0, sizeof(winclass));

		winclass.cbSize        = sizeof(winclass);
		winclass.style         = CS_HREDRAW | CS_VREDRAW;
		winclass.lpfnWndProc   = WindowProc;
		winclass.cbClsExtra    = 0;
		winclass.cbWndExtra    = 0;
		winclass.hInstance     = GetModuleHandle(NULL);
		winclass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
		winclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
		winclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
		winclass.lpszMenuName  = NULL;
		winclass.lpszClassName = L&quot;WindowClass&quot;;
		winclass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

		if(!(hr = ::RegisterClassEx(&amp;winclass)))
		{
			// error
		}

		hwnd = ::CreateWindow(L&quot;WindowClass&quot;, L&quot;Digitaler Fahrtenschreiber | Testtool&quot;, WS_OVERLAPPEDWINDOW | WS_VISIBLE, 200, 300, 600, 700, GetDesktopWindow(), NULL, winclass.hInstance, NULL);
		if(!hwnd)
		{
			// error
		}

		MSG msg;
		memset(&amp;msg, 0, sizeof(msg));

		while(Running)
		{
			if(PeekMessage(&amp;msg, NULL, 0, 0, PM_REMOVE))
			{
				TranslateMessage(&amp;msg);
				DispatchMessage(&amp;msg);
			}
			else
			{
			}
		}
	}
	catch(const std::exception &amp;e)
	{
		MessageBoxA(0, &quot;exception&quot;, e.what(), MB_OK);
	}
	catch(...)
	{
		MessageBoxA(0, &quot;unknown exception&quot;, &quot;eroor&quot;, MB_OK);
	}

	return 0;
}
</code></pre>
<p>Die txt-File, die ausgelesen wird, liegt dabei immer an einer Stelle, die nicht verändert wird. Daher möchte ich diese schon im Programmcode festlegen.<br />
Die Datei enthält dabei 3 Informationen pro Zeile.<br />
Kann mir jemand helfen, wie ich solch eine Auslese und in meiner Listbox anzeige?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252168</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252168</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 12:17:23 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 12:10:06 GMT]]></title><description><![CDATA[<p>Zeig mal genau wie das Textfile aussehen soll ...<br />
Brauchst ne Lösung in C oder C++?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252173</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252173</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 25 Mar 2007 12:10:06 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 12:17:04 GMT]]></title><description><![CDATA[<p>Ich bräuchte die Lösung in C++</p>
<p>Die Textfile (save_logs.txt) sieht z.B. so aus:</p>
<p>24.03.2007 | 12:42:45 | 56<br />
24.03.2007 | 12:42:55 | 57<br />
24.03.2007 | 12:43:20 | 54<br />
24.03.2007 | 12:43:25 | 50<br />
24.03.2007 | 12:43:45 | 35<br />
24.03.2007 | 12:44:15 | 45</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252178</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252178</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 12:17:04 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 12:26:31 GMT]]></title><description><![CDATA[<p>ja das ist doch gut ... dann guck dir mal std::fstream und std::getline und std::string an (s. <a href="http://www.cppreference.com/cppio/index.html" rel="nofollow">http://www.cppreference.com/cppio/index.html</a>, <a href="http://www.cppreference.com/cppstring/getline.html" rel="nofollow">http://www.cppreference.com/cppstring/getline.html</a>, <a href="http://www.cppreference.com/cppstring/index.html" rel="nofollow">http://www.cppreference.com/cppstring/index.html</a>) <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/1252185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252185</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 25 Mar 2007 12:26:31 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 12:40:39 GMT]]></title><description><![CDATA[<p>Danke für deine Links, wobei dort nur der letzte 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>
<p>Also um die txt zu öffnen brauche ich noch:</p>
<pre><code class="language-cpp">#include &lt;fstream&gt;
  void open( const char *filename );
  void open( const char *filename, openmode mode = default_mode );
</code></pre>
<p>und dann noch</p>
<pre><code class="language-cpp">ifstream inputStream;
inputStream.open(&quot;file.txt&quot;);
   if( !inputStream ) {
	//error &quot;Error opening input stream&quot;;
	return 0;
   }
</code></pre>
<p>Allerdings bekomme ich dann folgende Fehler:</p>
<p>error C2061: syntax error : identifier 'openmode'<br />
error C2065: 'ifstream' : undeclared identifier<br />
error C2146: syntax error : missing ';' before identifier 'inputStream'<br />
error C2065: 'inputStream' : undeclared identifier<br />
error C2228: left of '.open' must have class/struct/union</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252187</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252187</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 12:40:39 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 13:56:33 GMT]]></title><description><![CDATA[<p>ja ka was du da machst ^^</p>
<pre><code class="language-cpp">#include &lt;iostream&gt; // für std::cout
#include &lt;fstream&gt; // für std::fstream
#include &lt;string&gt; // für std::string und std::getline

int main()
{
    std::ifstream file_stream(&quot;file.txt&quot;, std::ios::in); // Datei zum Lesen öffnen
    if (!file_stream) // Konnte die Datei geöffnet werden?
    {
        std::cout &lt;&lt; &quot;Could not open file \&quot;file.txt\&quot;!&quot; &lt;&lt; std::endl;
        return 0;
    }

    std::string string_input;
    while (std::geline(file_stream, string_input)) // Solange getline klappt immer eine Zeile aus der Datei auslesen ...
        std::cout &lt;&lt; string_input &lt;&lt; std::endl; // Und einfach ausgeben ... kannst hier auch was anderes machen ;)

    file_stream.close(); // Datei auch wieder schließen!

    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1252199</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252199</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 25 Mar 2007 13:56:33 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 13:25:32 GMT]]></title><description><![CDATA[<p>Bitte schlag mich jetzt, wenn ich falsch liege.<br />
Dein Code ist doch jetzt für eine Konsolenapllikation oder?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252214</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252214</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 13:25:32 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 13:55:30 GMT]]></title><description><![CDATA[<p>hmm ja das std::cout und das int main ... ^^<br />
mach halt aus</p>
<pre><code class="language-cpp">std::ifstream file_stream(&quot;file.txt&quot;, std::ios::in);
if (!file_stream)
{
    std::cout &lt;&lt; &quot;Could not open file \&quot;file.txt\&quot;!&quot; &lt;&lt; std::endl;
    return 0;
}
</code></pre>
<p>einfach</p>
<pre><code class="language-cpp">std::ifstream file_stream(&quot;file.txt&quot;, std::ios::in);
if (!file_stream)
{
    MessageBox(NULL, &quot;Could not open file \&quot;file.txt\&quot;!&quot;, NULL, MB_OK | MB_ICONERROR);
    return 0;
}
</code></pre>
<p>und anstelle von</p>
<pre><code class="language-cpp">std::cout &lt;&lt; string_input &lt;&lt; std::endl;
</code></pre>
<p>packst du das was in string_input steht in deine ListBox ... und fertig. Allerdings muss du den Code noch anpassen ... so das der nicht die ganze Zeile ausließt sondern nur das was du brauchst <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/1252224</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252224</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 25 Mar 2007 13:55:30 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 15:04:22 GMT]]></title><description><![CDATA[<p>Also habe ich jetzt folgendes:</p>
<pre><code class="language-cpp">case ID_ladedaten:
	//Daten aus einer txt lesen
	std::ifstream file_stream(&quot;C:/Dokumente und Einstellungen/Odenwaelder/Desktop/Stephan/13bgdw/besondere lernleistung/programme/opener/txtopener/save_logs.txt&quot;, std::ios::in);
	if (!file_stream)
	{
	    //MessageBox(NULL, &quot;Could not open file \&quot;file.txt\&quot;!&quot;, NULL, MB_OK | MB_ICONERROR);
	    MessageBox(hwnd,TEXT(&quot;Die Datei konnte nicht geladen werden&quot;), TEXT(&quot;ERROR: Lade Daten&quot;), MB_OK | MB_ICONERROR);
	    return 0;
	}
break;
</code></pre>
<p>Aber ich bekomme noch folgende Fehlermeldungen:</p>
<p>error C2360: initialization of 'file_stream' is skipped by 'case' label</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252262</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252262</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 15:04:22 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 15:18:49 GMT]]></title><description><![CDATA[<p>hmm ja scheinst ja noch nicht soo gefestigt in den Grundlagen zu sein ...</p>
<pre><code class="language-cpp">case ID_ladedaten:
{ // !!! Wenn du Variablen deklarieren willst !!!
    std::ifstream file_stream(&quot;C:\\Dokumente und Einstellungen\\Odenwaelder\\Desktop\\Stephan\\13bgdw\\besondere lernleistung\\programme\\opener\\txtopener\\save_logs.txt&quot;, std::ios::in);
    if (!file_stream)
    {
        MessageBox(hwnd,TEXT(&quot;Die Datei konnte nicht geöffnet werden&quot;), NULL, MB_OK | MB_ICONERROR);
        break;
    }
    file_stream.close() // Nicht vergessen ;)
} break; // !!! Und wieder schließen !!!
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1252266</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252266</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 25 Mar 2007 15:18:49 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 15:30:45 GMT]]></title><description><![CDATA[<p>Hopla, das die geschweiften Klammern fehlen, hätte mir eigentlich auffallen müssen. Aber irgendwie...</p>
<p>Ich bin auch wirklich noch ein Anfänger, aber ich hoffe das ich das bald ändern kann <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>
<p>Okay, das funktioniert anscheind.<br />
Jetzt fehlt mir noch die Weitergabe an die Listbox <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="😕"
    /><br />
Das geht dann über SendMessage() ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252278</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252278</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 15:30:45 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 15:58:03 GMT]]></title><description><![CDATA[<p>Hmm könnte Probleme geben, dass c_str nicht Null-Terminiert ist ... naja:</p>
<pre><code class="language-cpp">case ID_ladedaten:
{
    std::ifstream file_stream(&quot;C:\\Dokumente und Einstellungen\\Odenwaelder\\Desktop\\Stephan\\13bgdw\\besondere lernleistung\\programme\\opener\\txtopener\\save_logs.txt&quot;, std::ios::in);
    if (!file_stream)
    {
        MessageBox(hwnd,TEXT(&quot;Die Datei konnte nicht geöffnet werden&quot;), NULL, MB_OK | MB_ICONERROR);
        break;
    }
    std::string string_input;
    while (std::getline(file_stream, string_input))
        SendMessage(hWndList, LB_ADDSTRING, 0, string_input.c_str());

    file_stream.close()
} break;
</code></pre>
<p>so in etwa ..</p>
<p><strong>Referenz:</strong><br />
<a href="http://msdn2.microsoft.com/en-us/library/ms671405.aspx" rel="nofollow">LB_ADDSTRING Message</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252296</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252296</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 25 Mar 2007 15:58:03 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 16:14:31 GMT]]></title><description><![CDATA[<p>Bekomme den Fehler:</p>
<p>error C2664: 'SendMessageW' : cannot convert parameter 4 from 'const char *' to 'LPARAM'</p>
<pre><code class="language-cpp">LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static HWND        hwndlist; 
	switch(msg)
	{
	case WM_CREATE:
		{

			CreateWindowA(&quot;button&quot;, &quot;Daten Laden&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 10, 10, 100, 40, hwnd, (HMENU)ID_ladedaten, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			CreateWindowA(&quot;button&quot;, &quot;Speichern&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 120, 10, 100, 40, hwnd, (HMENU)ID_speichern, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			CreateWindowA(&quot;button&quot;, &quot;Projekt&quot;, WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 230, 10, 100, 40, hwnd, (HMENU)ID_about, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL);
			hwndlist = CreateWindowA(&quot;listbox&quot;, NULL, WS_CHILD | WS_VISIBLE | LBS_STANDARD ^ LBS_SORT | LBS_HASSTRINGS, 10, 60, 300, 500, hwnd, (HMENU)ID_listbox, ((LPCREATESTRUCT)lParam)-&gt;hInstance, NULL); 

		}
</code></pre>
<pre><code class="language-cpp">case ID_ladedaten:
					{
					//Daten aus einer txt lesen
					std::ifstream file_stream(&quot;C:/Dokumente und Einstellungen/Odenwaelder/Desktop/Stephan/13bgdw/besondere lernleistung/programme/opener/txtopener/save_logs.txt&quot;, std::ios::in);
					if (!file_stream)
					{
						//MessageBox(NULL, &quot;Could not open file \&quot;file.txt\&quot;!&quot;, NULL, MB_OK | MB_ICONERROR);
						MessageBox(hwnd,TEXT(&quot;Die Datei konnte nicht geladen werden&quot;), TEXT(&quot;ERROR: Lade Daten&quot;), MB_OK | MB_ICONERROR);
						return 0;
					}
					else
					{
						std::string string_input;
						while (std::getline(file_stream, string_input)) // Solange getline klappt immer eine Zeile aus der Datei auslesen
						{
							//Daten werden an die Listbox geschickt
							SendMessage(hwndlist, LB_ADDSTRING, 0, string_input.c_str()); 
						}
						file_stream.close(); //Datei wird nicht mehr gebraucht, also schließen!
					}
					}
					break;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1252309</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252309</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 16:14:31 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 17:07:09 GMT]]></title><description><![CDATA[<p>ich hab keine Lust dir alles vor zu kauen ... musst de halt casten ... hättest de in der Doc nachgeguckt, hättest de das auch selbst rausbekommen ...</p>
<p>reinterpret_cast&lt;LPARAM&gt;(string_line.c_str()) ... anstelle von string_line.c_str() ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252349</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252349</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 25 Mar 2007 17:07:09 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 19:24:17 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12713">@stephan</a>²: Du weißt, aber das WinAPI C-basiert ist und daher keine Exceptions auswirft, nech ?! ... Vergleiche hier:</p>
<p>stephan² schrieb:</p>
<blockquote>
<pre><code class="language-cpp">int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR szCmdLine, int nCmdShow)
{
    try
    {
        // ...
    }
    catch(const std::exception &amp;e)
    {
        MessageBoxA(0, &quot;exception&quot;, e.what(), MB_OK);
    }
    catch(...)
    {
        MessageBoxA(0, &quot;unknown exception&quot;, &quot;eroor&quot;, MB_OK);
    }
}
</code></pre>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1252482</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252482</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 25 Mar 2007 19:24:17 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 19:56:35 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12048">@CodeFinder</a></p>
<p>Ich glaube, ich kapiere gerade nicht, was mir das sagen soll.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252506</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 19:56:35 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 20:21:20 GMT]]></title><description><![CDATA[<p>stephan² schrieb:</p>
<blockquote>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/12048">@CodeFinder</a></p>
<p>Ich glaube, ich kapiere gerade nicht, was mir das sagen soll.</p>
</blockquote>
<p>Naja, Deine catch-Handler kommen nie zur Ausführung da Funktionen wie RegisterClass(Ex) und CreateWindow(Ex), etc ( <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> WinAPI-Funktionen) keine Exceptions auswerfen. Daher ist Dein Exceptions-Handling bei Deinem derzeitigen Code überflüssig <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/1252517</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252517</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 25 Mar 2007 20:21:20 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 21:15:56 GMT]]></title><description><![CDATA[<p>Naja, vielleicht brauche ich sie irgendwann noch <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>
<p>Womit ich grad gar nicht klar komme, egal wie ich den ausdruck</p>
<p>Ob ich das so schreibe:</p>
<pre><code class="language-cpp">char test[40];
strcpy(test,&quot;hello world&quot;);
SendMessage( hwndList,(UINT)LB_ADDSTRING,(WPARAM)0,(LPARAM)test);
</code></pre>
<p>oder so:</p>
<pre><code class="language-cpp">TCHAR* test = &quot;test&quot;;
SendMessage( hwndList,(UINT)LB_ADDSTRING,(WPARAM)0,(LPARAM)test);
</code></pre>
<p>oder so:</p>
<pre><code class="language-cpp">SendMessage(hwndList, LB_ADDSTRING, 0, (LPARAM)string_input.c_str());
</code></pre>
<p>Ich bekomme in meiner Listbox nur &quot;??????d&quot; z.b. angezeigt.<br />
Woran liegt das ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252546</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 21:15:56 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 21:30:39 GMT]]></title><description><![CDATA[<p>Versuch mal das:</p>
<pre><code class="language-cpp">SendMessage(hwndList, LB_ADDSTRING, 0, reinterpret_cast&lt;LPARAM&gt;(TEXT(&quot;Diese Zeichenkette wird hinzugefügt.&quot;)));
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1252548</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252548</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 25 Mar 2007 21:30:39 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 21:45:33 GMT]]></title><description><![CDATA[<p>Jap, das macht er...</p>
<p>aber wenn ich dann</p>
<pre><code class="language-cpp">SendMessage(hwndList, LB_ADDSTRING, 0, reinterpret_cast&lt;LPARAM&gt;(TEXT(string_input.c_str())) );
</code></pre>
<p>daraus mache, geht das wieder nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252557</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252557</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Sun, 25 Mar 2007 21:45:33 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Sun, 25 Mar 2007 21:57:34 GMT]]></title><description><![CDATA[<p>Damit hat sich das wohl bestätigt *grinz* ...:</p>
<p>(D)Evil schrieb:</p>
<blockquote>
<p>hmm ja scheinst ja noch nicht soo gefestigt in den Grundlagen zu</p>
</blockquote>
<p>Ähm, ja entweder Du verwendest ANSI oder nur UNICODE. Denke mal 'string_input' ist ein std::string, kein std::wstring. Wenn es ein std::wstring ist, brauchst Du auch das Makro TEXT nicht mehr. Dieses sorgt dafür, dass Dein Compiler den in dem doppelten Anführungszeichen eingeschlossenen Text als UNICODE-String interpretiert, falls UNICODE aktiviert ist, andernfalls als ANSI-String. Falls Du auf ein std::string-Objekt angewiesen bist, musst Du den Inhalt entsprechend in einen UNICODE-String umwandeln.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252560</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252560</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 25 Mar 2007 21:57:34 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Mon, 26 Mar 2007 02:01:37 GMT]]></title><description><![CDATA[<p>CodeFinder schrieb:</p>
<blockquote>
<p>Damit hat sich das wohl bestätigt *grinz* ...:</p>
<p>(D)Evil schrieb:</p>
<blockquote>
<p>hmm ja scheinst ja noch nicht soo gefestigt in den Grundlagen zu</p>
</blockquote>
</blockquote>
<p>Ich habe auch nie das Gegenteil behauptet.</p>
<p>So zu dem Unicode. Wenn ich das bisher richtig verstanden habe, dann brauche ich ein wchar_t string, ja?<br />
Wenn ich das aberi umwandeln will, sagt er mir &quot;cannot convert from 'const char [6]' to 'wchar_t *'&quot;</p>
<p>Bin ich grad aufm falschen weg?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252594</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252594</guid><dc:creator><![CDATA[stephan*]]></dc:creator><pubDate>Mon, 26 Mar 2007 02:01:37 GMT</pubDate></item><item><title><![CDATA[Reply to txt-File auslesen und in Listbox anzeigen? on Mon, 26 Mar 2007 13:05:01 GMT]]></title><description><![CDATA[<p>stephan² schrieb:</p>
<blockquote>
<p>[...]<br />
Ich habe auch nie das Gegenteil behauptet.</p>
</blockquote>
<p>Joar, ich weiß; war auch nicht böse gemeint <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>stephan² schrieb:</p>
<blockquote>
<p>So zu dem Unicode. Wenn ich das bisher richtig verstanden habe, dann brauche ich ein wchar_t string, ja?</p>
</blockquote>
<p>Exakt <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>stephan² schrieb:</p>
<blockquote>
<p>Wenn ich das aberi umwandeln will, sagt er mir &quot;cannot convert from 'const char [6]' to 'wchar_t *'&quot;</p>
<p>Bin ich grad aufm falschen weg?</p>
</blockquote>
<p>Joar ich meine auch nicht casten, sondern umwandeln, also mit der Funktion: MultiByteToWideChar.<br />
Hier, guck Dir mal den Post von (D)Evil an: <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-176777.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-176777.html</a><br />
Oder hier, da gibts gleich die perfekte Funktion von Jochen: <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-161855.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-161855.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252943</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252943</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Mon, 26 Mar 2007 13:05:01 GMT</pubDate></item></channel></rss>